【发布时间】:2011-01-02 14:49:40
【问题描述】:
我正在使用统一的 Maven 构建来改造一堆现有的 Java 项目。由于每个项目都很成熟并且已经建立了基于 Ant 的构建,所以我使用maven-antrun-plugin 来执行现有的build.xml,如下所示:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>compile</phase>
<configuration>
<tasks>
<ant antfile="build.xml" target="compile" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
当我运行 mvn compile 时,构建失败并显示以下消息:
[INFO] An Ant BuildException has occured: The following error occurred
while executing this line:
build.xml:175: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "C:\Java\jdk1.6.0_13\jre"
让我困惑的是
- 我将
JAVA_HOME=C:\Java\jdk1.6.0_13作为我的环境设置的一部分,当mvn.bat执行时,这正是我得到的值,但是正如您在错误消息中看到的那样,它显示为C:\Java\jdk1.6.0_13\jre - 如果我运行
ant compile一切都编译得很好
这是否意味着maven-antrun-plugin 可能会做类似set JAVA_HOME=%JAVA_HOME%\jre 的事情?我搜索了我的批处理/构建文件,但找不到更改发生的位置
【问题讨论】: