Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
296 views
Welcome To Ask or Share your Answers For Others

1 Answer

If you are using Ant 1.6 or higher, you can set the javac attribute fork="yes". This gives you the ability to specify the path of your executable when using jikes, jvc, gcj, sj, or whatever version of javac you are using.

  <javac srcdir="${src}"
         destdir="${build}"
         fork="yes"
         executable="/opt/java/jdk1.1/bin/javac"
         compiler="javac1.1"
  />

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...