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 5b604909 [MPLUGIN-435] Revert MPLUGIN-410. Drop 
@Parameter.implementation and keep it a corner case for now to stick to a more 
efficient API.
5b604909 is described below

commit 5b6049090fefc8590c1aa9beeb34ac1a2e279e98
Author: Romain Manni-Bucau <[email protected]>
AuthorDate: Thu Oct 27 17:17:23 2022 +0200

    [MPLUGIN-435] Revert MPLUGIN-410. Drop @Parameter.implementation and keep 
it a corner case for now to stick to a more efficient API.
---
 .../maven/plugins/annotations/Parameter.java       |  7 ----
 .../verify.groovy                                  | 22 +-----------
 .../JavaAnnotationsMojoDescriptorExtractor.java    |  1 -
 .../datamodel/ParameterAnnotationContent.java      | 40 ++--------------------
 .../src/site/apt/index.apt                         |  1 -
 .../plugin/extractor/annotations/FooInterface.java | 24 -------------
 .../extractor/annotations/FooInterfaceImpl.java    | 24 -------------
 .../plugin/extractor/annotations/FooMojo.java      |  6 ----
 .../annotations/TestAnnotationsReader.java         | 13 ++-----
 9 files changed, 6 insertions(+), 132 deletions(-)

diff --git 
a/maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/Parameter.java
 
b/maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/Parameter.java
index f9eda41e..87887cb7 100644
--- 
a/maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/Parameter.java
+++ 
b/maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/Parameter.java
@@ -72,13 +72,6 @@ public @interface Parameter
      */
     String defaultValue() default "";
 
-    /**
-     * Defines the implementation in the case the parameter type is an 
interface.
-     *
-     * @return the implementation class name
-     */
-    Class<?> implementation() default Object.class;
-
     /**
      * is the parameter required?
      * @return <code>true</code> if the Mojo should fail when the parameter 
cannot be injected
diff --git 
a/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/verify.groovy
 
b/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/verify.groovy
index 90b4b692..6f0f05df 100644
--- 
a/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/verify.groovy
+++ 
b/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/verify.groovy
@@ -28,7 +28,6 @@ def pluginDescriptor = new XmlParser().parse( descriptorFile 
);
 def mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "first"}[0]
 
 assert mojo.goal.text() == 'first'
-assert mojo.implementation.text() == 'org.apache.maven.plugin.coreit.FirstMojo'
 assert mojo.language.text() == 'java'
 assert mojo.description.text() == 'Touches a test file.'
 assert mojo.deprecated.text() == "Don't use!"
@@ -44,11 +43,9 @@ assert mojo.executePhase.text() == 'package'
 assert mojo.executeLifecycle.text() == 'my-lifecycle'
 
 assert mojo.configuration.bar[0].text() == '${thebar}'
-assert mojo.configuration.bar[0].'@implementation' == 'java.lang.String'
 assert mojo.configuration.bar[0].'@default-value' == 'coolbar'
 
 assert mojo.configuration.beer[0].text() == '${thebeer}'
-assert mojo.configuration.beer[0].'@implementation' == 'java.lang.String'
 assert mojo.configuration.beer[0].'@default-value' == 'coolbeer'
 
 assert mojo.requirements.requirement.size() == 2
@@ -61,14 +58,13 @@ assert mojo.requirements.requirement[1].role.text() == 
'org.apache.maven.project
 assert mojo.requirements.requirement[1].'role-hint'.text() == ''
 assert mojo.requirements.requirement[1].'field-name'.text() == 'projectHelper'
 
-assert mojo.parameters.parameter.size() == 7
+assert mojo.parameters.parameter.size() == 6
 
 def parameter = mojo.parameters.parameter.findAll{ it.name.text() == 
"aliasedParam"}[0]
 
 assert parameter.name.text() == 'aliasedParam'
 assert parameter.alias.text() == 'alias'
 assert parameter.type.text() == 'java.lang.String'
-assert parameter.implementation.isEmpty()
 assert parameter.deprecated.text() == 'As of 0.2'
 assert parameter.required.text() == 'false'
 assert parameter.editable.text() == 'true'
@@ -79,7 +75,6 @@ parameter = mojo.parameters.parameter.findAll{ it.name.text() 
== "beer"}[0]
 assert parameter.name.text() == 'beer'
 assert parameter.alias.isEmpty()
 assert parameter.type.text() == 'java.lang.String'
-assert parameter.implementation.isEmpty()
 assert parameter.deprecated.text() == "wine is better"
 assert parameter.required.text() == 'false'
 assert parameter.editable.text() == 'true'
@@ -90,29 +85,16 @@ parameter = mojo.parameters.parameter.findAll{ 
it.name.text() == "bar"}[0]
 assert parameter.name.text() == 'bar'
 assert parameter.alias.isEmpty()
 assert parameter.type.text() == 'java.lang.String'
-assert parameter.implementation.isEmpty()
 assert parameter.deprecated.isEmpty()
 assert parameter.required.text() == 'true'
 assert parameter.editable.text() == 'true'
 assert parameter.description.text() == 'the cool bar to go'
 
-parameter = mojo.parameters.parameter.findAll{ it.name.text() == 
"fooInterface"}[0]
-
-assert parameter.name.text() == 'fooInterface'
-assert parameter.alias.isEmpty()
-assert parameter.type.text() == 
'org.apache.maven.tools.plugin.extractor.annotations.FooInterface'
-assert parameter.implementation.text() == 
'org.apache.maven.tools.plugin.extractor.annotations.FooInterfaceImpl'
-assert parameter.deprecated.isEmpty()
-assert parameter.required.text() == 'false'
-assert parameter.editable.text() == 'true'
-assert parameter.description.text() == 'Interface type as parameter.'
-
 parameter = mojo.parameters.parameter.findAll{ it.name.text() == 
"paramFromSetter"}[0]
 
 assert parameter.name.text() == 'paramFromSetter'
 assert parameter.alias.isEmpty()
 assert parameter.type.text() == 'java.lang.String'
-assert parameter.implementation.isEmpty()
 assert parameter.deprecated.isEmpty()
 assert parameter.required.text() == 'false'
 assert parameter.editable.text() == 'true'
@@ -123,7 +105,6 @@ parameter = mojo.parameters.parameter.findAll{ 
it.name.text() == "paramFromAdd"}
 assert parameter.name.text() == 'paramFromAdd'
 assert parameter.alias.isEmpty()
 assert parameter.type.text() == 'java.lang.String'
-assert parameter.implementation.isEmpty()
 assert parameter.deprecated.isEmpty()
 assert parameter.required.text() == 'false'
 assert parameter.editable.text() == 'true'
@@ -134,7 +115,6 @@ parameter = mojo.parameters.parameter.findAll{ 
it.name.text() == "paramFromSette
 assert parameter.name.text() == 'paramFromSetterDeprecated'
 assert parameter.alias.isEmpty()
 assert parameter.type.text() == 'java.util.List'
-assert parameter.implementation.isEmpty()
 assert parameter.deprecated.text() == 'reason of deprecation'
 assert parameter.required.text() == 'false'
 assert parameter.editable.text() == 'true'
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 e660eb2a..b70b91d3 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
@@ -695,7 +695,6 @@ public class JavaAnnotationsMojoDescriptorExtractor
                 parameter.setName( name );
                 parameter.setAlias( parameterAnnotationContent.alias() );
                 parameter.setDefaultValue( 
parameterAnnotationContent.defaultValue() );
-                parameter.setImplementation( 
parameterAnnotationContent.getImplementationClassName() );
                 parameter.setDeprecated( 
parameterAnnotationContent.getDeprecated() );
                 parameter.setDescription( 
parameterAnnotationContent.getDescription() );
                 parameter.setEditable( !parameterAnnotationContent.readonly() 
);
diff --git 
a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/datamodel/ParameterAnnotationContent.java
 
b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/datamodel/ParameterAnnotationContent.java
index 6ac23be5..82b125dc 100644
--- 
a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/datamodel/ParameterAnnotationContent.java
+++ 
b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/datamodel/ParameterAnnotationContent.java
@@ -20,7 +20,6 @@ package 
org.apache.maven.tools.plugin.extractor.annotations.datamodel;
  */
 
 import org.apache.maven.plugins.annotations.Parameter;
