How can I tell ant
to use a specific javac executable from the command line?
I have an installation of gcj, built as part of gcc, within a library we distribute, and I'd like to have a particular piece of Java software built against that. However, it just seems to use the system-gcc, and options such as "-Dbuild.compiler" seem to want me to specify some kind of Java class rather than a filepath.
I was hoping for something similar to CC in Makefiles.
I'm sure it's something really simple, and I'm just being stupid.
To be clear, I'd like to avoid editing the build file myself if possible. Is there not some standard way to simply specify the compiler on the command-line to ant? I don't mind the assumption that the buildfile is "well-behaved" in some sense.
I've done something similiar before, using the Ant Exec task. See http://ant.apache.org/manual/Tasks/exec.html
It allows you to call a specific system command. In our case, we needed to call Delphi (don't ask) to build some DLL's for a particular project. The exec command would also allow you to call gcj instead of javac.
If you are using Ant 1.6 or higher, you can set the
javac
attributefork="yes"
. This gives you the ability to specify the path of your executable when using jikes, jvc, gcj, sj, or whatever version ofjavac
you are using.The
-D
argument when calling ant will use a property from the command line inside of the Ant script. The form that it is used in is:ant -Dmyvar=true
Where
myvar
is the name of the property, andtrue
is the value you want to use in your script.The easiest way then would be to use a property for your javac executable attributes.
and then on the command line you could call:
From the javac task page:
The way I read this, you need to write a class that implements CompilerAdapter and uses your compiler. Then typedef that task and use it in the javac compiler attribute.