File 0001-Don-t-conflict-source-and-release.patch of Package maven-compiler-plugin
From 58eecab128606f5f79645bf99f3c481598a911eb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fridrich=20=C5=A0trba?= <fridrich.strba@bluewin.ch>
Date: Wed, 2 Jul 2025 11:16:16 +0200
Subject: [PATCH] Don't conflict source and release
---
.../maven/plugin/compiler/AbstractCompilerMojo.java | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java b/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
index 08eeeb2..745122a 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
@@ -1261,9 +1261,16 @@ public abstract class AbstractCompilerMojo implements Mojo {
* the fully formatted option (e.g. "-g:vars,lines") that we provided to it.
*/
final var configuration = new Options(compiler, logger);
- configuration.addIfNonBlank("--source", getSource());
- targetOrReleaseSet = configuration.addIfNonBlank("--target", getTarget());
- targetOrReleaseSet |= configuration.setRelease(getRelease());
+ targetOrReleaseSet = configuration.setRelease(getRelease());
+ if (!targetOrReleaseSet) {
+ configuration.addIfNonBlank("--source", getSource());
+ targetOrReleaseSet = configuration.addIfNonBlank("--target", getTarget());
+ } else if (null != getSource()) {
+ logger.warn("Option --source cannot be used together with --release. Following with --release");
+ } else if (null != getTarget()) {
+ logger.warn("Option --target cannot be used together with --release. Following with --release");
+ }
+
configuration.addIfTrue("--enable-preview", enablePreview);
configuration.addComaSeparated("-proc", proc, List.of("none", "only", "full"), null);
if (annotationProcessors != null) {
--
2.50.1