我正在用统一的 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
?我搜索了我的批处理/构建文件,但找不到更改发生的位置