Skip to content
Latchkey

Maven Compiler "<release> overrides <source>/<target>" - Fix the Conflict

The maven-compiler-plugin was given both a <release> and a <source>/<target> (or a --release plus -source/-target), which javac rejects. --release is a self-contained setting that pins source, target, and the platform API together - it cannot be combined with the older pair.

What this error means

Compilation fails with error: option --release is not allowed with --source (or --target). Both forms are configured, so javac refuses before compiling anything.

mvn output
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile (default-compile)
on project app: Fatal error compiling: error: option --release is not allowed
with --source

Common causes

Both <release> and <source>/<target> set

A <maven.compiler.release> (or plugin <release>) is set alongside <maven.compiler.source>/<target>. javac treats --release and -source/-target as mutually exclusive.

Inherited config collides with local config

A parent POM sets <release> while the child still defines <source>/<target> (or vice versa), so the effective config contains both.

How to fix it

Use <release> alone (preferred for JDK 9+)

Drop source/target and rely solely on release - it also enforces the correct platform API.

pom.xml
<properties>
  <maven.compiler.release>21</maven.compiler.release>
  <!-- remove maven.compiler.source / maven.compiler.target -->
</properties>

Or use source/target alone

If you must keep the legacy pair, remove <release> entirely so they no longer conflict.

pom.xml
<properties>
  <maven.compiler.source>21</maven.compiler.source>
  <maven.compiler.target>21</maven.compiler.target>
  <!-- no maven.compiler.release -->
</properties>

How to prevent it

  • Standardize on <release> for JDK 9+ and drop <source>/<target>.
  • Check inherited parent POM compiler config so child and parent do not mix the two forms.
  • Keep one compiler-version mechanism across the whole reactor.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →