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

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top