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

gnodet 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 f054780f Run the v4 mojo (#296)
f054780f is described below

commit f054780fdd03b8702c8e168c6ed71fd5377a874d
Author: Guillaume Nodet <gno...@gmail.com>
AuthorDate: Wed Jun 26 09:43:30 2024 +0200

    Run the v4 mojo (#296)
---
 .../src/it/{v4api => v4api-3x}/invoker.properties        |  1 +
 maven-plugin-plugin/src/it/{v4api => v4api-3x}/pom.xml   |  0
 .../main/java/org/apache/maven/its/v4api/FirstMojo.java  | 16 +++-------------
 .../src/it/{v4api => v4api-3x}/verify.groovy             |  2 --
 .../src/it/{v4api => v4api-4x}/invoker.properties        |  2 ++
 maven-plugin-plugin/src/it/{v4api => v4api-4x}/pom.xml   |  0
 .../main/java/org/apache/maven/its/v4api/FirstMojo.java  | 16 +++-------------
 .../src/it/{v4api => v4api-4x}/verify.groovy             |  2 --
 .../scanner/DefaultMojoAnnotationsScanner.java           | 11 ++++++-----
 .../annotations/scanner/MojoAnnotationsScanner.java      |  2 +-
 .../maven/tools/plugin/ExtendedMojoDescriptor.java       |  8 +++-----
 pom.xml                                                  |  1 +
 12 files changed, 20 insertions(+), 41 deletions(-)

diff --git a/maven-plugin-plugin/src/it/v4api/invoker.properties 
b/maven-plugin-plugin/src/it/v4api-3x/invoker.properties
similarity index 97%
copy from maven-plugin-plugin/src/it/v4api/invoker.properties
copy to maven-plugin-plugin/src/it/v4api-3x/invoker.properties
index e1b69341..1185737b 100644
--- a/maven-plugin-plugin/src/it/v4api/invoker.properties
+++ b/maven-plugin-plugin/src/it/v4api-3x/invoker.properties
@@ -17,3 +17,4 @@
 
 invoker.java.version = 17+
 invoker.goals.1 = clean install
+invoker.maven.version = 3
diff --git a/maven-plugin-plugin/src/it/v4api/pom.xml 
b/maven-plugin-plugin/src/it/v4api-3x/pom.xml
similarity index 100%
copy from maven-plugin-plugin/src/it/v4api/pom.xml
copy to maven-plugin-plugin/src/it/v4api-3x/pom.xml
diff --git 
a/maven-plugin-plugin/src/it/v4api/src/main/java/org/apache/maven/its/v4api/FirstMojo.java
 
b/maven-plugin-plugin/src/it/v4api-3x/src/main/java/org/apache/maven/its/v4api/FirstMojo.java
similarity index 84%
copy from 
maven-plugin-plugin/src/it/v4api/src/main/java/org/apache/maven/its/v4api/FirstMojo.java
copy to 
maven-plugin-plugin/src/it/v4api-3x/src/main/java/org/apache/maven/its/v4api/FirstMojo.java
index abab3cee..d2c3e17e 100644
--- 
a/maven-plugin-plugin/src/it/v4api/src/main/java/org/apache/maven/its/v4api/FirstMojo.java
+++ 
b/maven-plugin-plugin/src/it/v4api-3x/src/main/java/org/apache/maven/its/v4api/FirstMojo.java
@@ -24,14 +24,10 @@ import org.apache.maven.api.MojoExecution;
 import org.apache.maven.api.Project;
 import org.apache.maven.api.Session;
 import org.apache.maven.api.di.Inject;
-import org.apache.maven.api.di.Named;
 import org.apache.maven.api.plugin.Log;
 import org.apache.maven.api.plugin.MojoException;
-import org.apache.maven.api.plugin.annotations.Execute;
 import org.apache.maven.api.plugin.annotations.Mojo;
 import org.apache.maven.api.plugin.annotations.Parameter;
-import org.apache.maven.api.services.ArtifactInstaller;
-import org.apache.maven.api.settings.Settings;
 
 /**
  * Test mojo for the v4 api plugin descriptor generation.
@@ -42,7 +38,6 @@ import org.apache.maven.api.settings.Settings;
  * @since 1.2
  */
 @Mojo(name = "first", defaultPhase = "integration-test")
-@Execute(phase = "generate-sources", lifecycle = "cobertura")
 public class FirstMojo implements org.apache.maven.api.plugin.Mojo {
 
     /**
@@ -71,15 +66,10 @@ public class FirstMojo implements 
org.apache.maven.api.plugin.Mojo {
     @Inject
     private MojoExecution mojo;
 
-    @Inject
-    private Settings settings;
-
     @Inject
     private Log log;
 
-    @Inject
-    @Named("test")
-    private ArtifactInstaller custom;
-
-    public void execute() throws MojoException {}
+    public void execute() throws MojoException {
+        log.info("Executing first");
+    }
 }
diff --git a/maven-plugin-plugin/src/it/v4api/verify.groovy 
b/maven-plugin-plugin/src/it/v4api-3x/verify.groovy
similarity index 97%
copy from maven-plugin-plugin/src/it/v4api/verify.groovy
copy to maven-plugin-plugin/src/it/v4api-3x/verify.groovy
index 878ab95a..c7e767ae 100644
--- a/maven-plugin-plugin/src/it/v4api/verify.groovy
+++ b/maven-plugin-plugin/src/it/v4api-3x/verify.groovy
@@ -37,8 +37,6 @@ assert mojo.projectRequired.text() == 'true'
 assert mojo.onlineRequired.text() == 'false'
 assert mojo.aggregator.text() == 'false'
 assert mojo.phase.text() == 'integration-test'
-assert mojo.executePhase.text() == 'generate-sources'
-assert mojo.executeLifecycle.text() == 'cobertura'
 
 assert mojo.parameters.parameter.size() == 3
 
diff --git a/maven-plugin-plugin/src/it/v4api/invoker.properties 
b/maven-plugin-plugin/src/it/v4api-4x/invoker.properties
similarity index 90%
rename from maven-plugin-plugin/src/it/v4api/invoker.properties
rename to maven-plugin-plugin/src/it/v4api-4x/invoker.properties
index e1b69341..5a80f791 100644
--- a/maven-plugin-plugin/src/it/v4api/invoker.properties
+++ b/maven-plugin-plugin/src/it/v4api-4x/invoker.properties
@@ -17,3 +17,5 @@
 
 invoker.java.version = 17+
 invoker.goals.1 = clean install
+invoker.goals.2 = org.apache.maven.its:v4api:1.0-SNAPSHOT:first
+invoker.maven.version = 4+
diff --git a/maven-plugin-plugin/src/it/v4api/pom.xml 
b/maven-plugin-plugin/src/it/v4api-4x/pom.xml
similarity index 100%
rename from maven-plugin-plugin/src/it/v4api/pom.xml
rename to maven-plugin-plugin/src/it/v4api-4x/pom.xml
diff --git 
a/maven-plugin-plugin/src/it/v4api/src/main/java/org/apache/maven/its/v4api/FirstMojo.java
 
b/maven-plugin-plugin/src/it/v4api-4x/src/main/java/org/apache/maven/its/v4api/FirstMojo.java
similarity index 84%
rename from 
maven-plugin-plugin/src/it/v4api/src/main/java/org/apache/maven/its/v4api/FirstMojo.java
rename to 
maven-plugin-plugin/src/it/v4api-4x/src/main/java/org/apache/maven/its/v4api/FirstMojo.java
index abab3cee..d2c3e17e 100644
--- 
a/maven-plugin-plugin/src/it/v4api/src/main/java/org/apache/maven/its/v4api/FirstMojo.java
+++ 
b/maven-plugin-plugin/src/it/v4api-4x/src/main/java/org/apache/maven/its/v4api/FirstMojo.java
@@ -24,14 +24,10 @@ import org.apache.maven.api.MojoExecution;
 import org.apache.maven.api.Project;
 import org.apache.maven.api.Session;
 import org.apache.maven.api.di.Inject;
-import org.apache.maven.api.di.Named;
 import org.apache.maven.api.plugin.Log;
 import org.apache.maven.api.plugin.MojoException;
-import org.apache.maven.api.plugin.annotations.Execute;
 import org.apache.maven.api.plugin.annotations.Mojo;
 import org.apache.maven.api.plugin.annotations.Parameter;
-import org.apache.maven.api.services.ArtifactInstaller;
-import org.apache.maven.api.settings.Settings;
 
 /**
  * Test mojo for the v4 api plugin descriptor generation.
@@ -42,7 +38,6 @@ import org.apache.maven.api.settings.Settings;
  * @since 1.2
  */
 @Mojo(name = "first", defaultPhase = "integration-test")
-@Execute(phase = "generate-sources", lifecycle = "cobertura")
 public class FirstMojo implements org.apache.maven.api.plugin.Mojo {
 
     /**
@@ -71,15 +66,10 @@ public class FirstMojo implements 
org.apache.maven.api.plugin.Mojo {
     @Inject
     private MojoExecution mojo;
 
-    @Inject
-    private Settings settings;
-
     @Inject
     private Log log;
 
-    @Inject
-    @Named("test")
-    private ArtifactInstaller custom;
-
-    public void execute() throws MojoException {}
+    public void execute() throws MojoException {
+        log.info("Executing first");
+    }
 }
diff --git a/maven-plugin-plugin/src/it/v4api/verify.groovy 
b/maven-plugin-plugin/src/it/v4api-4x/verify.groovy
similarity index 97%
rename from maven-plugin-plugin/src/it/v4api/verify.groovy
rename to maven-plugin-plugin/src/it/v4api-4x/verify.groovy
index 878ab95a..c7e767ae 100644
--- a/maven-plugin-plugin/src/it/v4api/verify.groovy
+++ b/maven-plugin-plugin/src/it/v4api-4x/verify.groovy
@@ -37,8 +37,6 @@ assert mojo.projectRequired.text() == 'true'
 assert mojo.onlineRequired.text() == 'false'
 assert mojo.aggregator.text() == 'false'
 assert mojo.phase.text() == 'integration-test'
-assert mojo.executePhase.text() == 'generate-sources'
-assert mojo.executeLifecycle.text() == 'cobertura'
 
 assert mojo.parameters.parameter.size() == 3
 
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 75989011..6acccd0d 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
@@ -339,13 +339,14 @@ public class DefaultMojoAnnotationsScanner extends 
AbstractLogEnabled implements
             }
 
             // @Component annotations
-            List<MojoFieldVisitor> mojoFieldVisitors =
+            List<MojoFieldVisitor> mojoComponentVisitors =
                     mojoClassVisitor.findFieldWithAnnotation(new 
HashSet<>(Arrays.asList(COMPONENT_V3)));
-            for (MojoFieldVisitor mojoFieldVisitor : mojoFieldVisitors) {
+            for (MojoFieldVisitor mojoComponentVisitor : 
mojoComponentVisitors) {
                 ComponentAnnotationContent componentAnnotationContent =
-                        new 
ComponentAnnotationContent(mojoFieldVisitor.getFieldName());
+                        new 
ComponentAnnotationContent(mojoComponentVisitor.getFieldName());
 
-                Map<String, MojoAnnotationVisitor> annotationVisitorMap = 
mojoFieldVisitor.getAnnotationVisitorMap();
+                Map<String, MojoAnnotationVisitor> annotationVisitorMap =
+                        mojoComponentVisitor.getAnnotationVisitorMap();
                 MojoAnnotationVisitor annotationVisitor = 
annotationVisitorMap.get(COMPONENT_V3);
 
                 if (annotationVisitor != null) {
@@ -362,7 +363,7 @@ public class DefaultMojoAnnotationsScanner extends 
AbstractLogEnabled implements
                     }
 
                     if 
(StringUtils.isEmpty(componentAnnotationContent.getRoleClassName())) {
-                        
componentAnnotationContent.setRoleClassName(mojoFieldVisitor.getClassName());
+                        
componentAnnotationContent.setRoleClassName(mojoComponentVisitor.getClassName());
                     }
                 }
                 mojoAnnotatedClass
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 890f8512..9495f0b9 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
@@ -51,7 +51,7 @@ public interface MojoAnnotationsScanner {
             Component.class.getName(),
             Deprecated.class.getName(),
             V4_API_ANNOTATIONS_PACKAGE + ".Parameter",
-            V4_API_ANNOTATIONS_PACKAGE + ".Component");
+            V4_API_ANNOTATIONS_PACKAGE + ".Resolution");
 
     List<String> METHOD_LEVEL_ANNOTATIONS = Arrays.asList(
             Parameter.class.getName(), Deprecated.class.getName(), 
V4_API_ANNOTATIONS_PACKAGE + ".Parameter");
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 cf227272..7dad0a00 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
@@ -65,10 +65,7 @@ public class ExtendedMojoDescriptor extends MojoDescriptor {
 
     @Override
     public int hashCode() {
-        final int prime = 31;
-        int result = super.hashCode();
-        result = prime * result + Objects.hash(containsXhtmlTextValues);
-        return result;
+        return Objects.hash(containsXhtmlTextValues, v4Api);
     }
 
     @Override
@@ -83,6 +80,7 @@ public class ExtendedMojoDescriptor extends MojoDescriptor {
             return false;
         }
         ExtendedMojoDescriptor other = (ExtendedMojoDescriptor) obj;
-        return containsXhtmlTextValues == other.containsXhtmlTextValues;
+        return Objects.equals(containsXhtmlTextValues, 
other.containsXhtmlTextValues)
+                && Objects.equals(v4Api, other.v4Api);
     }
 }
diff --git a/pom.xml b/pom.xml
index 36979e4d..48d45423 100644
--- a/pom.xml
+++ b/pom.xml
@@ -105,6 +105,7 @@
     <reportingImplVersion>3.2.0</reportingImplVersion>
     <compilerPluginVersion>3.11.0</compilerPluginVersion>
     <javadocPluginVersion>3.5.0</javadocPluginVersion>
+    <version.maven-invoker-plugin>3.7.0</version.maven-invoker-plugin>
     
<project.build.outputTimestamp>2024-05-28T08:15:05Z</project.build.outputTimestamp>
   </properties>
 

Reply via email to