Reputation: 1023
I would like to run the command javac -version
when the Ant does it build on Linux. I did a bit of reading and wrote my xml as follows:
<javac srcdir="SourceDir" destdir="DestDir" executable="${env.JAVA_HOME}">
<classpath>
....
</classpath>
<compilerarg value="javac -version"/>
</javac>
But i get an error as follows:
[javac] javac: invalid flag: javac -version
[javac] Usage: javac <options> <source files>
[javac] use -help for a list of possible options
What is the issue? How can i make Ant print the jdk version that it is using when running the javac command. Thanks in advance!
Upvotes: 0
Views: 215
Reputation: 15254
<project>
<echo>Java Version via Ant: ${ant.java.version}</echo>
<echo>Java Version System Prop: ${java.version}</echo>
</project>
or
<target name="print-version">
<echo>Java/JVM version: ${ant.java.version}</echo>
<echo>Java/JVM detail version: ${java.version}</echo>
</target>
Upvotes: 1