Currently, when building our project we use:
javac <various command line options> C:\project\CompilationHelper.java
The CompilationHelper
class then references our main files and through a chain of dependencies everything we need gets compiled and nothing more. The class directory is then jar'ed.
I've started using ant and noticed that by just building our source directory we get a larger .jar file than normal.
I realise that the best solution is to find all the unused .java files and remove them but we actu开发者_JS百科ally have one "main" project and one "child" project within it which uses a lot of the components of the main one and separating them is unfeasable at the moment.
Is there a way to tell ant to compile one file and all it's dependencies rather than a directory?
Many thanks in advance,
Dave
You can use your CompilationHelper method in ant, too. Just give the CompilationHelper.java to your javac task, instead the whole source directory.
Here is an example:
<javac srcdir="src"
destdir="classes">
<include name="CompilationHelper.java" />
</javac>
If all the source files are (according to their package structure) below src, and a package-less class CompilationHelper in this directory, it should work.
精彩评论