ant buildfile 设置 javac 位置 [英] ant buildfile setting javac location

查看:30
本文介绍了ant buildfile 设置 javac 位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编辑一个旧项目的构建文件.当我向使用 Java 1.6 的项目添加一些 jar 文件时,它不会构建.它说

I'm editing the buildfile of an old project. When I add some jar files to the project that use Java 1.6, it won't build. It says

[javac] javac: invalid target release: 1.6

很明显我需要告诉 ant 构建文件使用 javac 1.6.

So clearly I need to tell the ant buildfile to use javac 1.6.

我该怎么做?我的系统上安装了 JDK1.6,但默认的 javac 是 1.5.我不想更改默认的javac...我只想将这个proejct中的javac位置设置为JDK1.6/bin/javac.如何在 ant 构建文件的 XML 中执行此操作?

How do I do this? I have JDK1.6 installed on my system, but the default javac is 1.5. I don't want to change the default javac... I just want to set the javac location in this one proejct to JDK1.6/bin/javac. How do I do this in the XML of an ant buildfile?

谢谢,
公里

推荐答案

您可以创建一个包装脚本,在执行 ant 之前,您可以在其中更改您的 JAVA_HOME.

You can create a wrapper script in which you change your JAVA_HOME before executing ant.

例如build.sh

export JAVA_HOME=/path/to/jdk1.6
ant "$@"

现在,当您调用 build.sh 时,它将对 javacjava 和任何其他命令使用 java6.

Now when you call build.sh it will use java6 for both javac, java and any other commands.

IMO 这比摆弄 build.xml(并创建一个新的 javac 进程)要好.

IMO this is better than fiddling with the build.xml (and forking a new javac process).

这篇关于ant buildfile 设置 javac 位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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