如何告诉 ant 使用特定的 javac 可执行文件进行构建? [英] How to tell ant to build using a specific javac executable?

查看:21
本文介绍了如何告诉 ant 使用特定的 javac 可执行文件进行构建?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从命令行告诉 ant 使用特定的 javac 可执行文件?

How can I tell ant to use a specific javac executable from the command line?

我在我们分发的库中安装了 gcj,它是作为 gcc 的一部分构建的,我希望有一个针对它构建的特定 Java 软件.但是,它似乎只是使用了 system-gcc,而诸如-Dbuild.compiler"之类的选项似乎要我指定某种 Java 类而不是文件路径.

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.

我希望在 Makefile 中有类似于 CC 的东西.

I was hoping for something similar to CC in Makefiles.

我确定这很简单,只是我太笨了.

I'm sure it's something really simple, and I'm just being stupid.

明确地说,如果可能,我想避免自己编辑构建文件.有没有一些标准的方法可以简单地在命令行上指定编译器给 ant?我不介意构建文件在某种意义上表现良好"的假设.

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.

推荐答案

如果您使用的是 Ant 1.6 或更高版本,您可以设置 javac 属性 fork="yes".这使您能够在使用 jikes、jvc、gcj、sj 或您正在使用的任何版本的 javac 时指定可执行文件的路径.

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"
  />

这篇关于如何告诉 ant 使用特定的 javac 可执行文件进行构建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