gpt4 book ai didi

java - Maven 中 eclipse 编译器的参数

转载 作者:搜寻专家 更新时间:2023-11-01 00:56:44 25 4
gpt4 key购买 nike

在 Eclipse Compiler for Java standalone 中,我能够通过命令行属性在 XML 中记录编译信息,如在这个 stub 中:

java -jar ecj-4.3.2.jar -log compile.xml <classpath,files>

但是,当我将 maven-compiler-plugin 与 plexus-compiler-eclipse 一起使用时,似乎无法将此参数传递给编译器,而且我不确定造成这种情况的原因,插件的编译器是否是另一个,它不会生成新进程(我什至尝试了可执行参数)或其他原因。

这是 pom.xml 部分:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<compilerId>eclipse</compilerId>
<forceJavacCompilerUse>true</forceJavacCompilerUse>
<!--<compilerArgument> -log compile.xml </compilerArgument>-->
<compilerArgs>
<arg>-log</arg>
<arg>compile.xml</arg>
</compilerArgs>
<fork>true</fork>
<verbose>true</verbose>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-eclipse</artifactId>
<version>2.3</version>
</dependency>
</dependencies>
</plugin>

最佳答案

eclipse 实现是 plexus-compiler-eclipse,它不接受 fork 参数,因为它使用内部 jvm。因此,它只能接受像 MAVEN_OPTS 这样的 jvm 选项。

不过,默认实现是plexus-compiler-javac,支持自定义executable。解决方法可能是这样的:将 fork 设置为 true,并指定 executable

关于bash中的wraper,你可以访问这里:https://stackoverflow.com/a/37971000/3289354

关于java - Maven 中 eclipse 编译器的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22306811/

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