Skip to content
Advertisement

Maven, error copying a file with antrun

I have some problems copying files with Maven.

I use the antrun plugin in this manner: (I want to copy the file jdk1.5.0_22.tgz to a temporary folder)

<exec executable="cp">
    <arg value="${parent.resources}/jdk1.5.0_22.tgz" />
    <arg value="${iso.tempDir}/"/>
</exec>

And it works fine. Now I make a small change to be independent from the jdk file version: (I only change jdk1.5.0_22.tgz to jdk*.*)

<exec executable="cp">
    <arg value="${parent.resources}/jdk*.*" />
    <arg value="${iso.tempDir}/"/>
</exec>

In this case I have the following error: [exec] /bin/cp: impossible to do the stat of ‘../../resources/jdk*.*’: No such file or directory

Why?

Advertisement

Answer

This does not seem to be a Maven question.

It is even hardly an Ant question.

With jdk*.* you are expecting wildcard expansion to be performed by the shell. However, this all is not executed by the shell, rather it is executed by Ant. Ant does not do the wildcard expansion, rather passes the original string including the wildcards into cp, which also does not do the wildcard expansion, rather interprets it literally.

As something toward a solution, may I suggest you use Ant’s fileset to find the file. While you’re at it, Ant’s copy may do the copy, which would then be platform-independent (much nicer than using cp).

Advertisement