Skip to content

Commit 5b60490

Browse files
rmannibucauslawekjaranowski
authored andcommitted
[MPLUGIN-435] Revert MPLUGIN-410. Drop @Parameter.implementation and keep it a corner case for now to stick to a more efficient API.
1 parent ebdb063 commit 5b60490

File tree

9 files changed

+6
-132
lines changed

9 files changed

+6
-132
lines changed

maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/Parameter.java

-7
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,6 @@
7272
*/
7373
String defaultValue() default "";
7474

75-
/**
76-
* Defines the implementation in the case the parameter type is an interface.
77-
*
78-
* @return the implementation class name
79-
*/
80-
Class<?> implementation() default Object.class;
81-
8275
/**
8376
* is the parameter required?
8477
* @return <code>true</code> if the Mojo should fail when the parameter cannot be injected

maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/verify.groovy

+1-21
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ def pluginDescriptor = new XmlParser().parse( descriptorFile );
2828
def mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "first"}[0]
2929

3030
assert mojo.goal.text() == 'first'
31-
assert mojo.implementation.text() == 'org.apache.maven.plugin.coreit.FirstMojo'
3231
assert mojo.language.text() == 'java'
3332
assert mojo.description.text() == 'Touches a test file.'
3433
assert mojo.deprecated.text() == "Don't use!"
@@ -44,11 +43,9 @@ assert mojo.executePhase.text() == 'package'
4443
assert mojo.executeLifecycle.text() == 'my-lifecycle'
4544

4645
assert mojo.configuration.bar[0].text() == '${thebar}'
47-
assert mojo.configuration.bar[0].'@implementation' == 'java.lang.String'
4846
assert mojo.configuration.bar[0].'@default-value' == 'coolbar'
4947

5048
assert mojo.configuration.beer[0].text() == '${thebeer}'
51-
assert mojo.configuration.beer[0].'@implementation' == 'java.lang.String'
5249
assert mojo.configuration.beer[0].'@default-value' == 'coolbeer'
5350

5451
assert mojo.requirements.requirement.size() == 2
@@ -61,14 +58,13 @@ assert mojo.requirements.requirement[1].role.text() == 'org.apache.maven.project
6158
assert mojo.requirements.requirement[1].'role-hint'.text() == ''
6259
assert mojo.requirements.requirement[1].'field-name'.text() == 'projectHelper'
6360

64-
assert mojo.parameters.parameter.size() == 7
61+
assert mojo.parameters.parameter.size() == 6
6562

6663
def parameter = mojo.parameters.parameter.findAll{ it.name.text() == "aliasedParam"}[0]
6764

6865
assert parameter.name.text() == 'aliasedParam'
6966
assert parameter.alias.text() == 'alias'
7067
assert parameter.type.text() == 'java.lang.String'
71-
assert parameter.implementation.isEmpty()
7268
assert parameter.deprecated.text() == 'As of 0.2'
7369
assert parameter.required.text() == 'false'
7470
assert parameter.editable.text() == 'true'
@@ -79,7 +75,6 @@ parameter = mojo.parameters.parameter.findAll{ it.name.text() == "beer"}[0]
7975
assert parameter.name.text() == 'beer'
8076
assert parameter.alias.isEmpty()
8177
assert parameter.type.text() == 'java.lang.String'
82-
assert parameter.implementation.isEmpty()
8378
assert parameter.deprecated.text() == "wine is better"
8479
assert parameter.required.text() == 'false'
8580
assert parameter.editable.text() == 'true'
@@ -90,29 +85,16 @@ parameter = mojo.parameters.parameter.findAll{ it.name.text() == "bar"}[0]
9085
assert parameter.name.text() == 'bar'
9186
assert parameter.alias.isEmpty()
9287
assert parameter.type.text() == 'java.lang.String'
93-
assert parameter.implementation.isEmpty()
9488
assert parameter.deprecated.isEmpty()
9589
assert parameter.required.text() == 'true'
9690
assert parameter.editable.text() == 'true'
9791
assert parameter.description.text() == 'the cool bar to go'
9892

99-
parameter = mojo.parameters.parameter.findAll{ it.name.text() == "fooInterface"}[0]
100-
101-
assert parameter.name.text() == 'fooInterface'
102-
assert parameter.alias.isEmpty()
103-
assert parameter.type.text() == 'org.apache.maven.tools.plugin.extractor.annotations.FooInterface'
104-
assert parameter.implementation.text() == 'org.apache.maven.tools.plugin.extractor.annotations.FooInterfaceImpl'
105-
assert parameter.deprecated.isEmpty()
106-
assert parameter.required.text() == 'false'
107-
assert parameter.editable.text() == 'true'
108-
assert parameter.description.text() == 'Interface type as parameter.'
109-
11093
parameter = mojo.parameters.parameter.findAll{ it.name.text() == "paramFromSetter"}[0]
11194

11295
assert parameter.name.text() == 'paramFromSetter'
11396
assert parameter.alias.isEmpty()
11497
assert parameter.type.text() == 'java.lang.String'
115-
assert parameter.implementation.isEmpty()
11698
assert parameter.deprecated.isEmpty()
11799
assert parameter.required.text() == 'false'
118100
assert parameter.editable.text() == 'true'
@@ -123,7 +105,6 @@ parameter = mojo.parameters.parameter.findAll{ it.name.text() == "paramFromAdd"}
123105
assert parameter.name.text() == 'paramFromAdd'
124106
assert parameter.alias.isEmpty()
125107
assert parameter.type.text() == 'java.lang.String'
126-
assert parameter.implementation.isEmpty()
127108
assert parameter.deprecated.isEmpty()
128109
assert parameter.required.text() == 'false'
129110
assert parameter.editable.text() == 'true'
@@ -134,7 +115,6 @@ parameter = mojo.parameters.parameter.findAll{ it.name.text() == "paramFromSette
134115
assert parameter.name.text() == 'paramFromSetterDeprecated'
135116
assert parameter.alias.isEmpty()
136117
assert parameter.type.text() == 'java.util.List'
137-
assert parameter.implementation.isEmpty()
138118
assert parameter.deprecated.text() == 'reason of deprecation'
139119
assert parameter.required.text() == 'false'
140120
assert parameter.editable.text() == 'true'

maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/JavaAnnotationsMojoDescriptorExtractor.java

-1
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,6 @@ private List<MojoDescriptor> toMojoDescriptors( Map<String, MojoAnnotatedClass>
695695
parameter.setName( name );
696696
parameter.setAlias( parameterAnnotationContent.alias() );
697697
parameter.setDefaultValue( parameterAnnotationContent.defaultValue() );
698-
parameter.setImplementation( parameterAnnotationContent.getImplementationClassName() );
699698
parameter.setDeprecated( parameterAnnotationContent.getDeprecated() );
700699
parameter.setDescription( parameterAnnotationContent.getDescription() );
701700
parameter.setEditable( !parameterAnnotationContent.readonly() );

maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/datamodel/ParameterAnnotationContent.java

+2-38
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
*/
2121

