Garret Wilson
Garret Wilson

Reputation: 21326

Maven compiler configuration via built-in properties?

The Maven Compiler Plugin compile goal indicates (as many of you already know) that I can turn off debug information by setting <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>

I note however that the same documentation indicates that the "user property" for this setting is maven.compiler.debug. What does it mean that something is a "user property"? Does this mean that I can simply set the maven.compiler.debug property to false in my profile, and not even mention anything about a plugin, like this?

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

Upvotes: 0

Views: 817

Answers (1)

Marcelo Silva
Marcelo Silva

Reputation: 26

As answered in another question:

"User property" specifies the name of the Maven property that can be used to set a plugin parameter. This allows configuring a plugin from outside the section. Note that this only works if the parameter is not specified in the section (see MNG-4979 - Cannot override configuration parameter from command line).

The "User property" on Maven3 can be used on the command line, by specifying
-Dmaven.compiler.debug=false or in a POM profile like example below, as per your question:

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

Upvotes: 1

Related Questions