Properties and the compiler release

A property is a name and a value kept in the pom, read wherever the name appears between ${ and }. The plugins read a few of them by name, as if they were settings of their own, which is how a pom sets the encoding of the resources and the release of the compiler without configuring a plugin. Most of them are the project's own: a version used in two places belongs in a property, so the two places cannot drift apart.

What a property is

Properties are inherited like everything else in a pom, a child sees the ones of its parent, and the command line can override one with -Dname=value. Maven also fills a set of properties of its own from the project: project.groupId, project.artifactId, project.version, project.basedir and many more. They are not in the pom, and they are readable the same way.

The pom

pom.xml

<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId> <artifactId>props</artifactId> <version>1.4.0</version> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.release>21</maven.compiler.release> <junit.version>5.14.3</junit.version> <app.label>${project.artifactId} ${project.version}</app.label> </properties> <dependencies> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter</artifactId> <version>${junit.version}</version> <scope>test</scope> </dependency> </dependencies> </project>

Four properties and three kinds. project.build.sourceEncoding is a property the plugins read: the resources plugin uses it as the encoding of every resource it copies, and the compiler plugin passes it to javac as -encoding. maven.compiler.release is the same idea for the compiler: it becomes --release 21, which is the JDK's way of saying "compile for Java 21 and check that nothing newer is used". junit.version is the project's own: a value that a dependency reads.

app.label is the interesting one, because its value is made of two other properties. Maven interpolates until nothing is left to replace, so ${project.artifactId} becomes props and ${project.version} becomes 1.4.0.

The values Maven read

mvn -B -q help:evaluate -Dexpression=junit.version -DforceStdout
mvn -B -q help:evaluate -Dexpression=maven.compiler.release -DforceStdout
mvn -B -q help:evaluate -Dexpression=app.label -DforceStdout

5.14.3
21
props 1.4.0

The third line is the proof that a property can hold other properties: the value that was stored was two placeholders, and what came out is the name and the version of the project. help:evaluate resolves what a plugin would resolve, so this is the value the dependency of the pom gets.

The release in a build

A property that no plugin printed would be a claim, so the compiler says what it was given. The project has one class and one test:

src/main/java/com/example/props/Main.java

package com.example.props; public class Main { public static void main(String[] args) { System.out.println("props 1.4.0"); } }

src/test/java/com/example/props/MainTest.java

package com.example.props; import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; class MainTest { @Test void addsNothingUnexpected() { assertEquals(3, 1 + 2); } }

mvn -B test > build.log 2>&1; echo "status: $?"; sed "s#$PWD#<project>#g" build.log

status: 0
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< com.example:props >--------------------------
[INFO] Building props 1.4.0
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- resources:3.4.0:resources (default-resources) @ props ---
[INFO] skip non existing resourceDirectory <project>/src/main/resources
[INFO]
[INFO] --- compiler:3.15.0:compile (default-compile) @ props ---
[INFO] Recompiling the module because of changed source code.
[INFO] Compiling 1 source file with javac [debug release 21] to target/classes
[INFO]
[INFO] --- resources:3.4.0:testResources (default-testResources) @ props ---
[INFO] skip non existing resourceDirectory <project>/src/test/resources
[INFO]
[INFO] --- compiler:3.15.0:testCompile (default-testCompile) @ props ---
[INFO] Recompiling the module because of changed dependency.
[INFO] Compiling 1 source file with javac [debug release 21] to target/test-classes
[INFO]
[INFO] --- surefire:3.5.4:test (default-test) @ props ---
[INFO] Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.example.props.MainTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.086 s -- in com.example.props.MainTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.404 s
[INFO] Finished at: 2026-11-22T08:33:49Z
[INFO] ------------------------------------------------------------------------

javac [debug release 21] is the compiler plugin printing the options it used: debug for the line numbers and the local variable table, release 21 from the property. Without the property the plugin would fall back to source and target at 1.8, which is the default of the plugin and not of the JDK; a class compiled that way still runs on 21, and a class that uses a record does not compile at all.

A property that is not there

An unresolved placeholder is left in the value, and whether that is an error depends on where it is. In a version it is an error, because ${junit.versionn} is not a version:

pom.xml

<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId> <artifactId>props</artifactId> <version>1.4.0</version> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.release>21</maven.compiler.release> <junit.version>5.14.3</junit.version> <app.label>${project.artifactId} ${project.version}</app.label> </properties> <dependencies> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter</artifactId> <version>${junit.versionn}</version> <scope>test</scope> </dependency> </dependencies> </project>

mvn -B test > typo.log 2>&1; echo "status: $?"; sed "s#$PWD#<project>#g" typo.log

status: 1
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] 'dependencies.dependency.version' for org.junit.jupiter:junit-jupiter:jar must be a valid version but is '${junit.versionn}'. @ line 22, column 16
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.example:props:1.4.0 (<project>/pom.xml) has 1 error
[ERROR] 'dependencies.dependency.version' for org.junit.jupiter:junit-jupiter:jar must be a valid version but is '${junit.versionn}'. @ line 22, column 16
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException

The message prints the placeholder as it was written, which is the fastest way to see the typo: the property exists as junit.version and the dependency asks for junit.versionn. A placeholder in a text that Maven does not validate, such as a plugin argument, is passed through as it is, and the tool that reads it reports something less obvious; the resources article shows the one place where that is wanted.

Where to go next

The effective pom shows every property Maven has, the ones of the pom and the ones of the project, in one document. The compiler article goes one step further than the release property and configures the plugin itself.

Article author: Arthur Isaev

Banner image