2222
import org.apache.maven.plugins.annotations.Parameter;
23-
import org.objectweb.asm.Type;
2423

2524
import java.lang.annotation.Annotation;
2625
import java.util.List;
@@ -43,8 +42,6 @@ public class ParameterAnnotationContent
4342

4443
private String defaultValue;
4544

46-
private String implementationClassName;
47-
4845
private boolean required = false;
4946

5047
private boolean readonly = false;
@@ -61,14 +58,13 @@ public ParameterAnnotationContent( String fieldName, String className, List<Stri
6158
}
6259

6360
public ParameterAnnotationContent( String fieldName, String alias, String property, String defaultValue,
64-
Class<?> implementation, boolean required, boolean readonly, String className,
61+
boolean required, boolean readonly, String className,
6562
List<String> typeParameters )
6663
{
6764
this( fieldName, className, typeParameters );
6865
this.alias = alias;
6966
this.property = property;
7067
this.defaultValue = defaultValue;
71-
this.implementationClassName = implementation != null ? implementation.getName() : null;
7268
this.required = required;
7369
this.readonly = readonly;
7470
}
@@ -117,33 +113,6 @@ public void defaultValue( String defaultValue )
117113
this.defaultValue = defaultValue;
118114
}
119115

120-
public void implementation( Type implementation )
121-
{
122-
123-
implementationClassName = implementation.getClassName();
124-
if ( implementationClassName.equals( Object.class.getName() ) )
125-
{
126-
// Object is default value for implementation attribute
127-
this.implementationClassName = null;
128-
}
129-
}
130-
131-
public String getImplementationClassName()
132-
{
133-
return implementationClassName;
134-
}
135-
136-
@Override
137-
public Class<?> implementation()
138-
{
139-
// needed for implementing @Parameter
140-
// we don't have access to project class path,
141-
// so loading class is not possible without build additional classLoader
142-
// we only operate on classes names
143-
throw new UnsupportedOperationException(
144-
"please use getImplementationClassName instead of implementation method" );
145-
}
146-
147116
@Override
148117
public boolean required()
149118
{
@@ -201,7 +170,6 @@ public String toString()
201170
sb.append( ", alias='" ).append( alias ).append( '\'' );
202171
sb.append( ", property='" ).append( property ).append( '\'' );
203172
sb.append( ", defaultValue='" ).append( defaultValue ).append( '\'' );
204-
sb.append( ", implementation='" ).append( implementationClassName ).append( '\'' );
205173
sb.append( ", required=" ).append( required );
206174
sb.append( ", readonly=" ).append( readonly );
207175
sb.append( '}' );
@@ -257,10 +225,6 @@ public boolean equals( Object o )
257225
{
258226
return false;
259227
}
260-
if ( !Objects.equals( implementationClassName, that.implementationClassName ) )
261-
{
262-
return false;
263-
}
264228

265229
return true;
266230
}
@@ -269,6 +233,6 @@ public boolean equals( Object o )
269233
public int hashCode()
270234
{
271235
return Objects.hash( alias, getFieldName(), getClassName(), typeParameters, property, defaultValue, required,
272-
readonly, implementationClassName );
236+
readonly );
273237
}
274238
}

