【发布时间】:2016-01-11 02:13:09
【问题描述】:
我有一个 Ant 项目,它可以自行构建。我现在正试图将它包装在一个 Maven 构建中,该构建将使用 maven-antrun-plugin 启动 Ant 构建。当我这样做时,构建失败并出现此错误,
[ERROR] C:\Users\bobby\workspace\libraries\build-targets\common-targets.xml:170: Unable to find a javac compiler;
[ERROR] com.sun.tools.javac.Main is not on the classpath.
[ERROR] Perhaps JAVA_HOME does not point to the JDK.
[ERROR] It is currently set to "C:\Java\jdk1.8.0_65\jre"
有很多关于此错误的 SOF 帖子,但我觉得我的帖子很独特,因为它仅在我将 Ant 构建包装在 Maven 中时发生$ ant build.
这是我的 pom.xml 文件的一部分
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>process-resources</phase>
<configuration>
<tasks>
<ant antfile="build.xml" target="build" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>add-jar</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>build/bin/myWarFile.war</file>
<type>war</type>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
我的JAVA_HOME环境变量设置为C:\Java\jdk1.8.0_65。
错误中提到的文件来自我的工作维护的一个库,我们保存了所有的罐子。在该文件中,这是第 170 行的内容
<target name="compile-src">
<!-- Compile source -->
<javac srcdir="${java.src.dir}"
destdir="${class.dir}"
debug="${debug.flag}"
deprecation="${deprecation.flag}"
nowarn="${warnings.flag}"
optimize="off"
source="${source.value}">
<classpath refid="compile.classpath"/>
</javac>
</target>
source= 所在的行是第 170 行。
【问题讨论】:
标签: maven ant java-home maven-antrun-plugin