This is an automated email from the ASF dual-hosted git repository.

sjaranowski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-apache-parent.git


The following commit(s) were added to refs/heads/master by this push:
     new 9d07deb  Introduce javaVersion property for maven.compiler.* 
configuration
9d07deb is described below

commit 9d07debba70cc8b93eef083e9124bbda3b56f1bb
Author: Slawomir Jaranowski <[email protected]>
AuthorDate: Thu Nov 13 21:04:31 2025 +0100

    Introduce javaVersion property for maven.compiler.* configuration
---
 docs/src/site/apt/index.apt.vm | 33 +++++++++++++++++++++++++++------
 pom.xml                        | 15 ++++++---------
 2 files changed, 33 insertions(+), 15 deletions(-)

diff --git a/docs/src/site/apt/index.apt.vm b/docs/src/site/apt/index.apt.vm
index 331383f..51054ae 100644
--- a/docs/src/site/apt/index.apt.vm
+++ b/docs/src/site/apt/index.apt.vm
@@ -63,6 +63,29 @@ Apache Software Foundation Parent POM
   ** <<mailingLists>>: The POM sets up generic Apache announcement
      lists. You should override this.
 
+  ** <<javaVersion>>: Java version used for compilation, default value is 
<<$context.get("javaVersion")>>.
+
+    You can override this property in your project POM to set different Java 
version for compilation.
+
+    The <<<javaVersion>>> property is used to set the <<<maven.compiler.*>>> 
properties, so they should not be set directly in your project POM.
+
+    They will be set automatically according to the JDK used for the project 
build:
+
+    *** for JDK 8 and older
+
++------+
+  <maven.compiler.source>\${javaVersion}</maven.compiler.source>
+  <maven.compiler.target>\${javaVersion}</maven.compiler.target>
++------+
+
+    *** for JDK 9 and newer
+
++------+
+  <maven.compiler.release>\${javaVersion}</maven.compiler.release>
++------+
+
+    []
+
  * <<pluginManagement>>: The plugin management section specifies versions
     of a list of plugins. See the {{{./plugin-management.html}Plugin 
Management report}} for
     the complete list with versions. 
@@ -77,11 +100,6 @@ Apache Software Foundation Parent POM
 
    []
 
-  ** The compiler plugin is set target <<Java 
$context.get("maven.compiler.target")>> (<<<maven.compiler.target>>> property)
-     and assume $context.get("project.build.sourceEncoding") source encoding 
(<<<project.build.sourceEncoding>>> property). When being executed
-     with JDK 9 or newer also <<<maven.compiler.release>>> is set to the value 
of property <<<maven.compiler.target>>>.
-     Therefore its value must not start with <<<1.>>> (use for example <<<8>>> 
instead of <<<1.8>>>).
-    
   ** The jar plugin is set to add default specification and implementation 
entries.
     
   ** The resources plugin is set for 
$context.get("project.build.sourceEncoding").
@@ -108,7 +126,7 @@ Apache Software Foundation Parent POM
  
     *** <<<minimalMavenBuildVersion>>> property: default value is <<Maven 
$context.get("minimalMavenBuildVersion")>>
 
-    *** <<<minimalJavaBuildVersion>>> property: default value is <<Java 
$context.get("minimalJavaBuildVersion")>>
+    *** <<<minimalJavaBuildVersion>>> property: default is <<<javaVersion>>> 
property value.
 
     []
 
@@ -191,6 +209,9 @@ Settings Configuration
 
 Notices
 
+ * Since version <<36>>, the <<<javaVersion>>> property has been introduced
+   to define the Java version used for the <<<maven.compiler.*>>> properties.
+
  * Since version <<32>> <<<maven-site-plugin:attach-descriptor>>> was removed 
from <<<plugins>>> section.
 
    Publishing a site descriptor is only needed in project parent poms, child 
projects not need publish it.
diff --git a/pom.xml b/pom.xml
index 436092d..bb46f71 100644
--- a/pom.xml
+++ b/pom.xml
@@ -96,11 +96,10 @@ under the License.
     
<sourceReleaseAssemblyDescriptor>source-release</sourceReleaseAssemblyDescriptor>
     <resourceBundleArtifact>apache-jar-resource-bundle</resourceBundleArtifact>
     <gpg.useagent>true</gpg.useagent>
+    <!-- java version used to to set maven.compiler.* -->
+    <javaVersion>8</javaVersion>
     <minimalMavenBuildVersion>3.6.3</minimalMavenBuildVersion>
-    <minimalJavaBuildVersion>${maven.compiler.target}</minimalJavaBuildVersion>
-    <maven.compiler.source>${maven.compiler.target}</maven.compiler.source>
-    <!-- use version numbers without the "1." prefix (supported since javac 5) 
-->
-    <maven.compiler.target>8</maven.compiler.target>
+    <minimalJavaBuildVersion>${javaVersion}</minimalJavaBuildVersion>
     <!-- for surefire, failsafe and surefire-report -->
     <surefire.version>3.5.4</surefire.version>
     <assembly.tarLongFileMode>posix</assembly.tarLongFileMode>
@@ -520,9 +519,8 @@ under the License.
         <jdk>[,9)</jdk>
       </activation>
       <properties>
-        <maven.compiler.source>${maven.compiler.target}</maven.compiler.source>
-        <maven.compiler.target>8</maven.compiler.target>
-        
<minimalJavaBuildVersion>${maven.compiler.target}</minimalJavaBuildVersion>
+        <maven.compiler.source>${javaVersion}</maven.compiler.source>
+        <maven.compiler.target>${javaVersion}</maven.compiler.target>
       </properties>
     </profile>
     <profile>
@@ -533,8 +531,7 @@ under the License.
       </activation>
       <properties>
         <!-- 
https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-release.html,
 affects m-compiler-p and m-javadoc-p -->
-        <maven.compiler.release>8</maven.compiler.release>
-        
<minimalJavaBuildVersion>${maven.compiler.release}</minimalJavaBuildVersion>
+        <maven.compiler.release>${javaVersion}</maven.compiler.release>
       </properties>
     </profile>
     <profile>

Reply via email to