为什么ANT没有达到Eclipse工作空间默认的JRE for build

时间:2023-01-24 14:05:43

I'm trying to compile my projects with ANT build script. When I change the Eclipse workspace default JRE, let say to JDK1.6.0_27 32bit the ANT still using JRE 1.7.0 64bit (which is system default)

我正在尝试使用ANT构建脚本编译我的项目。当我更改Eclipse工作空间的默认JRE时,让我们说JDK1.6.0_27 32位,ANT仍然使用JRE 1.7.0 64位(这是系统默认的)

There is an option to set ANT build file to use different java version by setting "External Tools Configuration", selecting ANT build file and selecting relevant java in "JRE" tab, but that is strange, because there is option in the same place to use "Run in the same JRE as the workspace", which doesn't works for me (running Eclipse Indigo 3.7).

通过设置“外部工具配置”,选择ANT构建文件并在“JRE”选项卡中选择相关的java,可以选择设置ANT构建文件以使用不同的Java版本,但这很奇怪,因为在同一个地方有选项使用“在与工作区相同的JRE中运行”,这对我不起作用(运行Eclipse Indigo 3.7)。

That can be not problem when you have an one project with one ANT script, but I have an 7 projects with 7 build files, and I need to make 2 different releases: one with Java 1.6 32bit, and one Java 1.7 64bit. Selection of required settings manually each time (I'm building releases almost every day) became the real 'pain in the ass'.

当你有一个带有一个ANT脚本的项目时,这可能不是问题,但我有一个包含7个构建文件的7个项目,我需要制作2个不同的版本:一个使用Java 1.6 32位,一个使用Java 1.7 64位。每次手动选择所需的设置(我几乎每天都在发布)会成为真正的“屁股”。

1 个解决方案

#1


0  

Okay, I found the solution by myself. I was created new ANT build file and called from it to the other ANT files, like this:

好的,我自己找到了解决方案。我创建了新的ANT构建文件并从中调用其他ANT文件,如下所示:

<project name="build-all" default="build.all">

<target name="proj1">
    <ant antfile="build-proj1.xml" target="build" inheritAll="false"/>
</target>

<target name="proj2">
    <ant antfile="build-proj2.xml" target="build" inheritAll="false"/>
</target>

<target name="proj3">
    <ant antfile="build-proj3.xml" target="build" inheritAll="false"/>
</target>

<target name="build.all" depends="proj1,proj2,proj3"/>

Now I can go to the Eclipse, change the target to desired JRE version for this top level ANT file, all sub build files are executed using the parent's settings.

现在我可以转到Eclipse,将目标更改为此*ANT文件的所需JRE版本,所有子构建文件都使用父级设置执行。

#1


0  

Okay, I found the solution by myself. I was created new ANT build file and called from it to the other ANT files, like this:

好的,我自己找到了解决方案。我创建了新的ANT构建文件并从中调用其他ANT文件,如下所示:

<project name="build-all" default="build.all">

<target name="proj1">
    <ant antfile="build-proj1.xml" target="build" inheritAll="false"/>
</target>

<target name="proj2">
    <ant antfile="build-proj2.xml" target="build" inheritAll="false"/>
</target>

<target name="proj3">
    <ant antfile="build-proj3.xml" target="build" inheritAll="false"/>
</target>

<target name="build.all" depends="proj1,proj2,proj3"/>

Now I can go to the Eclipse, change the target to desired JRE version for this top level ANT file, all sub build files are executed using the parent's settings.

现在我可以转到Eclipse,将目标更改为此*ANT文件的所需JRE版本,所有子构建文件都使用父级设置执行。