Skip to content

Maven properties configuration

In Apache Maven, the <properties> section within the pom.xml file serves as a centralized location to define project-level constants and configuration values.^[600-developer-java-3-party-java-maven01.md] These properties act as placeholders that can be referenced elsewhere in the build file using the ${propertyName} syntax, promoting consistency and reducing redundancy.^[600-developer-java-3-party-java-maven01.md]

Common Configurations

The properties section is frequently used to define build and environment settings, particularly regarding character encoding and compiler versions.^[600-developer-java-3-party-java-maven01.md] For example, source and reporting encoding can be explicitly set to UTF-8 to ensure consistency across different platforms.^[600-developer-java-3-party-java-maven01.md]

Additionally, properties can be used to control specific build behaviors, such as configuring the Java compiler version or modifying how Maven handles missing web XML files during the packaging process.^[600-developer-java-3-party-java-maven01.md]

Example Configuration

The following XML snippet illustrates a standard <properties> block defining encoding, compiler version, and fail-safe settings:^[600-developer-java-3-party-java-maven01.md]

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.compiler.vertion>1.8</java.compiler.vertion>
    <failOnMissingWebXml>false</failOnMissingWebXml>
</properties>

Sources

  • 600-developer-java-3-party-java-maven01.md