You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Kevin Toomey <to...@yahoo.com> on 2000/07/06 17:05:04 UTC
Problem with javac task using -sourcepath
I've run into a problem using the javac task and the
way it creates the -sourcepath parameter. I've just
started using Ant (which is great, by the way), so the
problem could very well be mine :p. Any help would be
greatly appreciated.
The javac task passes the srcdir attribute as the
-sourcepath. If the -sourcepath attribute is passed to
sun.tools.javac.Main, only the -sourcepath is searched
for source files during compilation as opposed to the
classpath.
So if my directory structure looks like this:
\test
\classes
\testa
\testb
\java
\testa
classa.java (package testa)
\testb
classb.java (package testb)
and classa.java contains:
package testa;
import testb.classb;
public class classa {
classb bb;
public classa(){
bb = new classb();
}
}
and my build.xml looks like:
<?xml version="1.0"?>
<project name="foo" default="all" base="/test">
<target name="init">
<property name="in" value="${base}/java" />
<property name="out" value="${base}/classes" />
</target>
<target name="all" depends="init">
<javac srcdir="${in}/testa" destdir="${out}"/>
</target>
</project>
the build fails, because only /test/java/testa is
searched, for classb.java.
Am I missing something?
Thanks for any help,
Kevin
__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/
Re: Problem with javac task using -sourcepath
Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "KT" == Kevin Toomey <to...@yahoo.com> writes:
KT> Am I missing something?
How about <javac srcdir="${in}" destdir="${out}"/>?
Apart from that, there has been a patch commited by Conot today that
allows for multiple sourcedirs to be specified, that would be
<javac destdir="${out}">
<src path="${in}/testa" />
<src path="${in}/testb" />
</javac>
Stefan
Re: Problem with javac task using -sourcepath
Posted by Peter Donald <do...@mad.scientist.com>.
Try:
<?xml version="1.0"?>
<project name="foo" default="all" base="/test">
<target name="init">
<property name="in" value="${base}/java" />
<property name="out" value="${base}/classes" />
</target>
<target name="all" depends="init">
<!-- changed to -->
<javac srcdir="${in}" destdir="${out}" includes="testa/**" />
<!-- or -->
<javac srcdir="${in}" destdir="${out}">
<include name="testa/**" />
</javac>
<!-- or -->
<javac srcdir="${in}" destdir="${out}">
<exclude name="testb/**" />
</javac>
</target>
</project>
>Am I missing something?
No. Everyone seems to fall for that (or at least a lot of traffic ion list
is gernearated for it. So you are not alone :P
Cheers,
Pete
*------------------------------------------------------*
| "Nearly all men can stand adversity, but if you want |
| to test a man's character, give him power." |
| -Abraham Lincoln |
*------------------------------------------------------*