slachiewicz opened a new issue, #608:
URL: https://github.com/apache/maven-apache-parent/issues/608

   Since 32 (MPOM-264, #479) the `jdk9+` profile sets `maven.compiler.release` 
to `${javaVersion}`, which defaults to 8. maven-compiler-plugin gives `release` 
precedence over `source`/`target` (plexus-compiler emits `--release` whenever 
the value is non-empty), so a child POM that declares `maven.compiler.source` 
and `maven.compiler.target` but no `release`, which is every child written 
against a parent before 32, is compiled for Java 8 on JDK 9+ regardless of its 
own settings.
   
   Observed on flink-connector-parent moving from `org.apache:apache:20` to 39 
with source 11 / target 17:
   
   ```
   [INFO] Compiling 130 source files with javac [debug release 8] to 
target/classes
   [ERROR] TransactionOwnership.java:[74,29] method orElseThrow in class 
java.util.Optional<T> cannot be applied to given types
   ```
   
   The compile error is the good outcome. A child whose sources happen to be 
Java 8 compatible is silently downgraded to bytecode 52 instead.
   
   Each available workaround has a cost:
   
   - Setting `javaVersion` fixes `release`, but it is a single value. A child 
with different source and target levels, or with per-profile targets, cannot 
express that through `--release`.
   - Blanking `maven.compiler.release` restores `-source`/`-target` for javac, 
but maven-javadoc-plugin fails on the empty string (apache/maven-javadoc-plugin 
issue linked below).
   - Overriding the compiler plugin's `release` parameter in the child works, 
but nothing points a user at it.
   
   A POM profile cannot see whether the child set `maven.compiler.source`, so 
the profile itself cannot be made conditional. What would help:
   
   1. Call this out in the release notes and on the parent's site: a child that 
sets `maven.compiler.source`/`target` must also set `javaVersion` or override 
`maven.compiler.release`, or its levels are ignored.
   2. Consider having the parent's enforcer execution fail when 
`maven.compiler.source` or `maven.compiler.target` differs from `javaVersion` 
on JDK 9+, so the mismatch fails loudly instead of downgrading silently.
   
   Context: [FLINK-40630](https://issues.apache.org/jira/browse/FLINK-40630).
   
   *This issue was created with AI assistance.*


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to