tags:

views:

29

answers:

1

Hello,

in a project we have several source pathes, so we defined a path for that:

<path id="de.his.path.srcpath">
    <pathelement path="${de.his.dir.src.qis.java}"/>
    <pathelement path="${de.his.dir.src.h1.java}"/>
    ...
</path>

Using the path works fine in the <javac> tag with:

<src refid="de.his.path.srcpath" />

In the next step we have to copy non java files to the classpath folder:

<copy todir="${de.his.dir.bin.classes}" overwrite="true">
    <fileset refid="de.his.path.srcpath">
       <exclude name="**/*.java" />
    </fileset>
</copy>

Unfortunately, this does not work because "refid" and nested elements may not be mixed.

Is there another way I can get a set of all none java files in my source path without copying the list of source pathes into individual filesets?

+1  A: 

Here's an option. First, use the pathconvert task to make a pattern suitable for generating a fileset:

<pathconvert pathsep="/**/*," refid="de.his.path.srcpath" property="my_fileset_pattern">
    <filtermapper>
        <replacestring from="${basedir}/" to="" />
    </filtermapper>
</pathconvert>

Next make the fileset from all the files in the paths, except the java sources. Note the trailing wildcard /**/* needed as pathconvert only does the wildcards within the list, not the one needed at the end:

<fileset dir="." id="my_fileset" includes="${my_fileset_pattern}/**/*" >
     <exclude name="**/*.java" />
</fileset>

Then your copy task would be:

<copy todir="${de.his.dir.bin.classes}" overwrite="true" >
    <fileset refid="my_fileset" />
</copy>

For portability, instead of hard-coding the unix wildcard /**/* you might consider using something like:

<property name="wildcard" value="${file.separator}**${file.separator}*" />
martin clayton