gpt4 book ai didi

java - 从 maven 调用时无法使用 ant 构建

转载 作者:行者123 更新时间:2023-11-30 09:27:12 24 4
gpt4 key购买 nike

我有一个 ant 构建文件,它在被自身调用时可以工作。当我从 maven 调用它时,前几个任务执行得很好(init、clean 等),但构建失败:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.7:run (compile) on project maven-stream: An Ant BuildException has occur
ed: The following error occurred while executing this line:
[ERROR] C:\maven_projects\cm\Qlarius Underwriter\build.xml:24: 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:\Program Files\Java\jdk1.7.0_07\jre"
[ERROR] around Ant part ...<ant antfile="C:\maven_projects\cm/Qlarius Underwriter/build.xml">... @ 4:69 in C:\maven_projects\cm\target\antrun\build-ma
in.xml

为什么ant在直接调用而不是通过maven调用时会找到java?

pom.xml 文件的 ant 部分是:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<configuration>
<target>
<ant antfile="${basedir}/Qlarius Underwriter/build.xml">
<target name="LifeQuote"/>
</ant>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>

最佳答案

错误表明您没有指向 JDK。您需要将 JAVA_HOME 更改为 JDK 的根而不是 JRE。这样它将能够找到 javac

其他任务 initclean 如果不使用 javac 可能没问题

关于java - 从 maven 调用时无法使用 ant 构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14663969/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com