0

I wrote a bash shell that runs a java application. To automatize the process I want to first add ant to build the java application. However, I don't want to rebuilt the existing application if there aren't any changes in *java files. I'm lost as what is a good way to do this.

2 Answers 2

2

The Ant javac task does exactly that:

Compiles a Java source tree.

The source and destination directory will be recursively scanned for Java source files to compile. Only Java files that have no corresponding .class file or where the class file is older than the .java file will be compiled.

So just create a buildfile that uses javac and have the bash script call Ant to compile before running the application. You can also use Ant itself to run the application by using the java task.

2
  • Thanks, I understand it now. In my build.xml I have ` <javac debug="true" debuglevel="${debuglevel}" destdir="bin" includeantruntime="false" source="${source}" target="${target}"> <src path="src"/> <classpath refid="GRAB.classpath"/> </javac> ` I assume that's where Ant javac is used.
    – PyPhys
    Jan 25, 2015 at 21:45
  • Yes this is how it is usually called. But I don't think you need to specify the src element if you're already using the source="${source}" attribute.
    – M A
    Jan 26, 2015 at 8:10
1

Javac task of ant should be doing exactly that. Can check the answer to the question link below which provides little more detail

how to compile only changed source files using ANT

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.