2

我有一个编译 JavaFX 8 应用程序的 Maven 项目。你能告诉我如何在编译期间显示详细的输出吗?通常这是由 -X 参数完成的,但我想将其配置到 POM 文件中。

4

2 回答 2

6

You can use the configuration of the maven-compiler-plugin to add such supplemental arguments like this:

<project>
  ...
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.1</version>
          <configuration>
            <compilerArgs>
              <arg>-Xmaxerrs=1000</arg>
              <arg>-Xlint</arg>
            </compilerArgs>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
  ...
</project>

Furthermore you can use the verbose option to enhance the output like this:

<project>
  ...
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.1</version>
          <configuration>
            <verbose>true</verbose>
            ..
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
  ...
</project>
于 2013-08-25T12:31:39.800 回答
1

除了khmarbaise的回答:

-X需要值(例如-Xmaxwarns)的编译器参数需要传递给单独的<arg>标签。

例子:

  <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
      <compilerArgs>
        <arg>-Xlint:all</arg>
        <arg>-Xmaxwarns</arg>
        <arg>50000</arg>
      </compilerArgs>
    </configuration>
  </plugin>

经测试:

  • Maven 3.0.5 + Maven 编译器插件 3.2
  • Maven 3.3.9 + Maven 编译器插件 3.6.0
于 2016-12-09T10:08:50.587 回答