You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sj...@apache.org on 2022/07/04 20:19:50 UTC
[maven-plugin-tools] branch master updated: [MPLUGIN-404] Set JDK prerequisite preferably from release parameter or maven.compiler.release property
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-plugin-tools.git
The following commit(s) were added to refs/heads/master by this push:
new 7580f40a [MPLUGIN-404] Set JDK prerequisite preferably from release parameter or maven.compiler.release property
7580f40a is described below
commit 7580f40ac419740e18d36c1da46bd5dbe66a2262
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Mon Jul 4 14:13:09 2022 +0200
[MPLUGIN-404] Set JDK prerequisite preferably from release parameter or
maven.compiler.release property
---
maven-plugin-plugin/src/it/plugin-info-jdk/pom.xml | 1 +
.../src/it/plugin-info-jdk/propertyRelease/pom.xml | 40 +++++++++++++
.../src/main/resources/META-INF/maven/plugin.xml | 69 ++++++++++++++++++++++
.../src/it/plugin-info-jdk/verify.groovy | 1 +
.../apache/maven/plugin/plugin/PluginReport.java | 10 +++-
5 files changed, 119 insertions(+), 2 deletions(-)
diff --git a/maven-plugin-plugin/src/it/plugin-info-jdk/pom.xml b/maven-plugin-plugin/src/it/plugin-info-jdk/pom.xml
index 081a1e34..051dfd99 100644
--- a/maven-plugin-plugin/src/it/plugin-info-jdk/pom.xml
+++ b/maven-plugin-plugin/src/it/plugin-info-jdk/pom.xml
@@ -42,6 +42,7 @@ under the License.
<modules>
<module>property</module>
+ <module>propertyRelease</module>
<module>pluginManagement</module>
<module>plugin</module>
<module>requirement</module>
diff --git a/maven-plugin-plugin/src/it/plugin-info-jdk/propertyRelease/pom.xml b/maven-plugin-plugin/src/it/plugin-info-jdk/propertyRelease/pom.xml
new file mode 100644
index 00000000..948ecdab
--- /dev/null
+++ b/maven-plugin-plugin/src/it/plugin-info-jdk/propertyRelease/pom.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<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>
+
+ <parent>
+ <groupId>org.apache.maven.its.plugin-info-jdk</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>propertyRelease</artifactId>
+ <name>target bytecode defined by maven.compiler.release property</name>
+ <packaging>maven-plugin</packaging>
+
+ <properties>
+ <maven.compiler.release>8</maven.compiler.release><!-- this should take precedence over maven.compiler.target -->
+ <maven.compiler.source>1.3</maven.compiler.source>
+ <maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
+ </properties>
+</project>
diff --git a/maven-plugin-plugin/src/it/plugin-info-jdk/propertyRelease/src/main/resources/META-INF/maven/plugin.xml b/maven-plugin-plugin/src/it/plugin-info-jdk/propertyRelease/src/main/resources/META-INF/maven/plugin.xml
new file mode 100644
index 00000000..df636a13
--- /dev/null
+++ b/maven-plugin-plugin/src/it/plugin-info-jdk/propertyRelease/src/main/resources/META-INF/maven/plugin.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<plugin>
+ <name>target bytecode defined by maven.compiler.release property</name>
+ <description></description>
+ <groupId>org.apache.maven.its.plugin-info-jdk</groupId>
+ <artifactId>propertyRelease</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <goalPrefix>property</goalPrefix>
+ <isolatedRealm>false</isolatedRealm>
+ <inheritedByDefault>true</inheritedByDefault>
+ <mojos>
+ <mojo>
+ <goal>touch</goal>
+ <description>Goal which touches a timestamp file.</description>
+ <requiresDirectInvocation>false</requiresDirectInvocation>
+ <requiresProject>true</requiresProject>
+ <requiresReports>false</requiresReports>
+ <aggregator>false</aggregator>
+ <requiresOnline>false</requiresOnline>
+ <inheritedByDefault>true</inheritedByDefault>
+ <phase>process-sources</phase>
+ <implementation>org.apache.maven.plugins.issues.plugin.MyMojo</implementation>
+ <language>java</language>
+ <instantiationStrategy>per-lookup</instantiationStrategy>
+ <executionStrategy>once-per-session</executionStrategy>
+ <threadSafe>false</threadSafe>
+ <parameters>
+ <parameter>
+ <name>outputDirectory</name>
+ <type>java.io.File</type>
+ <required>true</required>
+ <editable>true</editable>
+ <description>Location of the file.</description>
+ </parameter>
+ </parameters>
+ <configuration>
+ <outputDirectory implementation="java.io.File">${project.build.directory}</outputDirectory>
+ </configuration>
+ </mojo>
+ </mojos>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <type>jar</type>
+ <version>2.0</version>
+ </dependency>
+ </dependencies>
+</plugin>
\ No newline at end of file
diff --git a/maven-plugin-plugin/src/it/plugin-info-jdk/verify.groovy b/maven-plugin-plugin/src/it/plugin-info-jdk/verify.groovy
index 2b437142..947dded0 100644
--- a/maven-plugin-plugin/src/it/plugin-info-jdk/verify.groovy
+++ b/maven-plugin-plugin/src/it/plugin-info-jdk/verify.groovy
@@ -18,6 +18,7 @@
*/
assert new File( basedir, 'property/target/site/plugin-info.html' ).text.contains( '<td>1.3</td>' )
+assert new File( basedir, 'propertyRelease/target/site/plugin-info.html' ).text.contains( '<td>8</td>' )
assert new File( basedir, 'pluginManagement/target/site/plugin-info.html' ).text.contains( '<td>1.4</td>' )
assert new File( basedir, 'plugin/target/site/plugin-info.html' ).text.contains( '<td>1.5</td>' )
assert new File( basedir, 'requirement/target/site/plugin-info.html' ).text.contains( '<td>1.8</td>' )
diff --git a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java
index 24e4ad4c..08894227 100644
--- a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java
+++ b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java
@@ -770,13 +770,19 @@ public class PluginReport
compiler = getCompilerPlugin( project.getPluginManagement().getPluginsAsMap() );
}
- jdk = getPluginParameter( compiler, "target" );
+ jdk = getPluginParameter( compiler, "release" );
if ( jdk != null )
{
return jdk;
}
- jdk = getPluginParameter( compiler, "release" );
+ jdk = project.getProperties().getProperty( "maven.compiler.release" );
+ if ( jdk != null )
+ {
+ return jdk;
+ }
+
+ jdk = getPluginParameter( compiler, "target" );
if ( jdk != null )
{
return jdk;