maven-plugin-tools-annotations/src/site/apt/index.apt

-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ public class MyMojo
8686
alias = "myAlias",
8787
property = "a.property",
8888
defaultValue = "an expression, possibly with ${variables}",
89-
implementation = "class of implementation in the case the parameter type is an interface"
9089
readonly = <false|true>,
9190
required = <false|true> )
9291
private String parameter;

maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/FooInterface.java

-24
This file was deleted.

maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/FooInterfaceImpl.java

-24
This file was deleted.

maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/FooMojo.java

-6
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@ public class FooMojo
4545
@Parameter( property = "thebar", required = true, defaultValue = "coolbar" )
4646
protected String bar;
4747

48-
/**
49-
* Interface type as parameter.
50-
*/
51-
@Parameter( property = "fooInterface", implementation = FooInterfaceImpl.class )
52-
protected FooInterface fooInterface;
53-
5448
/**
5549
* beer for non french folks
5650
* @deprecated wine is better

maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/TestAnnotationsReader.java

+3-10
Original file line numberDiff line numberDiff line change
@@ -95,26 +95,19 @@ void testReadMojoClass()
9595
Collection<ParameterAnnotationContent> parameters = mojoAnnotatedClass.getParameters().values();
9696
assertThat( parameters ).isNotNull()
9797
.isNotEmpty()
98-
.hasSize( 6 )
98+
.hasSize( 5 )
9999
.containsExactlyInAnyOrder(
100-
new ParameterAnnotationContent( "bar", null, "thebar", "coolbar", null, true, false,
100+
new ParameterAnnotationContent( "bar", null, "thebar", "coolbar", true, false,
101101
String.class.getName(), Collections.emptyList() ),
102-
new ParameterAnnotationContent( "beer", null, "thebeer", "coolbeer", null, false, false,
102+
new ParameterAnnotationContent( "beer", null, "thebeer", "coolbeer", false, false,
103103
String.class.getName(), Collections.emptyList() ),
104-
new ParameterAnnotationContent( "fooInterface", null, "fooInterface", null,
105-
FooInterfaceImpl.class,
106-
false,
107-
false, FooInterface.class.getName(), Collections.emptyList() ),
108104
new ParameterAnnotationContent( "paramFromSetter", null, "props.paramFromSetter", null,
109-
null,
110105
false,
111106
false, String.class.getName(), Collections.emptyList() ),
112107
new ParameterAnnotationContent( "paramFromAdd", null, "props.paramFromAdd", null,
113-
null,
114108
false,
115109
false, String.class.getName(), Collections.emptyList() ),
116110
new ParameterAnnotationContent( "paramFromSetterDeprecated", null, "props.paramFromSetterDeprecated", null,
117-
null,
118111
false,
119112
false, List.class.getName(), Collections.singletonList("java.lang.String") )
120113
);

0 commit comments

Comments
 (0)