-import org.objectweb.asm.Type;
 
 import java.lang.annotation.Annotation;
 import java.util.List;
@@ -43,8 +42,6 @@ public class ParameterAnnotationContent
 
     private String defaultValue;
 
-    private String implementationClassName;
-
     private boolean required = false;
 
     private boolean readonly = false;
@@ -61,14 +58,13 @@ public class ParameterAnnotationContent
     }
 
     public ParameterAnnotationContent( String fieldName, String alias, String 
property, String defaultValue,
-                                       Class<?> implementation, boolean 
required, boolean readonly, String className,
+                                       boolean required, boolean readonly, 
String className,
                                        List<String> typeParameters )
     {
         this( fieldName, className, typeParameters );
         this.alias = alias;
         this.property = property;
         this.defaultValue = defaultValue;
-        this.implementationClassName = implementation != null ? 
implementation.getName() : null;
         this.required = required;
         this.readonly = readonly;
     }
@@ -117,33 +113,6 @@ public class ParameterAnnotationContent
         this.defaultValue = defaultValue;
     }
 
-    public void implementation( Type implementation )
-    {
-
-        implementationClassName = implementation.getClassName();
-        if ( implementationClassName.equals( Object.class.getName() ) )
-        {
-            // Object is default value for implementation attribute
-            this.implementationClassName = null;
-        }
-    }
-
-    public String getImplementationClassName()
-    {
-        return implementationClassName;
-    }
-
-    @Override
-    public Class<?> implementation()
-    {
-        // needed for implementing @Parameter
-        // we don't have access to project class path,
-        // so loading class is not possible without build additional 
classLoader
-        // we only operate on classes names
-        throw new UnsupportedOperationException(
-            "please use getImplementationClassName instead of implementation 
method" );
-    }
-
     @Override
     public boolean required()
     {
@@ -201,7 +170,6 @@ public class ParameterAnnotationContent
         sb.append( ", alias='" ).append( alias ).append( '\'' );
         sb.append( ", property='" ).append( property ).append( '\'' );
         sb.append( ", defaultValue='" ).append( defaultValue ).append( '\'' );
-        sb.append( ", implementation='" ).append( implementationClassName 
).append( '\'' );
         sb.append( ", required=" ).append( required );
         sb.append( ", readonly=" ).append( readonly );
         sb.append( '}' );
@@ -257,10 +225,6 @@ public class ParameterAnnotationContent
         {
             return false;
         }
-        if ( !Objects.equals( implementationClassName, 
that.implementationClassName ) )
-        {
-            return false;
-        }
 
         return true;
     }
@@ -269,6 +233,6 @@ public class ParameterAnnotationContent
     public int hashCode()
     {
         return Objects.hash( alias, getFieldName(), getClassName(), 
typeParameters, property, defaultValue, required,
-                             readonly, implementationClassName );
+                             readonly );
     }
 }
