shellholic
shellholic

Reputation: 6114

Show compiler warnings without editing pom.xml

I would like to always show compiler warning and deprecation when I compile with Maven. I know how to do it by editing the pom.xml, but I want this behavior by default only for myself (so I can't edit the pom.xml).

I tried:

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

but this doesn't show any warnings (if I modify the pom.xml to show them, they are there).

Both expressions (maven.compiler.showWarnings and maven.compiler.showDeprecation) exist.

What do I miss?

Upvotes: 8

Views: 3294

Answers (2)

Guest
Guest

Reputation: 21

Try this.

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

Upvotes: 2

Wouter Lievens
Wouter Lievens

Reputation: 4029

You could perhaps wrap these in a maven profile, and instead specific the profile with -P.

It would be something like this (I did not test this though):

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

And then run as

mvn compile -Pdebug

Upvotes: 0

Related Questions