【问题标题】:Arguments for eclipse compiler in MavenMaven中eclipse编译器的参数
【发布时间】:2014-04-13 22:45:44
【问题描述】:

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

【问题讨论】:

  • 使用&lt;compilerArgument&gt;-log compile.xml&lt;/compilerArgument&gt;也不起作用?我看到您的问题中已将其注释掉。
  • 不,不是真的...我尝试了几乎所有我可以从 maven-compiler-plugin 的 compile:compile 页面中提供的选项的组合

标签: java eclipse maven eclipse-jdt maven-compiler-plugin


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 2015-05-14
    • 1970-01-01
    • 1970-01-01
    • 2019-09-18
    • 1970-01-01
    • 1970-01-01
    • 2015-10-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多