I expected ant to figure out when not to recompile the files which are up to date - unfortunately it keeps happening. My build target contains only:
<javac srcdir="configuration" destdir="${build_env}">
<compilerarg value="-Xlint"/>
</javac>
In verbose ant output I get:
conf:
[javac] MissingConfigurationException.java added as MissingConfigurationException.class doesn't exist.
[javac] TestConfiguration.java added as TestConfig开发者_StackOverflow中文版uration.class doesn't exist.
[javac] TestConfigurationStorage.java added as TestConfigurationStorage.class doesn't exist.
[javac] Compiling 3 source files to /blah/build
but they do exist and are available in the "/blah/build/com/blah/configuration/..." directory.
How can I fix this?
I have seen this in the past when the class is defined in a location that differs from the package that was declared in the .java file.
For instance, if we're looking at a file in com/stackoverflow/ant/error called AJavaFile.java. It better have the package defined as:
package com.stackoverflow.ant.error;
or it the javac compiler will put it in a different place than is expected by the package declaration.
Had this same confounding issue.
You should try the base of the path to the location of your files from where ant is being run, not just the relative directory down inside it.
javac seems to take issue with trying to determine the packages properly when they do not exactly match those in your "build" starting from exactly how you specified them. And so it just compiles everything in those cases. This sort of makes sense if you think about it, despite it showing some drawbacks. Paths in what has already been built needing to match exactly what is to be compiled. It is just not able to look ahead and resolve the full paths when it is not told to start from the same base directory as is written into the "build" directory.
If your code is in /blah/build/com/blah/configuration/... then try
<javac srcdir="/blah/" destdir="${build_env}">
...
</javac>
or
<javac destdir="${build_env}">
<src path="blah/"/>
...
</javac>
精彩评论