I am trying to get ant4eclipse to work and I have used ant a bit, but not much above a simple scripting language. We have multiple source folders in our Eclipse projects so the example in the ant4eclipse documentation needs adapting:
Currently I have the following:
<target name='build'> <!-- resolve the eclipse output location --> <getOutputpath property='classes.dir' workspace='${workspace}' projectName='${project.name}' /> <!-- init output location --> <delete dir='${classes.dir}' /> <mkdir dir='${classes.dir}' /> <!-- resolve the eclipse source location --> <getSourcepath pathId='source.path' project='.' allowMultipleFolders='true'/> <!-- read the eclipse classpath --> <getEclipseClasspath pathId='build.classpath' workspace='${workspace}' projectName='${project.name}' /> <!-- compile --> <javac destdir='${classes.dir}' classpathref='build.classpath' verbose='false' encoding='iso-8859-1'> <src refid='source.path' /> </javac> <!-- copy resources from src to bin --> <copy todir='${classes.dir}' preservelastmodified='true'> <fileset refid='source.path'> <include name='**/*'/> <!-- patternset refid='not.java.files'/> --> </fileset> </copy> </target>
The task runs successfully, but I cannot get the to work – it is supposed to copy all non-java files over too to emulate the behaviour of eclipse.
So, I have a pathId named source.path which contains multiple directories, which I somehow needs to massage into something the copy-task like. I have tried nesting which is not valid, and some other wild guesses.
How can I do this – thanks in advance.
You could use the
foreachtask from the ant-contrib library:If your
source.pathcontains file paths as well then you could theiftask (also from ant-contrib) to prevent attempting to copy files for a file path, e.g.