6

在 Eclipse Compiler for Java Standalone 中,我可以通过命令行属性将编译信息记录到 XML 中,就像在这个存根中一样:

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>
4

1 回答 1

0

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

但是,默认实现是plexus-compiler-javac,它支持 custom executable。解决方法可能是这样的:设置fork为 true,并指定executable.

对于 bash 中的包装器,您可以访问此处:https ://stackoverflow.com/a/37971000/3289354

于 2016-06-22T17:31:28.183 回答