diff --git a/maven-plugin-tools-annotations/src/site/apt/index.apt 
b/maven-plugin-tools-annotations/src/site/apt/index.apt
index a46c3710..f78b791a 100644
--- a/maven-plugin-tools-annotations/src/site/apt/index.apt
+++ b/maven-plugin-tools-annotations/src/site/apt/index.apt
@@ -86,7 +86,6 @@ public class MyMojo
                 alias = "myAlias",
                 property = "a.property",
                 defaultValue = "an expression, possibly with ${variables}",
-                implementation = "class of implementation in the case the 
parameter type is an interface"
                 readonly = <false|true>,
                 required = <false|true> )
     private String parameter;
diff --git 
a/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/FooInterface.java
 
b/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/FooInterface.java
deleted file mode 100644
index f8932933..00000000
--- 
a/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/FooInterface.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.apache.maven.tools.plugin.extractor.annotations;
-
-/*
- * 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.
- */
-
-public interface FooInterface
-{
-}
diff --git 
a/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/FooInterfaceImpl.java
 
b/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/FooInterfaceImpl.java
deleted file mode 100644
index 99f593b8..00000000
--- 
a/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/FooInterfaceImpl.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.apache.maven.tools.plugin.extractor.annotations;
-
-/*
- * 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.
- */
-
-public class FooInterfaceImpl implements FooInterface
-{
-}
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..e7265d12 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
@@ -45,12 +45,6 @@ public class FooMojo
     @Parameter( property = "thebar", required = true, defaultValue = "coolbar" 
)
     protected String bar;
 
-    /**
-     * Interface type as parameter.
-     */
-    @Parameter( property = "fooInterface", implementation = 
FooInterfaceImpl.class )
-    protected FooInterface fooInterface;
-
     /**
      * beer for non french folks
      * @deprecated wine is better
diff --git 
a/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/TestAnnotationsReader.java
 
b/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/TestAnnotationsReader.java
index dca5896c..0e075c66 100644
--- 
a/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/TestAnnotationsReader.java
+++ 
b/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/TestAnnotationsReader.java
@@ -95,26 +95,19 @@ class TestAnnotationsReader
         Collection<ParameterAnnotationContent> parameters = 
mojoAnnotatedClass.getParameters().values();
         assertThat( parameters ).isNotNull()
             .isNotEmpty()
-            .hasSize( 6 )
+            .hasSize( 5 )
             .containsExactlyInAnyOrder(
-                new ParameterAnnotationContent( "bar", null, "thebar", 
"coolbar", null, true, false,
+                new ParameterAnnotationContent( "bar", null, "thebar", 
"coolbar", true, false,
                                                 String.class.getName(), 
Collections.emptyList() ),
-                new ParameterAnnotationContent( "beer", null, "thebeer", 
"coolbeer", null, false, false,
+                new ParameterAnnotationContent( "beer", null, "thebeer", 
"coolbeer", false, false,
                                                 String.class.getName(), 
Collections.emptyList() ),
-                new ParameterAnnotationContent( "fooInterface", null, 
"fooInterface", null,
-                                                FooInterfaceImpl.class,
-                                                false,
-                                                false, 
FooInterface.class.getName(), Collections.emptyList() ),
                 new ParameterAnnotationContent( "paramFromSetter", null, 
"props.paramFromSetter", null,
-                                                null,
                                                 false,
                                                 false, String.class.getName(), 
Collections.emptyList() ),
                 new ParameterAnnotationContent( "paramFromAdd", null, 
"props.paramFromAdd", null,
-                                                null,
                                                 false,
                                                 false, String.class.getName(), 
Collections.emptyList() ),
                 new ParameterAnnotationContent( "paramFromSetterDeprecated", 
null, "props.paramFromSetterDeprecated", null,
-                                                null,
                                                 false,
                                                 false, List.class.getName(), 
Collections.singletonList("java.lang.String") )
             );

Reply via email to