You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2022/10/26 19:58:05 UTC
[maven-plugin-tools] branch m-api created (now 931f8e69)
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a change to branch m-api
in repository https://gitbox.apache.org/repos/asf/maven-plugin-tools.git
at 931f8e69 Use the plexus-utils from maven
This branch includes the following new commits:
new 63a0ba28 Support mojos using the new API
new 7da011e7 Fix enhanced descriptor builder to make it compatible with recent changes
new 371224ff Switch to 4.0.0-alpha-2 release
new 931f8e69 Use the plexus-utils from maven
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[maven-plugin-tools] 02/04: Fix enhanced descriptor builder to make it compatible with recent changes
Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch m-api
in repository https://gitbox.apache.org/repos/asf/maven-plugin-tools.git
commit 7da011e75075ed79065aeaafe63be671c4e25db4
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Fri Oct 21 09:16:43 2022 +0200
Fix enhanced descriptor builder to make it compatible with recent changes
---
.../descriptor/EnhancedPluginDescriptorBuilder.java | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugins/plugin/descriptor/EnhancedPluginDescriptorBuilder.java b/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugins/plugin/descriptor/EnhancedPluginDescriptorBuilder.java
index 8d3361a2..38805eac 100644
--- a/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugins/plugin/descriptor/EnhancedPluginDescriptorBuilder.java
+++ b/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugins/plugin/descriptor/EnhancedPluginDescriptorBuilder.java
@@ -30,6 +30,10 @@ import org.codehaus.plexus.configuration.PlexusConfigurationException;
import org.apache.maven.plugin.plugin.report.PluginReport;
import java.net.URI;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
/**
* Reads enhanced plugin.xml files as generated by
@@ -63,11 +67,14 @@ public class EnhancedPluginDescriptorBuilder extends PluginDescriptorBuilder
PlexusConfiguration[] parameterConfigurations = c.getChild( "parameters" ).getChildren( "parameter" );
+ List<Parameter> parameters = new ArrayList<>( mojoDescriptor.getParameters() );
+ Map<String, Parameter> parameterMap = new LinkedHashMap<>( mojoDescriptor.getParameterMap() );
+
for ( PlexusConfiguration d : parameterConfigurations )
{
String parameterName = d.getChild( "name" ).getValue();
// don't call getParameterMap() to not populate
- Parameter pd = mojoDescriptor.getParameterMap().get( parameterName );
+ Parameter pd = parameterMap.get( parameterName );
if ( requireAddingMissingParameterSinceField )
{
addMissingParameterSinceField( pd, d );
@@ -78,10 +85,14 @@ public class EnhancedPluginDescriptorBuilder extends PluginDescriptorBuilder
String parameterTypeJavadocUrl = configTypeJavadocUrl.getValue();
EnhancedParameterWrapper enhancedParameter = new EnhancedParameterWrapper( pd );
enhancedParameter.setTypeJavadocUrl( URI.create( parameterTypeJavadocUrl ) );
- mojoDescriptor.getParameters().set( mojoDescriptor.getParameters().indexOf( pd ), enhancedParameter );
- mojoDescriptor.getParameterMap().put( parameterName, enhancedParameter );
+ parameters.set( mojoDescriptor.getParameters().indexOf( pd ), enhancedParameter );
+ parameterMap.put( parameterName, enhancedParameter );
}
}
+
+ mojoDescriptor.getParameters().clear();
+ mojoDescriptor.setParameters( parameters );
+
return mojoDescriptor;
}
[maven-plugin-tools] 04/04: Use the plexus-utils from maven
Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch m-api
in repository https://gitbox.apache.org/repos/asf/maven-plugin-tools.git
commit 931f8e69e83a4a96c876d6edeb194f90569ad7dd
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Tue Oct 25 00:25:32 2022 +0200
Use the plexus-utils from maven
---
maven-plugin-plugin/pom.xml | 2 +-
maven-plugin-plugin/src/it/annotation-with-inheritance/pom.xml | 2 +-
maven-plugin-plugin/src/it/java-basic-annotations/pom.xml | 2 +-
maven-plugin-report-plugin/pom.xml | 2 +-
maven-plugin-report-plugin/src/it/fix-maven-since-3.x/pom.xml | 2 +-
maven-plugin-tools-annotations/pom.xml | 2 +-
maven-plugin-tools-api/pom.xml | 2 +-
maven-plugin-tools-generators/pom.xml | 2 +-
maven-plugin-tools-java/pom.xml | 2 +-
maven-script/maven-plugin-tools-ant/pom.xml | 2 +-
maven-script/maven-plugin-tools-model/pom.xml | 2 +-
11 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/maven-plugin-plugin/pom.xml b/maven-plugin-plugin/pom.xml
index 750852ed..b6b222fb 100644
--- a/maven-plugin-plugin/pom.xml
+++ b/maven-plugin-plugin/pom.xml
@@ -136,7 +136,7 @@
<!-- plexus -->
<dependency>
- <groupId>org.codehaus.plexus</groupId>
+ <groupId>org.apache.maven</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
<dependency>
diff --git a/maven-plugin-plugin/src/it/annotation-with-inheritance/pom.xml b/maven-plugin-plugin/src/it/annotation-with-inheritance/pom.xml
index b00ab7d5..ec477fa1 100644
--- a/maven-plugin-plugin/src/it/annotation-with-inheritance/pom.xml
+++ b/maven-plugin-plugin/src/it/annotation-with-inheritance/pom.xml
@@ -58,7 +58,7 @@ under the License.
<scope>compile</scope>
</dependency>
<dependency>
- <groupId>org.codehaus.plexus</groupId>
+ <groupId>org.apache.maven</groupId>
<artifactId>plexus-utils</artifactId>
<version>@plexusUtilsVersion@</version>
</dependency>
diff --git a/maven-plugin-plugin/src/it/java-basic-annotations/pom.xml b/maven-plugin-plugin/src/it/java-basic-annotations/pom.xml
index 19ee2b15..81f204fd 100644
--- a/maven-plugin-plugin/src/it/java-basic-annotations/pom.xml
+++ b/maven-plugin-plugin/src/it/java-basic-annotations/pom.xml
@@ -52,7 +52,7 @@ under the License.
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.codehaus.plexus</groupId>
+ <groupId>org.apache.maven</groupId>
<artifactId>plexus-utils</artifactId>
<version>@plexusUtilsVersion@</version>
</dependency>
diff --git a/maven-plugin-report-plugin/pom.xml b/maven-plugin-report-plugin/pom.xml
index 08dd74ec..f07bfa6c 100644
--- a/maven-plugin-report-plugin/pom.xml
+++ b/maven-plugin-report-plugin/pom.xml
@@ -100,7 +100,7 @@
<!-- plexus -->
<dependency>
- <groupId>org.codehaus.plexus</groupId>
+ <groupId>org.apache.maven</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
diff --git a/maven-plugin-report-plugin/src/it/fix-maven-since-3.x/pom.xml b/maven-plugin-report-plugin/src/it/fix-maven-since-3.x/pom.xml
index 47ea4d51..2dd09879 100644
--- a/maven-plugin-report-plugin/src/it/fix-maven-since-3.x/pom.xml
+++ b/maven-plugin-report-plugin/src/it/fix-maven-since-3.x/pom.xml
@@ -41,7 +41,7 @@
<dependencies>
<dependency>
- <groupId>org.codehaus.plexus</groupId>
+ <groupId>org.apache.maven</groupId>
<artifactId>plexus-utils</artifactId>
<version>@plexusUtilsVersion@</version>
</dependency>
diff --git a/maven-plugin-tools-annotations/pom.xml b/maven-plugin-tools-annotations/pom.xml
index 0019be03..7d4a2130 100644
--- a/maven-plugin-tools-annotations/pom.xml
+++ b/maven-plugin-tools-annotations/pom.xml
@@ -61,7 +61,7 @@
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
- <groupId>org.codehaus.plexus</groupId>
+ <groupId>org.apache.maven</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
<dependency>
diff --git a/maven-plugin-tools-api/pom.xml b/maven-plugin-tools-api/pom.xml
index dd7073df..e272f1bd 100644
--- a/maven-plugin-tools-api/pom.xml
+++ b/maven-plugin-tools-api/pom.xml
@@ -57,7 +57,7 @@
</dependency>
<!-- plexus -->
<dependency>
- <groupId>org.codehaus.plexus</groupId>
+ <groupId>org.apache.maven</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
<!-- for retrieving package-list or element-list of existing javadoc sites -->
diff --git a/maven-plugin-tools-generators/pom.xml b/maven-plugin-tools-generators/pom.xml
index 61ffd71b..7a6a2774 100644
--- a/maven-plugin-tools-generators/pom.xml
+++ b/maven-plugin-tools-generators/pom.xml
@@ -56,7 +56,7 @@
<!-- plexus -->
<dependency>
- <groupId>org.codehaus.plexus</groupId>
+ <groupId>org.apache.maven</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
<dependency>
diff --git a/maven-plugin-tools-java/pom.xml b/maven-plugin-tools-java/pom.xml
index e9018d41..4481d9ec 100644
--- a/maven-plugin-tools-java/pom.xml
+++ b/maven-plugin-tools-java/pom.xml
@@ -52,7 +52,7 @@
<!-- plexus -->
<dependency>
- <groupId>org.codehaus.plexus</groupId>
+ <groupId>org.apache.maven</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
<dependency>
diff --git a/maven-script/maven-plugin-tools-ant/pom.xml b/maven-script/maven-plugin-tools-ant/pom.xml
index b52a47e0..99221874 100644
--- a/maven-script/maven-plugin-tools-ant/pom.xml
+++ b/maven-script/maven-plugin-tools-ant/pom.xml
@@ -51,7 +51,7 @@
<!-- plexus -->
<dependency>
- <groupId>org.codehaus.plexus</groupId>
+ <groupId>org.apache.maven</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
<dependency>
diff --git a/maven-script/maven-plugin-tools-model/pom.xml b/maven-script/maven-plugin-tools-model/pom.xml
index 66e754b8..d0226464 100644
--- a/maven-script/maven-plugin-tools-model/pom.xml
+++ b/maven-script/maven-plugin-tools-model/pom.xml
@@ -41,7 +41,7 @@
</dependency>
<!-- plexus -->
<dependency>
- <groupId>org.codehaus.plexus</groupId>
+ <groupId>org.apache.maven</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
<dependency>
[maven-plugin-tools] 01/04: Support mojos using the new API
Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch m-api
in repository https://gitbox.apache.org/repos/asf/maven-plugin-tools.git
commit 63a0ba28c5ebdeb460b966e782a91c5dd731beca
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Fri Jul 22 11:18:22 2022 +0200
Support mojos using the new API
---
maven-plugin-annotations/pom.xml | 4 +-
maven-plugin-plugin/pom.xml | 7 +-
.../src/main/java/fr/ca/MyMojo.java | 3 +-
maven-plugin-plugin/src/it/settings.xml | 4 +
maven-plugin-report-plugin/pom.xml | 2 +-
.../src/it/fix-maven-since-3.x/pom.xml | 5 ++
.../src/main/java/org/DummyReport.java | 3 +-
.../src/it/plugin-report/pom.xml | 14 ++++
.../src/main/java/org/DummyReport.java | 6 +-
maven-plugin-tools-annotations/pom.xml | 6 +-
.../JavaAnnotationsMojoDescriptorExtractor.java | 38 +++++++++-
.../scanner/DefaultMojoAnnotationsScanner.java | 48 ++++++++++--
.../annotations/scanner/MojoAnnotatedClass.java | 13 ++++
.../scanner/MojoAnnotationsScanner.java | 12 ++-
.../scanner/visitors/MojoClassVisitor.java | 48 +++++++++---
.../plugin/extractor/annotations/FooMojo.java | 3 +-
maven-plugin-tools-api/pom.xml | 2 +-
.../maven/tools/plugin/ExtendedMojoDescriptor.java | 16 +++-
.../maven/tools/plugin/util/stubs/MojoStub.java | 54 +------------
maven-plugin-tools-generators/pom.xml | 2 +-
.../generator/PluginDescriptorFilesGenerator.java | 7 ++
.../plugin/generator/PluginHelpGenerator.java | 6 ++
.../src/main/resources/help-class-source.vm | 88 ++++++++++++++--------
.../generator/AbstractGeneratorTestCase.java | 18 +----
maven-plugin-tools-java/pom.xml | 2 +-
.../javadoc/JavaMojoDescriptorExtractorTest.java | 11 +--
maven-script/maven-plugin-tools-ant/pom.xml | 2 +-
maven-script/maven-plugin-tools-beanshell/pom.xml | 2 +-
maven-script/maven-plugin-tools-model/pom.xml | 2 +-
maven-script/maven-script-ant/pom.xml | 2 +-
.../apache/maven/script/ant/AntMojoWrapper.java | 3 +-
maven-script/maven-script-beanshell/pom.xml | 2 +-
maven-script/pom.xml | 2 +-
pom.xml | 8 +-
34 files changed, 283 insertions(+), 162 deletions(-)
diff --git a/maven-plugin-annotations/pom.xml b/maven-plugin-annotations/pom.xml
index e752eb7d..1d1bcd03 100644
--- a/maven-plugin-annotations/pom.xml
+++ b/maven-plugin-annotations/pom.xml
@@ -21,9 +21,9 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <artifactId>maven-plugin-tools</artifactId>
<groupId>org.apache.maven.plugin-tools</groupId>
- <version>3.7.1-SNAPSHOT</version>
+ <artifactId>maven-plugin-tools</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<artifactId>maven-plugin-annotations</artifactId>
diff --git a/maven-plugin-plugin/pom.xml b/maven-plugin-plugin/pom.xml
index 3f69c50f..750852ed 100644
--- a/maven-plugin-plugin/pom.xml
+++ b/maven-plugin-plugin/pom.xml
@@ -21,9 +21,9 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <artifactId>maven-plugin-tools</artifactId>
<groupId>org.apache.maven.plugin-tools</groupId>
- <version>3.7.1-SNAPSHOT</version>
+ <artifactId>maven-plugin-tools</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.apache.maven.plugins</groupId>
@@ -38,11 +38,12 @@
</description>
<prerequisites>
- <maven>${mavenVersion}</maven>
+ <maven>3.2.5</maven>
</prerequisites>
<properties>
<it.debug>true</it.debug>
+ <javaVersion>8</javaVersion>
</properties>
<dependencies>
diff --git a/maven-plugin-plugin/src/it/mplugin-272_java8/src/main/java/fr/ca/MyMojo.java b/maven-plugin-plugin/src/it/mplugin-272_java8/src/main/java/fr/ca/MyMojo.java
index 07750203..7ba20750 100644
--- a/maven-plugin-plugin/src/it/mplugin-272_java8/src/main/java/fr/ca/MyMojo.java
+++ b/maven-plugin-plugin/src/it/mplugin-272_java8/src/main/java/fr/ca/MyMojo.java
@@ -21,7 +21,6 @@ package fr.ca;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
@@ -31,7 +30,7 @@ import org.apache.maven.plugins.annotations.Mojo;
@Mojo(name="test-plugin",defaultPhase = LifecyclePhase.GENERATE_SOURCES)
public class MyMojo extends AbstractMojo {
@Override
- public void execute() throws MojoExecutionException, MojoFailureException {
+ public void execute() throws MojoExecutionException {
}
}
diff --git a/maven-plugin-plugin/src/it/settings.xml b/maven-plugin-plugin/src/it/settings.xml
index 44480e37..564f5d6e 100644
--- a/maven-plugin-plugin/src/it/settings.xml
+++ b/maven-plugin-plugin/src/it/settings.xml
@@ -39,9 +39,11 @@ under the License.
<url>@localRepositoryUrl@</url>
<releases>
<enabled>true</enabled>
+ <checksumPolicy>ignore</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
+ <checksumPolicy>ignore</checksumPolicy>
</snapshots>
</repository>
</repositories>
@@ -51,9 +53,11 @@ under the License.
<url>@localRepositoryUrl@</url>
<releases>
<enabled>true</enabled>
+ <checksumPolicy>ignore</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
+ <checksumPolicy>ignore</checksumPolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
diff --git a/maven-plugin-report-plugin/pom.xml b/maven-plugin-report-plugin/pom.xml
index 24342904..08dd74ec 100644
--- a/maven-plugin-report-plugin/pom.xml
+++ b/maven-plugin-report-plugin/pom.xml
@@ -23,7 +23,7 @@
<parent>
<artifactId>maven-plugin-tools</artifactId>
<groupId>org.apache.maven.plugin-tools</groupId>
- <version>3.7.1-SNAPSHOT</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.apache.maven.plugins</groupId>
diff --git a/maven-plugin-report-plugin/src/it/fix-maven-since-3.x/pom.xml b/maven-plugin-report-plugin/src/it/fix-maven-since-3.x/pom.xml
index 2f4bf851..47ea4d51 100644
--- a/maven-plugin-report-plugin/src/it/fix-maven-since-3.x/pom.xml
+++ b/maven-plugin-report-plugin/src/it/fix-maven-since-3.x/pom.xml
@@ -34,6 +34,11 @@
<module>javasample-maven-plugin</module>
</modules>
+ <properties>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ </properties>
+
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
diff --git a/maven-plugin-report-plugin/src/it/plugin-report-annotations/src/main/java/org/DummyReport.java b/maven-plugin-report-plugin/src/it/plugin-report-annotations/src/main/java/org/DummyReport.java
index 9eabcd55..24c7a418 100644
--- a/maven-plugin-report-plugin/src/it/plugin-report-annotations/src/main/java/org/DummyReport.java
+++ b/maven-plugin-report-plugin/src/it/plugin-report-annotations/src/main/java/org/DummyReport.java
@@ -195,11 +195,10 @@ public class DummyReport
private final Locale locale;
/**
- * @param project not null
* @param sink not null
* @param locale not null
*/
- public PluginOverviewRenderer( Sink sink, Locale locale )
+ PluginOverviewRenderer( Sink sink, Locale locale )
{
super( sink );
diff --git a/maven-plugin-report-plugin/src/it/plugin-report/pom.xml b/maven-plugin-report-plugin/src/it/plugin-report/pom.xml
index e665568d..ea16542c 100644
--- a/maven-plugin-report-plugin/src/it/plugin-report/pom.xml
+++ b/maven-plugin-report-plugin/src/it/plugin-report/pom.xml
@@ -34,6 +34,8 @@ under the License.
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ <maven.compiler.source>1.8</maven.compiler.source>
</properties>
<dependencies>
@@ -69,6 +71,18 @@ under the License.
<build>
<plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <version>3.0.0</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>extra-enforcer-rules</artifactId>
+ <version>1.5.1</version>
+ </dependency>
+ </dependencies>
+ </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
diff --git a/maven-plugin-report-plugin/src/it/plugin-report/src/main/java/org/DummyReport.java b/maven-plugin-report-plugin/src/it/plugin-report/src/main/java/org/DummyReport.java
index 302314dd..bc0447e5 100644
--- a/maven-plugin-report-plugin/src/it/plugin-report/src/main/java/org/DummyReport.java
+++ b/maven-plugin-report-plugin/src/it/plugin-report/src/main/java/org/DummyReport.java
@@ -120,7 +120,7 @@ public class DummyReport
{
return;
}
- if (skip || skipReport)
+ if ( skip || skipReport )
{
getLog().info( "Maven Plugin Plugin Report generation skipped." );
return;
@@ -181,12 +181,10 @@ public class DummyReport
private final Locale locale;
/**
- * @param project not null
* @param sink not null
* @param locale not null
*/
- public PluginOverviewRenderer( Sink sink,
- Locale locale )
+ PluginOverviewRenderer( Sink sink, Locale locale )
{
super( sink );
diff --git a/maven-plugin-tools-annotations/pom.xml b/maven-plugin-tools-annotations/pom.xml
index 1830d669..0019be03 100644
--- a/maven-plugin-tools-annotations/pom.xml
+++ b/maven-plugin-tools-annotations/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-tools</artifactId>
- <version>3.7.1-SNAPSHOT</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<artifactId>maven-plugin-tools-annotations</artifactId>
@@ -151,6 +151,10 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ </plugin>
</plugins>
</build>
diff --git a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/JavaAnnotationsMojoDescriptorExtractor.java b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/JavaAnnotationsMojoDescriptorExtractor.java
index ac7b4ea9..c368e0e5 100644
--- a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/JavaAnnotationsMojoDescriptorExtractor.java
+++ b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/JavaAnnotationsMojoDescriptorExtractor.java
@@ -416,8 +416,22 @@ public class JavaAnnotationsMojoDescriptorExtractor
}
catch ( NoClassDefFoundError e )
{
- getLogger().warn( "Failed extracting tag '" + tagName + "' from class " + javaClass );
- throw e;
+ if ( e.getMessage().replace( '/', '.' )
+ .contains( MojoAnnotationsScanner.V4_API_PLUGIN_PACKAGE ) )
+ {
+ return null;
+ }
+ String str;
+ try
+ {
+ str = javaClass.getFullyQualifiedName();
+ }
+ catch ( Throwable t )
+ {
+ str = javaClass.getValue();
+ }
+ getLogger().warn( "Failed extracting tag '" + tagName + "' from class " + str );
+ throw (NoClassDefFoundError) new NoClassDefFoundError( e.getMessage() ).initCause( e );
}
}
@@ -476,8 +490,22 @@ public class JavaAnnotationsMojoDescriptorExtractor
}
catch ( NoClassDefFoundError e )
{
- getLogger().warn( "Failed extracting parameters from " + javaClass );
- throw e;
+ if ( e.getMessage().replace( '/', '.' )
+ .contains( MojoAnnotationsScanner.V4_API_PLUGIN_PACKAGE ) )
+ {
+ return new TreeMap<>();
+ }
+ String str;
+ try
+ {
+ str = javaClass.getFullyQualifiedName();
+ }
+ catch ( Throwable t )
+ {
+ str = javaClass.getValue();
+ }
+ getLogger().warn( "Failed extracting parameters from " + str );
+ throw (NoClassDefFoundError) new NoClassDefFoundError( e.getMessage() ).initCause( e );
}
}
@@ -628,6 +656,8 @@ public class JavaAnnotationsMojoDescriptorExtractor
mojoDescriptor.setImplementation( mojoAnnotatedClass.getClassName() );
mojoDescriptor.setLanguage( "java" );
+ mojoDescriptor.setV4Api( mojoAnnotatedClass.isV4Api() );
+
MojoAnnotationContent mojo = mojoAnnotatedClass.getMojo();
mojoDescriptor.setDescription( mojo.getDescription() );
diff --git a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/DefaultMojoAnnotationsScanner.java b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/DefaultMojoAnnotationsScanner.java
index c0e3ed88..081799e1 100644
--- a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/DefaultMojoAnnotationsScanner.java
+++ b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/DefaultMojoAnnotationsScanner.java
@@ -49,7 +49,9 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Arrays;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
@@ -68,6 +70,17 @@ public class DefaultMojoAnnotationsScanner
extends AbstractLogEnabled
implements MojoAnnotationsScanner
{
+ public static final String MVN4_API = "org.apache.maven.api.plugin.annotations.";
+ public static final String MOJO_V4 = MVN4_API + "Mojo";
+ public static final String EXECUTE_V4 = MVN4_API + "Execute";
+ public static final String PARAMETER_V4 = MVN4_API + "Parameter";
+ public static final String COMPONENT_V4 = MVN4_API + "Component";
+
+ public static final String MOJO_V3 = Mojo.class.getName();
+ public static final String EXECUTE_V3 = Execute.class.getName();
+ public static final String PARAMETER_V3 = Parameter.class.getName();
+ public static final String COMPONENT_V3 = Component.class.getName();
+
// classes with a dash must be ignored
private static final Pattern SCANNABLE_CLASS = Pattern.compile( "[^-]+\\.class" );
private static final String EMPTY = "";
@@ -274,7 +287,11 @@ public class DefaultMojoAnnotationsScanner
try
{
// @Mojo annotation
- MojoAnnotationVisitor mojoAnnotationVisitor = mojoClassVisitor.getAnnotationVisitor( Mojo.class );
+ MojoAnnotationVisitor mojoAnnotationVisitor = mojoClassVisitor.getAnnotationVisitor( MOJO_V3 );
+ if ( mojoAnnotationVisitor == null )
+ {
+ mojoAnnotationVisitor = mojoClassVisitor.getAnnotationVisitor( MOJO_V4 );
+ }
if ( mojoAnnotationVisitor != null )
{
MojoAnnotationContent mojoAnnotationContent = new MojoAnnotationContent();
@@ -289,7 +306,11 @@ public class DefaultMojoAnnotationsScanner
}
// @Execute annotation
- mojoAnnotationVisitor = mojoClassVisitor.getAnnotationVisitor( Execute.class );
+ mojoAnnotationVisitor = mojoClassVisitor.getAnnotationVisitor( EXECUTE_V3 );
+ if ( mojoAnnotationVisitor == null )
+ {
+ mojoAnnotationVisitor = mojoClassVisitor.getAnnotationVisitor( EXECUTE_V4 );
+ }
if ( mojoAnnotationVisitor != null )
{
ExecuteAnnotationContent executeAnnotationContent = new ExecuteAnnotationContent();
@@ -298,7 +319,8 @@ public class DefaultMojoAnnotationsScanner
}
// @Parameter annotations
- List<MojoParameterVisitor> mojoParameterVisitors = mojoClassVisitor.findParameterVisitors();
+ List<MojoParameterVisitor> mojoParameterVisitors = mojoClassVisitor.findParameterVisitors(
+ new HashSet<>( Arrays.asList( PARAMETER_V3, PARAMETER_V4 ) ) );
for ( MojoParameterVisitor parameterVisitor : mojoParameterVisitors )
{
ParameterAnnotationContent parameterAnnotationContent =
@@ -306,9 +328,16 @@ public class DefaultMojoAnnotationsScanner
parameterVisitor.getTypeParameters() );
Map<String, MojoAnnotationVisitor> annotationVisitorMap = parameterVisitor.getAnnotationVisitorMap();
- MojoAnnotationVisitor fieldAnnotationVisitor = annotationVisitorMap.get( Parameter.class.getName() );
+ MojoAnnotationVisitor fieldAnnotationVisitor = annotationVisitorMap.get( PARAMETER_V3 );
+ if ( fieldAnnotationVisitor == null )
+ {
+ fieldAnnotationVisitor = annotationVisitorMap.get( PARAMETER_V4 );
+ }
- populateAnnotationContent( parameterAnnotationContent, fieldAnnotationVisitor );
+ if ( fieldAnnotationVisitor != null )
+ {
+ populateAnnotationContent( parameterAnnotationContent, fieldAnnotationVisitor );
+ }
if ( annotationVisitorMap.containsKey( Deprecated.class.getName() ) )
{
@@ -320,14 +349,19 @@ public class DefaultMojoAnnotationsScanner
}
// @Component annotations
- List<MojoFieldVisitor> mojoFieldVisitors = mojoClassVisitor.findFieldWithAnnotation( Component.class );
+ List<MojoFieldVisitor> mojoFieldVisitors = mojoClassVisitor.findFieldWithAnnotation(
+ new HashSet<>( Arrays.asList( COMPONENT_V3, COMPONENT_V4 ) ) );
for ( MojoFieldVisitor mojoFieldVisitor : mojoFieldVisitors )
{
ComponentAnnotationContent componentAnnotationContent =
new ComponentAnnotationContent( mojoFieldVisitor.getFieldName() );
Map<String, MojoAnnotationVisitor> annotationVisitorMap = mojoFieldVisitor.getAnnotationVisitorMap();
- MojoAnnotationVisitor annotationVisitor = annotationVisitorMap.get( Component.class.getName() );
+ MojoAnnotationVisitor annotationVisitor = annotationVisitorMap.get( COMPONENT_V3 );
+ if ( annotationVisitor == null )
+ {
+ annotationVisitor = annotationVisitorMap.get( COMPONENT_V4 );
+ }
if ( annotationVisitor != null )
{
diff --git a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/MojoAnnotatedClass.java b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/MojoAnnotatedClass.java
index ab5f5b15..9c5e6ee1 100644
--- a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/MojoAnnotatedClass.java
+++ b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/MojoAnnotatedClass.java
@@ -57,6 +57,8 @@ public class MojoAnnotatedClass
*/
private Artifact artifact;
+ private boolean v4Api;
+
public MojoAnnotatedClass()
{
// no op
@@ -151,6 +153,16 @@ public class MojoAnnotatedClass
return !( getComponents().isEmpty() && getParameters().isEmpty() && execute == null && mojo == null );
}
+ public boolean isV4Api()
+ {
+ return v4Api;
+ }
+
+ public void setV4Api( boolean v4Api )
+ {
+ this.v4Api = v4Api;
+ }
+
@Override
public String toString()
{
@@ -162,6 +174,7 @@ public class MojoAnnotatedClass
sb.append( ", execute=" ).append( execute );
sb.append( ", parameters=" ).append( parameters );
sb.append( ", components=" ).append( components );
+ sb.append( ", v4api=" ).append( v4Api );
sb.append( '}' );
return sb.toString();
}
diff --git a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/MojoAnnotationsScanner.java b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/MojoAnnotationsScanner.java
index e1eb5f35..afb50b41 100644
--- a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/MojoAnnotationsScanner.java
+++ b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/MojoAnnotationsScanner.java
@@ -37,13 +37,21 @@ public interface MojoAnnotationsScanner
{
String ROLE = MojoAnnotationsScanner.class.getName();
+ String V4_API_PLUGIN_PACKAGE = "org.apache.maven.api.plugin";
+
+ String V4_API_ANNOTATIONS_PACKAGE = V4_API_PLUGIN_PACKAGE + ".annotations";
+
List<String> CLASS_LEVEL_ANNOTATIONS = Arrays.asList( Mojo.class.getName(),
Execute.class.getName(),
- Deprecated.class.getName() );
+ Deprecated.class.getName(),
+ V4_API_ANNOTATIONS_PACKAGE + ".Mojo",
+ V4_API_ANNOTATIONS_PACKAGE + ".Execute" );
List<String> FIELD_LEVEL_ANNOTATIONS = Arrays.asList( Parameter.class.getName(),
Component.class.getName(),
- Deprecated.class.getName() );
+ Deprecated.class.getName(),
+ V4_API_ANNOTATIONS_PACKAGE + ".Parameter",
+ V4_API_ANNOTATIONS_PACKAGE + ".Component" );
List<String> METHOD_LEVEL_ANNOTATIONS = Arrays.asList( Parameter.class.getName(),
Deprecated.class.getName() );
diff --git a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/visitors/MojoClassVisitor.java b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/visitors/MojoClassVisitor.java
index 6267d64f..1cda2255 100644
--- a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/visitors/MojoClassVisitor.java
+++ b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/visitors/MojoClassVisitor.java
@@ -25,6 +25,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -70,28 +71,49 @@ public class MojoClassVisitor
public MojoAnnotationVisitor getAnnotationVisitor( Class<?> annotation )
{
- return annotationVisitorMap.get( annotation.getName() );
+ return getAnnotationVisitor( annotation.getName() );
+ }
+
+ public MojoAnnotationVisitor getAnnotationVisitor( String name )
+ {
+ return annotationVisitorMap.get( name );
}
public List<MojoFieldVisitor> findFieldWithAnnotation( Class<?> annotation )
{
- String annotationClassName = annotation.getName();
+ return findFieldWithAnnotation( Collections.singleton( annotation.getName() ) );
+ }
+
+ public List<MojoFieldVisitor> findFieldWithAnnotation( Set<String> annotationClassNames )
+ {
+ List<MojoFieldVisitor> mojoFieldVisitors = new ArrayList<MojoFieldVisitor>();
+
+ for ( MojoFieldVisitor mojoFieldVisitor : this.fieldVisitors )
+ {
+ Map<String, MojoAnnotationVisitor> filedVisitorMap = mojoFieldVisitor.getAnnotationVisitorMap();
+ if ( filedVisitorMap.keySet().stream().anyMatch( annotationClassNames::contains ) )
+ {
+ mojoFieldVisitors.add( mojoFieldVisitor );
+ }
+ }
- return fieldVisitors.stream()
- .filter( field -> field.getAnnotationVisitorMap().containsKey( annotationClassName ) )
- .collect( Collectors.toList() );
+ return mojoFieldVisitors;
}
public List<MojoParameterVisitor> findParameterVisitors()
+ {
+ return findParameterVisitors( Collections.singleton( Parameter.class.getName() ) );
+ }
+
+ public List<MojoParameterVisitor> findParameterVisitors( Set<String> annotationClassNames )
{
String annotationClassName = Parameter.class.getName();
- return Stream
- .concat(
- findFieldWithAnnotation( Parameter.class ).stream(),
- methodVisitors.stream()
- .filter( method -> method.getAnnotationVisitorMap().containsKey( annotationClassName ) ) )
- .collect( Collectors.toList() );
+ return Stream.concat(
+ findFieldWithAnnotation( Parameter.class ).stream(),
+ methodVisitors.stream()
+ .filter( method -> method.getAnnotationVisitorMap().containsKey( annotationClassName ) ) )
+ .collect( Collectors.toList() );
}
@Override
@@ -113,6 +135,10 @@ public class MojoClassVisitor
{
return null;
}
+ if ( annotationClassName.startsWith( MojoAnnotationsScanner.V4_API_ANNOTATIONS_PACKAGE ) )
+ {
+ mojoAnnotatedClass.setV4Api( true );
+ }
MojoAnnotationVisitor mojoAnnotationVisitor = new MojoAnnotationVisitor( annotationClassName );
annotationVisitorMap.put( annotationClassName, mojoAnnotationVisitor );
return mojoAnnotationVisitor;
diff --git a/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/FooMojo.java b/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/FooMojo.java
index c044d161..87f7fb32 100644
--- a/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/FooMojo.java
+++ b/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/FooMojo.java
@@ -23,7 +23,6 @@ import java.util.List;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Execute;
import org.apache.maven.plugins.annotations.LifecyclePhase;
@@ -106,7 +105,7 @@ public class FooMojo
@Override
public void execute()
- throws MojoExecutionException, MojoFailureException
+ throws MojoExecutionException
{
// nothing
}
diff --git a/maven-plugin-tools-api/pom.xml b/maven-plugin-tools-api/pom.xml
index 523fde74..dd7073df 100644
--- a/maven-plugin-tools-api/pom.xml
+++ b/maven-plugin-tools-api/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-tools</artifactId>
- <version>3.7.1-SNAPSHOT</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<artifactId>maven-plugin-tools-api</artifactId>
diff --git a/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/ExtendedMojoDescriptor.java b/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/ExtendedMojoDescriptor.java
index 7a54c456..7946be09 100644
--- a/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/ExtendedMojoDescriptor.java
+++ b/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/ExtendedMojoDescriptor.java
@@ -35,6 +35,8 @@ public class ExtendedMojoDescriptor
private String requiresDependencyCollection = null;
+ private boolean v4Api = false;
+
public ExtendedMojoDescriptor()
{
this( false );
@@ -72,7 +74,7 @@ public class ExtendedMojoDescriptor
{
this.requiresDependencyCollection = requiresDependencyCollection;
}
-
+
/**
* Indicates if the methods {@link #getDescription()}, {@link #getDeprecated()}, {@link Parameter#getDescription()}
* and {@link Parameter#getDeprecated()} return XHTML values.
@@ -84,4 +86,16 @@ public class ExtendedMojoDescriptor
{
return containsXhtmlTextValues;
}
+
+ @Override
+ public boolean isV4Api()
+ {
+ return v4Api;
+ }
+
+ @Override
+ public void setV4Api( boolean v4Api )
+ {
+ this.v4Api = v4Api;
+ }
}
diff --git a/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/stubs/MojoStub.java b/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/stubs/MojoStub.java
index f271b009..d7f42986 100644
--- a/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/stubs/MojoStub.java
+++ b/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/stubs/MojoStub.java
@@ -23,7 +23,6 @@ import java.util.Map;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.logging.Log;
/**
@@ -32,13 +31,6 @@ import org.apache.maven.plugin.logging.Log;
public class MojoStub
extends AbstractMojo
{
- /** {@inheritDoc} */
- @Override
- public Log getLog()
- {
- return super.getLog();
- }
-
/** {@inheritDoc} */
@Override
public Map getPluginContext()
@@ -46,13 +38,6 @@ public class MojoStub
return super.getPluginContext();
}
- /** {@inheritDoc} */
- @Override
- public void setLog( Log log )
- {
- super.setLog( log );
- }
-
/** {@inheritDoc} */
@Override
public void setPluginContext( Map pluginContext )
@@ -60,47 +45,10 @@ public class MojoStub
super.setPluginContext( pluginContext );
}
- /** {@inheritDoc} */
- @Override
- protected Object clone()
- throws CloneNotSupportedException
- {
- return super.clone();
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean equals( Object obj )
- {
- return super.equals( obj );
- }
-
- /** {@inheritDoc} */
- @Override
- protected void finalize()
- throws Throwable
- {
- super.finalize();
- }
-
- /** {@inheritDoc} */
- @Override
- public int hashCode()
- {
- return super.hashCode();
- }
-
- /** {@inheritDoc} */
- @Override
- public String toString()
- {
- return super.toString();
- }
-
/** {@inheritDoc} */
@Override
public void execute()
- throws MojoExecutionException, MojoFailureException
+ throws MojoExecutionException
{
}
diff --git a/maven-plugin-tools-generators/pom.xml b/maven-plugin-tools-generators/pom.xml
index 3fb4b444..61ffd71b 100644
--- a/maven-plugin-tools-generators/pom.xml
+++ b/maven-plugin-tools-generators/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-tools</artifactId>
- <version>3.7.1-SNAPSHOT</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<artifactId>maven-plugin-tools-generators</artifactId>
diff --git a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorFilesGenerator.java b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorFilesGenerator.java
index cce415f0..8e102420 100644
--- a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorFilesGenerator.java
+++ b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorFilesGenerator.java
@@ -448,6 +448,13 @@ public class PluginDescriptorFilesGenerator
}
GeneratorUtils.element( w, "threadSafe", String.valueOf( extendedMojoDescriptor.isThreadSafe() ) );
+
+ boolean v4Api = extendedMojoDescriptor.isV4Api();
+ if ( v4Api )
+ {
+ GeneratorUtils.element( w, "v4Api", String.valueOf( v4Api ) );
+ }
+
}
// ----------------------------------------------------------------------
diff --git a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java
index 49174e51..4d3a5a3b 100644
--- a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java
+++ b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java
@@ -57,6 +57,7 @@ public class PluginHelpGenerator
private String helpPackageName;
private String goalPrefix;
private MavenProject mavenProject;
+ private boolean useMaven4Api;
private VelocityComponent velocityComponent;
/**
@@ -76,6 +77,10 @@ public class PluginHelpGenerator
{
String helpImplementation = getImplementation();
+ useMaven4Api = mavenProject.getDependencies().stream()
+ .anyMatch( dep -> "org.apache.maven".equals( dep.getGroupId() )
+ && "maven-api-core".equals( dep.getArtifactId() ) );
+
try
{
String sourcePath = helpImplementation.replace( '.', File.separatorChar ) + ".java";
@@ -138,6 +143,7 @@ public class PluginHelpGenerator
// TODO: evaluate prefix from deserialized plugin
context.put( "goalPrefix", goalPrefix );
context.put( "useAnnotations", useAnnotations );
+ context.put( "useMaven4Api", useMaven4Api );
StringWriter stringWriter = new StringWriter();
diff --git a/maven-plugin-tools-generators/src/main/resources/help-class-source.vm b/maven-plugin-tools-generators/src/main/resources/help-class-source.vm
index 06cc56e7..e0d4ec79 100644
--- a/maven-plugin-tools-generators/src/main/resources/help-class-source.vm
+++ b/maven-plugin-tools-generators/src/main/resources/help-class-source.vm
@@ -1,3 +1,10 @@
+#if ( $useMaven4Api )
+#set ( $mojoException = "MojoException" )
+#set ( $logger = "logger" )
+#else
+#set ( $mojoException = "MojoExecutionException" )
+#set ( $logger = "getLog()" )
+#end
## 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
@@ -5,9 +12,9 @@
## 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
@@ -18,12 +25,20 @@
package ${helpPackageName};
#end
+#if( $useMaven4Api )
+import org.apache.maven.api.plugin.MojoException;
+import org.apache.maven.api.plugin.annotations.Component;
+import org.apache.maven.api.plugin.annotations.Mojo;
+import org.apache.maven.api.plugin.annotations.Parameter;
+import org.apache.maven.api.plugin.Log;
+#else
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
#if ( $useAnnotations )
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
#end
+#end
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -43,26 +58,37 @@ import java.util.List;
* Display help information on ${artifactId}.<br>
* Call <code>mvn ${goalPrefix}:help -Ddetail=true -Dgoal=<goal-name></code> to display parameter details.
* @author maven-plugin-tools
-#if ( !$useAnnotations )
+#if ( !$useAnnotations )
* @goal help
* @requiresProject false
* @threadSafe
#end
*/
-#if ( $useAnnotations )
+#if ( $useMaven4Api )
+@Mojo( name = "help", requiresProject = false )
+#elseif ( $useAnnotations )
@Mojo( name = "help", requiresProject = false, threadSafe = true )
#end
public class HelpMojo
+#if ( $useMaven4Api )
+ implements org.apache.maven.api.plugin.Mojo
+#else
extends AbstractMojo
+#end
{
+#if ( $useMaven4Api )
+ @Component
+ private Log logger;
+
+#end
/**
* If <code>true</code>, display all settable properties for each goal.
*
-#if ( !$useAnnotations )
+#if ( !$useAnnotations )
* @parameter property="detail" default-value="false"
#end
*/
-#if ( $useAnnotations )
+#if ( $useAnnotations || $useMaven4Api )
@Parameter( property = "detail", defaultValue = "false" )
#end
private boolean detail;
@@ -70,23 +96,23 @@ public class HelpMojo
/**
* The name of the goal for which to show help. If unspecified, all goals will be displayed.
*
-#if ( !$useAnnotations )
+#if ( !$useAnnotations )
* @parameter property="goal"
#end
*/
-#if ( $useAnnotations )
+#if ( $useAnnotations || $useMaven4Api )
@Parameter( property = "goal" )
-#end
+#end
private java.lang.String goal;
/**
* The maximum length of a display line, should be positive.
*
-#if ( !$useAnnotations )
+#if ( !$useAnnotations )
* @parameter property="lineLength" default-value="80"
#end
*/
-#if ( $useAnnotations )
+#if ( $useAnnotations || $useMaven4Api )
@Parameter( property = "lineLength", defaultValue = "80" )
#end
private int lineLength;
@@ -94,11 +120,11 @@ public class HelpMojo
/**
* The number of spaces per indentation level, should be positive.
*
-#if ( !$useAnnotations )
+#if ( !$useAnnotations )
* @parameter property="indentSize" default-value="2"
#end
*/
-#if ( $useAnnotations )
+#if ( $useAnnotations || $useMaven4Api )
@Parameter( property = "indentSize", defaultValue = "2" )
#end
private int indentSize;
@@ -110,9 +136,9 @@ public class HelpMojo
private static final int DEFAULT_LINE_LENGTH = 80;
private Document build()
- throws MojoExecutionException
+ throws ${mojoException}
{
- getLog().debug( "load plugin-help.xml: " + PLUGIN_HELP_PATH );
+ ${logger}.debug( "load plugin-help.xml: " + PLUGIN_HELP_PATH );
try ( InputStream is = getClass().getResourceAsStream( PLUGIN_HELP_PATH ) )
{
if ( is == null )
@@ -125,15 +151,15 @@ public class HelpMojo
}
catch ( IOException e )
{
- throw new MojoExecutionException( e.getMessage(), e );
+ throw new ${mojoException}( e.getMessage(), e );
}
catch ( ParserConfigurationException e )
{
- throw new MojoExecutionException( e.getMessage(), e );
+ throw new ${mojoException}( e.getMessage(), e );
}
catch ( SAXException e )
{
- throw new MojoExecutionException( e.getMessage(), e );
+ throw new ${mojoException}( e.getMessage(), e );
}
}
@@ -142,16 +168,16 @@ public class HelpMojo
*/
@Override
public void execute()
- throws MojoExecutionException
+ throws ${mojoException}
{
if ( lineLength <= 0 )
{
- getLog().warn( "The parameter 'lineLength' should be positive, using '80' as default." );
+ ${logger}.warn( "The parameter 'lineLength' should be positive, using '80' as default." );
lineLength = DEFAULT_LINE_LENGTH;
}
if ( indentSize <= 0 )
{
- getLog().warn( "The parameter 'indentSize' should be positive, using '2' as default." );
+ ${logger}.warn( "The parameter 'indentSize' should be positive, using '2' as default." );
indentSize = 2;
}
@@ -200,9 +226,9 @@ public class HelpMojo
writeGoal( sb, goalPrefix, (Element) mojo );
}
- if ( getLog().isInfoEnabled() )
+ if ( ${logger}.isInfoEnabled() )
{
- getLog().info( sb.toString() );
+ ${logger}.info( sb.toString() );
}
}
@@ -213,22 +239,22 @@ public class HelpMojo
}
private static String getValue( Node node, String elementName )
- throws MojoExecutionException
+ throws ${mojoException}
{
return getSingleChild( node, elementName ).getTextContent();
}
private static Node getSingleChild( Node node, String elementName )
- throws MojoExecutionException
+ throws ${mojoException}
{
List<Node> namedChild = findNamedChild( node, elementName );
if ( namedChild.isEmpty() )
{
- throw new MojoExecutionException( "Could not find " + elementName + " in plugin-help.xml" );
+ throw new ${mojoException}( "Could not find " + elementName + " in plugin-help.xml" );
}
if ( namedChild.size() > 1 )
{
- throw new MojoExecutionException( "Multiple " + elementName + " in plugin-help.xml" );
+ throw new ${mojoException}( "Multiple " + elementName + " in plugin-help.xml" );
}
return namedChild.get( 0 );
}
@@ -249,7 +275,7 @@ public class HelpMojo
}
private static Node findSingleChild( Node node, String elementName )
- throws MojoExecutionException
+ throws ${mojoException}
{
List<Node> elementsByTagName = findNamedChild( node, elementName );
if ( elementsByTagName.isEmpty() )
@@ -258,13 +284,13 @@ public class HelpMojo
}
if ( elementsByTagName.size() > 1 )
{
- throw new MojoExecutionException( "Multiple " + elementName + "in plugin-help.xml" );
+ throw new ${mojoException}( "Multiple " + elementName + "in plugin-help.xml" );
}
return elementsByTagName.get( 0 );
}
private void writeGoal( StringBuilder sb, String goalPrefix, Element mojo )
- throws MojoExecutionException
+ throws ${mojoException}
{
String mojoGoal = getValue( mojo, "goal" );
Node configurationElement = findSingleChild( mojo, "configuration" );
@@ -304,7 +330,7 @@ public class HelpMojo
}
private void writeParameter( StringBuilder sb, Node parameter, Node configurationElement )
- throws MojoExecutionException
+ throws ${mojoException}
{
String parameterName = getValue( parameter, "name" );
String parameterDescription = getValue( parameter, "description" );
diff --git a/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/AbstractGeneratorTestCase.java b/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/AbstractGeneratorTestCase.java
index c51406d1..f2672437 100644
--- a/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/AbstractGeneratorTestCase.java
+++ b/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/AbstractGeneratorTestCase.java
@@ -101,21 +101,11 @@ public abstract class AbstractGeneratorTestCase
MavenProject mavenProject = new MavenProject();
mavenProject.setGroupId( "foo" );
mavenProject.setArtifactId( "bar" );
- mavenProject.setBuild( new Build()
- {
- @Override
- public String getDirectory()
- {
- return basedir + "/target";
- }
+ Build build = new Build();
+ build.setDirectory( basedir + "/target" );
+ build.setOutputDirectory( basedir + "/target" );
+ mavenProject.setBuild( build );
- @Override
- public String getOutputDirectory()
- {
- return basedir + "/target";
- }
- } );
- extendPluginDescriptor( pluginDescriptor );
generator.execute( destinationDirectory, new DefaultPluginToolsRequest( mavenProject, pluginDescriptor ) );
validate( destinationDirectory );
diff --git a/maven-plugin-tools-java/pom.xml b/maven-plugin-tools-java/pom.xml
index 4fb941b3..e9018d41 100644
--- a/maven-plugin-tools-java/pom.xml
+++ b/maven-plugin-tools-java/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-tools</artifactId>
- <version>3.7.1-SNAPSHOT</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<artifactId>maven-plugin-tools-java</artifactId>
diff --git a/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/javadoc/JavaMojoDescriptorExtractorTest.java b/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/javadoc/JavaMojoDescriptorExtractorTest.java
index 83bd3bf5..97af4b70 100644
--- a/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/javadoc/JavaMojoDescriptorExtractorTest.java
+++ b/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/javadoc/JavaMojoDescriptorExtractorTest.java
@@ -86,14 +86,9 @@ public class JavaMojoDescriptorExtractorTest
model.setArtifactId( "maven-unitTesting-plugin" );
MavenProject project = new MavenProject( model );
- project.setBuild( new Build()
- {
- @Override
- public String getDirectory()
- {
- return new File( "target" ).getAbsolutePath();
- }
- } );
+ Build build = new Build();
+ build.setDirectory( new File( "target" ).getAbsolutePath() );
+ project.setBuild( build );
project.setFile( new File( root, "pom.xml" ) );
project.addCompileSourceRoot( new File( root, directory ).getPath() );
diff --git a/maven-script/maven-plugin-tools-ant/pom.xml b/maven-script/maven-plugin-tools-ant/pom.xml
index f1fc67db..b52a47e0 100644
--- a/maven-script/maven-plugin-tools-ant/pom.xml
+++ b/maven-script/maven-plugin-tools-ant/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-script</artifactId>
- <version>3.7.1-SNAPSHOT</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<artifactId>maven-plugin-tools-ant</artifactId>
diff --git a/maven-script/maven-plugin-tools-beanshell/pom.xml b/maven-script/maven-plugin-tools-beanshell/pom.xml
index 6e40d869..6a958aac 100644
--- a/maven-script/maven-plugin-tools-beanshell/pom.xml
+++ b/maven-script/maven-plugin-tools-beanshell/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-script</artifactId>
- <version>3.7.1-SNAPSHOT</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<artifactId>maven-plugin-tools-beanshell</artifactId>
diff --git a/maven-script/maven-plugin-tools-model/pom.xml b/maven-script/maven-plugin-tools-model/pom.xml
index 4219c22f..66e754b8 100644
--- a/maven-script/maven-plugin-tools-model/pom.xml
+++ b/maven-script/maven-plugin-tools-model/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-script</artifactId>
- <version>3.7.1-SNAPSHOT</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<artifactId>maven-plugin-tools-model</artifactId>
diff --git a/maven-script/maven-script-ant/pom.xml b/maven-script/maven-script-ant/pom.xml
index cbba0e1f..f46d93dc 100644
--- a/maven-script/maven-script-ant/pom.xml
+++ b/maven-script/maven-script-ant/pom.xml
@@ -23,7 +23,7 @@ under the License.
<parent>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-script</artifactId>
- <version>3.7.1-SNAPSHOT</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<artifactId>maven-script-ant</artifactId>
diff --git a/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntMojoWrapper.java b/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntMojoWrapper.java
index 43c8620e..aef75a44 100644
--- a/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntMojoWrapper.java
+++ b/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntMojoWrapper.java
@@ -223,8 +223,7 @@ public class AntMojoWrapper
if ( mavenProject != null && session != null && pathTranslator != null )
{
ExpressionEvaluator exprEvaluator =
- new PluginParameterExpressionEvaluator( session, mojoExecution, pathTranslator, logger,
- mavenProject, mavenProject.getProperties() );
+ new PluginParameterExpressionEvaluator( session, mojoExecution );
PropertyHelper propertyHelper = PropertyHelper.getPropertyHelper( antProject );
propertyHelper.setNext( new AntPropertyHelper( exprEvaluator, mavenProject.getArtifacts(), getLog() ) );
diff --git a/maven-script/maven-script-beanshell/pom.xml b/maven-script/maven-script-beanshell/pom.xml
index 9b7267d0..2d113236 100644
--- a/maven-script/maven-script-beanshell/pom.xml
+++ b/maven-script/maven-script-beanshell/pom.xml
@@ -23,7 +23,7 @@ under the License.
<parent>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-script</artifactId>
- <version>3.7.1-SNAPSHOT</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<artifactId>maven-script-beanshell</artifactId>
diff --git a/maven-script/pom.xml b/maven-script/pom.xml
index 8a73c36c..fc2a5895 100644
--- a/maven-script/pom.xml
+++ b/maven-script/pom.xml
@@ -23,7 +23,7 @@ under the License.
<parent>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-tools</artifactId>
- <version>3.7.1-SNAPSHOT</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<artifactId>maven-script</artifactId>
diff --git a/pom.xml b/pom.xml
index ebcdf48c..258f22a4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,7 +29,7 @@
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-tools</artifactId>
- <version>3.7.1-SNAPSHOT</version>
+ <version>4.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Maven Plugin Tools</name>
@@ -94,7 +94,7 @@
<properties>
<javaVersion>8</javaVersion>
<pluginTestingHarnessVersion>3.3.0</pluginTestingHarnessVersion>
- <mavenVersion>3.2.5</mavenVersion>
+ <mavenVersion>4.0.0-alpha-1-SNAPSHOT</mavenVersion>
<!-- SLF4J version must match the version exported from the mavenVersion,
https://github.com/apache/maven/blob/12a6b3acb947671f09b81f49094c53f426d8cea1/pom.xml#L63 -->
<slf4jVersion>1.7.5</slf4jVersion>
@@ -103,9 +103,10 @@
<asmVersion>9.4</asmVersion>
<doxiaVersion>1.11.1</doxiaVersion>
<doxia-sitetoolsVersion>1.11.1</doxia-sitetoolsVersion>
- <plexusUtilsVersion>3.4.2</plexusUtilsVersion>
+ <plexusUtilsVersion>4.0.0-alpha-1-SNAPSHOT</plexusUtilsVersion>
<reportingApiVersion>3.1.1</reportingApiVersion>
<reportingImplVersion>3.2.0</reportingImplVersion>
+ <surefire.version>3.0.0-M7</surefire.version>
<project.build.outputTimestamp>2022-10-20T07:36:59Z</project.build.outputTimestamp>
</properties>
@@ -366,6 +367,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
+ <version>${surefire.version}</version>
<configuration>
<trimStackTrace>false</trimStackTrace>
</configuration>
[maven-plugin-tools] 03/04: Switch to 4.0.0-alpha-2 release
Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch m-api
in repository https://gitbox.apache.org/repos/asf/maven-plugin-tools.git
commit 371224ffb24ce2319065ebec57fe1b793fa8f5c2
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Mon Oct 24 22:04:55 2022 +0200
Switch to 4.0.0-alpha-2 release
---
pom.xml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/pom.xml b/pom.xml
index 258f22a4..99f01c50 100644
--- a/pom.xml
+++ b/pom.xml
@@ -94,7 +94,7 @@
<properties>
<javaVersion>8</javaVersion>
<pluginTestingHarnessVersion>3.3.0</pluginTestingHarnessVersion>
- <mavenVersion>4.0.0-alpha-1-SNAPSHOT</mavenVersion>
+ <mavenVersion>4.0.0-alpha-2</mavenVersion>
<!-- SLF4J version must match the version exported from the mavenVersion,
https://github.com/apache/maven/blob/12a6b3acb947671f09b81f49094c53f426d8cea1/pom.xml#L63 -->
<slf4jVersion>1.7.5</slf4jVersion>
@@ -103,7 +103,7 @@
<asmVersion>9.4</asmVersion>
<doxiaVersion>1.11.1</doxiaVersion>
<doxia-sitetoolsVersion>1.11.1</doxia-sitetoolsVersion>
- <plexusUtilsVersion>4.0.0-alpha-1-SNAPSHOT</plexusUtilsVersion>
+ <plexusUtilsVersion>4.0.0-alpha-2</plexusUtilsVersion>
<reportingApiVersion>3.1.1</reportingApiVersion>
<reportingImplVersion>3.2.0</reportingImplVersion>
<surefire.version>3.0.0-M7</surefire.version>
@@ -235,7 +235,7 @@
</dependency>
<!-- plexus -->
<dependency>
- <groupId>org.codehaus.plexus</groupId>
+ <groupId>org.apache.maven</groupId>
<artifactId>plexus-utils</artifactId>
<version>${plexusUtilsVersion}</version>
</dependency>