Hi Dominique, > > I have a problem with the javac task that I cannot solve, maybe somebody > > can help me. Let's say I have a directory layout like this: > > > > src/proj1/Class1.java > > src/proj1/Class2.java > > src/proj2/Class1.java > > src/proj2/Class2.java > > > > Now I want to compile Class1 from proj1 and Class2 from proj2 and > > exclude the other two. Also, I need to compile those in one go because > > they depend on each other. I didn't find a way to implement this using > > the srcdir attribute, or nested src tags. Any ideas? > > The only way to do this is by resetting srcdir to an empty string. > That's the technique <compilewithwalls> and others (including me) have > used in the past. > > That way, Javac will compile *only* the file explicitly given to it, > and never implicitly compile files the explicitly given classes depend > on (which will lead to compile failures if the depend classes aren't > found via the classpath). > > AFAIK, <javac> will accept several nested <fileset>s, so that's how > you include source files from several directories (but remember to > scrdir=""). --DD
Yeah, I suppose this would work. But it would have the disadvantage that
the javac task could not map the sources to the .class files, and would
recompile everything on each invocation. Correct me if I'm wrong.
However, I think I found a better solution that works for me. Instead of
compiling it in one go, I compile it in 2 steps, and in the 1st step I
set the -sourcepath to the other sources dir, so that javac pulls in the
required sources from the other project. Then in the second step, I set
the classpath to the directory into which the 1st step built its
classes, so that it picks up the correct dependencies again. In both
steps I can set the necessary includes/excludes. For the simplified
example I gave above, this would look like:
<javac srcdir="proj1" excludes="Class2.java" destdir="classes"
sourcepath="proj2"/>
<javac srcdir="proj2" excludes="Class1.java" destdir="classes"
classpath="classes" />
Of course, having this in one javac task invocation would be much nicer.
*hint*
Cheers, Roman
--
http://kennke.org/blog/
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
