javac from ant fails to compile two source directories

T

timasmith

Hi,

I have

<target name="compile" depends="prepare">
<javac destdir="${build.dir}" classpathref="build.classpath"
debug="on">
<src path="${framework.dir}:${src.dir}"/>
</javac>
</target>

The files in the src.dir

com.mysite.myapp...

are dependent on the framework files

com.mysite.myframework...

and everything compiles ok in Eclipse though I had to create a build
path source link which was a little strange but worked.

How can I compile two directories with one dependent on the other?

thanks

Tim
 
A

alexandre_paterson

Hi there,

Hi,

I have

<target name="compile" depends="prepare">
<javac destdir="${build.dir}" classpathref="build.classpath"
debug="on">
<src path="${framework.dir}:${src.dir}"/>
</javac>
</target>

The files in the src.dir

com.mysite.myapp...

are dependent on the framework files

com.mysite.myframework... ....
How can I compile two directories with one dependent on the other?

You don't have circular dependencies right? (which would be very
ugly).

Then you can simply call Ant's javac task twice from your compile
target.

For example, if you'ge got a ${myapp.dir} defined :

<target name="compile" depends="prepare">
<javac destdir="${build.dir}" classpathref="build.classpath">
<src path="${framework.dir}:${src.dir}"/>
</javac>
<javac destdir="${build.dir}" classpathref="build.classpath">
<src path="${myapp.dir}:${src.dir}"/>
</javac>
</target>


This will work if "myapp" depends on "framework" but not the other
way round. Note that you must call javac on your "framework" first,
otherwise it won't work. Note also that you must use the same destdir.

This is relatively simple and straightforward, but there may be other,
better, ways to do it, which I leave to other posters to explain,

Alex
 
T

timasmith

thanks, I realized Eclipse was masking compilation errors because it
was referencing an old jar.

Once it compiled my ant worked.

thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top