TMN
TMN

Reputation: 3070

Ant copy task ignoring files

I have an Ant copy task (defined in a Maven script invoked by a Jenkins build) that appears to be correct but is not copying correctly. The task is defined as

<copy todir="./Virgo/config" overwrite="true" verbose="true">
    <fileset dir="${config.folder}">
        <include name="*.properties, *.xml" />
    </fileset>
</copy>

When I run the task, I can see that the correct directory is specified, but the copy task doesn't select any files. Both the source and destination directories exist, and I'm not getting any errors. What I'm seeing is

14:52:40  [INFO] Executing tasks
14:52:40  [DEBUG] getProperty(ns=null, name=ant.reuse.loader, user=false)
14:52:40  [antlib:org.apache.tools.ant] Could not load definitions from resource org/apache/tools/ant/antlib.xml. It could not be found.
14:52:40       [echo] Copying files from ../com.x.y.z.container.build/config...
14:52:40  fileset: Setup scanner in dir C:\Jenkins\workspace\container-build\com.x.y.z.container.build\config with patternSet{ includes: [*.properties, *.xml] excludes: [] }
14:52:40  [INFO] Executed tasks

I've tried adding files to the source directory, making the source files newer than the ones in the destination, even removing the files in the destination directory. What bothers me is that it appears that the fileset isn't matching any files, even though the path is correct. Has anyone ever seen this behavior before?

Upvotes: 4

Views: 6295

Answers (2)

Andrew Parks
Andrew Parks

Reputation: 8087

To those that are confused as to why copy is not working, it could be because the Copy task will only copy files if the source is newer than the destination.

Specify overwrite="true" to ensure that the copy happens.

Upvotes: 1

Emmanuel Ballerini
Emmanuel Ballerini

Reputation: 684

From the PatternSet section in the Ant manual: http://ant.apache.org/manual/Types/patternset.html

Note that while the includes and excludes attributes accept multiple elements separated by commas or spaces, the nested <include> and <exclude> elements expect their name attribute to hold a single pattern.

You could change your script to something like

<copy todir="./Virgo/config" overwrite="true" verbose="true">
    <fileset dir="${config.folder}">
        <include name="*.properties" />
        <include name="*.xml" />
    </fileset>
</copy>

Upvotes: 4

Related Questions