显示编译器警告而不编辑pom.xml

时间:2011-07-06 08:53:42

标签: maven compiler-warnings

我想在使用Maven编译时始终显示编译器警告和弃用。我知道如何通过编辑pom.xml来执行此操作,但我希望此操作默认仅适用于我自己(因此我无法编辑pom.xml)。

我试过了:

mvn -Dmaven.compiler.showWarnings=true -Dmaven.compiler.showDeprecation=true clean compile

但是这没有显示任何警告(如果我修改pom.xml以显示它们,它们就在那里)。

两个表达式(maven.compiler.showWarningsmaven.compiler.showDeprecationexist

我想念什么?

2 个答案:

答案 0 :(得分:1)

试试这个。

mvn clean install -Dmaven.compiler.showDeprecation=true -Dmaven.compiler.showWarnings=true > warnings.txt

答案 1 :(得分:0)

您可以将它们包装在maven配置文件中,而是使用-P。

指定配置文件

这将是这样的(虽然我没有测试过):

<profiles>
    <profile>
        <id>development</id>
        <build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <!-- compiler options go here -->
            </configuration>
        </plugin>
        </build>
    </profile>
</profiles>

然后以

运行
mvn compile -Pdebug
相关问题