tags:

views:

1194

answers:

3

Hello,

I created my own build.xml which got:

<target name="compile">
    <mkdir dir="build"/> 
    <javac destdir="build"> 
     <src path="src"/> 
    </javac>
</target>

<target name="build" depends="compile">
    <mkdir dir="dist"/>
    <jar destfile="dist/app.jar" basedir="build" />
</target>

<target name="run" depends="compile">
    <java classname="webserver.Loader" classpath="build" fork="true" />   
</target>

It works great. When I call ant run so it compiles and runs my application, but my application got a package with icons and it isn't moved to a folder "build" so my application ends with an exception that it couldn't locate my icons. When I move them by myself so it works.

I tried to use

<copy todir="build/app/icons">
    <fileset dir="src/app/icons"/>
</copy>

It works, but I would like to do it without the copy command. Is there any parameter to javac? or something else?

Thank you for answer.

+6  A: 

Sorry, you will need to copy non-java files manually. Resources are technically not "source". The command-line javac will not copy resource files from your source directory to the output directory, neither will ant's javac task.

Mike Miller
+2  A: 

No, there isn't. The copy task is the correct way to copy resources into your build folders.

jsight
+4  A: 

There is no such parameter. You can copy all sorts of files between your directories with:

<copy todir="build">
    <fileset dir="src"
             includes="**/*.xml,**/*.properties,**/*.txt,**/*.ico" />
</copy>
Chris Winters
more simple: exclude="**/*.java" instead of include
Arne Burmeister