ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Weintraub" <>
Subject Re: javac task with classpath issue
Date Fri, 08 Jun 2007 13:12:22 GMT
Please, please change your email preferences to not send HTML email
messages! This is a text only list, and I simply cannot read your

I think what you're saying is that you have two directories: eg1 and
eg2. You compile a JAR in ej1, and need that JAR in eg2. However, eg2
recompiles and rebuilds that JAR. There could be several things going

1). Although Ant says it is rebuilding the JAR, it isn't. The task is
executed, but the task does nothing. This is confusing for example,
when you do the "copy" task, and it claims that it is copying files.
However, I know from the time the task takes, nothing is being copied.

2). The other problem could be the way you call the task. Java tasks
will not recompile if the *.class file is newer than the corresponding
*.java file and the *.jar will not rebuild if the *.jar is newer than
the files it is composed of. If you remove the *.java files from the
eg1 jar file, and then you run eg2, it will recompile the *.class
files because they don't exist. Then, it will rebuild the JAR because
the *.jar is older than the *.class files. The *.jar will also be
rebuilt if you include a new META-INF file too.

The solution would be to make sure that the <java> task can easily
compare the *.java files to their corresponding *.class files and to
make sure that none of the files in your *.jar are newer than the
*.jar. Also make sure that you didn't accidentally add a file to the
directory that is being jar'd. I had a friend who created a temporary
file and that caused the *.jar to be rebuilt.

Another possibility is to use the <uptodate> task to only build the
JAR file if all the conditions are correct. The <uptodate> task (and
the Ant Contrib <outofdate> task) are good ways to prevent rebuilding
when Ant's built in rules don't seem to be working.

On 8 Jun 2007 07:23:05 -0000, query <> wrote:
> I have already compiled some java source files using ANT &lt;javac&gt; task and
created a jar file(eg1.jar). I am using eg1.jar in the classpath to compile files in E:\\ANTBUILD\\eg\\eg2\\sources.The
log shows that in the classpath, it is also including the destination folder as a classpath.
Is it an expected issue in &lt;javac&gt; task?
> &nbsp;&nbsp;&nbsp; [javac] \'-d\'&nbsp;&nbsp;&nbsp; [javac] \'E:\\ANTBUILD\\eg\\eg2\\ClassFiles\'&nbsp;&nbsp;&nbsp;
[javac] \'-classpath\'&nbsp;&nbsp;&nbsp; [javac] \'E:\\ANTBUILD\\eg\\eg2\\ClassFiles;C:\\PROGRA~1\\jdk1.5.0;E:\\ANTBUILD\\eg\\eg1\\eg1.jar
> There a few common java source files which are used in both eg1 and eg2 folder. As eg1.jar
is already having these class files, while compiling eg2 source files, it shouldn\'t create
these classfiles again. But the class files are generated and hence populating eg2.jar file
with more class files than expected. What may be the reason for this behaviour?
> This issue was not observed when I was using some other build tool. Observed only in
ANT tool.

David Weintraub

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message