通过内置属性配置Maven编译器?



Maven编译器插件编译目标表明(你们中的许多人已经知道(我可以通过设置<debug>false</debug>来关闭调试信息。

<project …>
…
<profiles>
<profile>
<id>production</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<debug>false</debug>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

但是,我注意到相同的文档表明此设置的"用户属性"是maven.compiler.debug。某物是"用户属性"是什么意思?这是否意味着我可以简单地将maven.compiler.debug属性设置为在我的配置文件中false,甚至不提及有关插件的任何内容,例如这样?

<project …>
…
<profiles>
<profile>
<id>production</id>
<properties>
<maven.compiler.debug>false</maven.compiler.debug>
</properties>
</profile>
</profiles>
</project>

正如另一个问题所回答的那样:

"用户属性"指定可用于设置插件参数的 Maven 属性的名称。这允许从该部分外部配置插件。请注意,仅当该部分中未指定参数时,此操作才有效(请参阅 MNG-4979 - 无法从命令行覆盖配置参数(。

Maven3 上的"用户属性"可以在命令行上使用,方法是指定
-Dmaven.compiler.debug=false或 在 POM 配置文件中,如下例所示,根据您的问题:

<properties> 
<maven.compiler.debug>false</maven.compiler.debug>
</properties>

最新更新