From bf49e7e7b537d75b31a7cfa745946f8471d08186 Mon Sep 17 00:00:00 2001 From: Herve Boutemy Date: Sat, 19 May 2012 22:42:30 +0000 Subject: [PATCH] removed readonly parameter to @Parameter annotation since this attribute was only useful when @Component didn't exist git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1340586 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/plugins/annotations/Parameter.java | 12 ----------- .../maven/plugins/AbstractFirstMojo.java | 2 +- .../verify.groovy | 2 +- .../plugin/coreit/AbstractFirstMojo.java | 2 +- .../apache/maven/plugin/coreit/FirstMojo.java | 2 +- .../annotation-with-inheritance/verify.groovy | 2 +- .../apache/maven/plugin/coreit/FirstMojo.java | 2 +- .../it/java-basic-annotations/verify.groovy | 2 +- .../src/main/java/org/DummyReport.java | 2 +- ...avaAnnotationsMojoDescriptorExtractor.java | 1 - .../datamodel/ParameterAnnotationContent.java | 21 +------------------ .../annotations/TestAnnotationsReader.java | 5 ++--- 12 files changed, 11 insertions(+), 44 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 5c57b0f..a3d4f03 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 @@ -64,16 +64,4 @@ public @interface Parameter * @return true if the Mojo should fail when the parameter cannot be injected */ boolean required() default false; - - /** - * Specifies that this parameter cannot be configured directly by the user (as in the case of POM-specified - * configuration). This is useful when you want to force the user to use common POM elements rather than plugin - * configurations, as in the case where you want to use the artifact's final name as a parameter. In this case, you - * want the user to modify <build><finalName/></build> rather than specifying a value - * for finalName directly in the plugin configuration section. It is also useful to ensure that - for example - a - * List-typed parameter which expects items of type Artifact doesn't get a List full of Strings. - * - * @return true if the user should not be allowed to configure the parameter directly - */ - boolean readonly() default false; } diff --git a/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/module-abstract-mojo/src/main/java/org/apache/maven/plugins/AbstractFirstMojo.java b/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/module-abstract-mojo/src/main/java/org/apache/maven/plugins/AbstractFirstMojo.java index 87ad0dc..68563ad 100644 --- a/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/module-abstract-mojo/src/main/java/org/apache/maven/plugins/AbstractFirstMojo.java +++ b/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/module-abstract-mojo/src/main/java/org/apache/maven/plugins/AbstractFirstMojo.java @@ -42,7 +42,7 @@ public abstract class AbstractFirstMojo /** * Project directory. */ - @Parameter( defaultValue = "${basedir}", readonly = true ) + @Parameter( defaultValue = "${basedir}" ) protected File basedir; @Parameter( property = "first.touchFile", defaultValue = "${project.build.directory}/touch.txt", diff --git a/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/verify.groovy b/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/verify.groovy index b76ba5f..d1146ef 100644 --- a/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/verify.groovy +++ b/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/verify.groovy @@ -69,7 +69,7 @@ assert parameter.alias.isEmpty() assert parameter.type.text() == 'java.io.File' assert parameter.deprecated.isEmpty() assert parameter.required.text() == 'false' -assert parameter.editable.text() == 'false' +assert parameter.editable.text() == 'true' assert parameter.description.text() == 'Project directory.' mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "second"}[0] diff --git a/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/AbstractFirstMojo.java b/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/AbstractFirstMojo.java index f0a1263..802417e 100644 --- a/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/AbstractFirstMojo.java +++ b/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/AbstractFirstMojo.java @@ -42,7 +42,7 @@ public abstract class AbstractFirstMojo /** * Project directory. */ - @Parameter( defaultValue = "${basedir}", readonly = true ) + @Parameter( defaultValue = "${basedir}" ) protected File basedir; @Parameter( property = "first.touchFile", defaultValue = "${project.build.directory}/touch.txt", diff --git a/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java b/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java index 15dd982..0c8cc2e 100644 --- a/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java +++ b/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java @@ -53,7 +53,7 @@ public class FirstMojo @Component( role = "org.apache.maven.project.MavenProjectHelper" )//, roleHint = "default" private Object projectHelper; - @Parameter( defaultValue = "${project.artifacts}", required = true, readonly = true ) + @Parameter( defaultValue = "${project.artifacts}", required = true ) private Set dependencies; public void execute() diff --git a/maven-plugin-plugin/src/it/annotation-with-inheritance/verify.groovy b/maven-plugin-plugin/src/it/annotation-with-inheritance/verify.groovy index 53f6191..064ab3a 100644 --- a/maven-plugin-plugin/src/it/annotation-with-inheritance/verify.groovy +++ b/maven-plugin-plugin/src/it/annotation-with-inheritance/verify.groovy @@ -73,7 +73,7 @@ assert parameter.alias.isEmpty() assert parameter.type.text() == 'java.io.File' assert parameter.deprecated.isEmpty() assert parameter.required.text() == 'false' -assert parameter.editable.text() == 'false' +assert parameter.editable.text() == 'true' assert parameter.description.text() == 'Project directory.' mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "second"}[0] diff --git a/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java b/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java index f5814a3..acf097b 100644 --- a/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java +++ b/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java @@ -45,7 +45,7 @@ public class FirstMojo /** * Project directory. */ - @Parameter( defaultValue = "${basedir}", readonly = true ) + @Parameter( defaultValue = "${basedir}" ) private File basedir; @Parameter( property = "first.touchFile", defaultValue = "${project.build.directory}/touch.txt", diff --git a/maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy b/maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy index ff2f74e..ee3e464 100644 --- a/maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy +++ b/maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy @@ -67,7 +67,7 @@ assert parameter.alias.isEmpty() assert parameter.type.text() == 'java.io.File' assert parameter.deprecated.isEmpty() assert parameter.required.text() == 'false' -assert parameter.editable.text() == 'false' +assert parameter.editable.text() == 'true' assert parameter.description.text() == 'Project directory.' mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "second" }[0] diff --git a/maven-plugin-plugin/src/it/plugin-report-annotations/src/main/java/org/DummyReport.java b/maven-plugin-plugin/src/it/plugin-report-annotations/src/main/java/org/DummyReport.java index 9eabcd5..50165fa 100644 --- a/maven-plugin-plugin/src/it/plugin-report-annotations/src/main/java/org/DummyReport.java +++ b/maven-plugin-plugin/src/it/plugin-report-annotations/src/main/java/org/DummyReport.java @@ -58,7 +58,7 @@ public class DummyReport /** * The Maven Project. */ - @Parameter( property = "project", readonly = true, required = true ) + @Parameter( property = "project", required = true ) private MavenProject project; diff --git a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/JavaAnnotationsMojoDescriptorExtractor.java b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/JavaAnnotationsMojoDescriptorExtractor.java index fdc8fb0..878611d 100644 --- a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/JavaAnnotationsMojoDescriptorExtractor.java +++ b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/JavaAnnotationsMojoDescriptorExtractor.java @@ -490,7 +490,6 @@ public class JavaAnnotationsMojoDescriptorExtractor parameter.setDefaultValue( parameterAnnotationContent.defaultValue() ); parameter.setDeprecated( parameterAnnotationContent.getDeprecated() ); parameter.setDescription( parameterAnnotationContent.getDescription() ); - parameter.setEditable( !parameterAnnotationContent.readonly() ); String property = parameterAnnotationContent.property(); if ( StringUtils.contains( property, '$' ) || StringUtils.contains( property, '{' ) || StringUtils.contains( property, '}' ) ) diff --git a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/ParameterAnnotationContent.java b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/ParameterAnnotationContent.java index a095858..e6168f0 100644 --- a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/ParameterAnnotationContent.java +++ b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/ParameterAnnotationContent.java @@ -40,8 +40,6 @@ public class ParameterAnnotationContent private boolean required = false; - private boolean readonly = false; - private String className; public ParameterAnnotationContent( String fieldName, String className ) @@ -51,14 +49,13 @@ public class ParameterAnnotationContent } public ParameterAnnotationContent( String fieldName, String alias, String property, String defaultValue, - boolean required, boolean readonly, String className ) + boolean required, String className ) { this( fieldName, className ); this.alias = alias; this.property = property; this.defaultValue = defaultValue; this.required = required; - this.readonly = readonly; } public String alias() @@ -101,16 +98,6 @@ public class ParameterAnnotationContent this.required = required; } - public boolean readonly() - { - return readonly; - } - - public void readonly( boolean readonly ) - { - this.readonly = readonly; - } - public Class annotationType() { return null; @@ -136,7 +123,6 @@ public class ParameterAnnotationContent sb.append( ", property='" ).append( property ).append( '\'' ); sb.append( ", defaultValue='" ).append( defaultValue ).append( '\'' ); sb.append( ", required=" ).append( required ); - sb.append( ", readonly=" ).append( readonly ); sb.append( '}' ); return sb.toString(); } @@ -155,10 +141,6 @@ public class ParameterAnnotationContent ParameterAnnotationContent that = (ParameterAnnotationContent) o; - if ( readonly != that.readonly ) - { - return false; - } if ( required != that.required ) { return false; @@ -193,7 +175,6 @@ public class ParameterAnnotationContent result = 31 * result + ( property != null ? property.hashCode() : 0 ); result = 31 * result + ( defaultValue != null ? defaultValue.hashCode() : 0 ); result = 31 * result + ( required ? 1 : 0 ); - result = 31 * result + ( readonly ? 1 : 0 ); return result; } } diff --git a/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/annotations/TestAnnotationsReader.java b/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/annotations/TestAnnotationsReader.java index a4738bd..53eef1f 100644 --- a/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/annotations/TestAnnotationsReader.java +++ b/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/annotations/TestAnnotationsReader.java @@ -83,8 +83,7 @@ public class TestAnnotationsReader Collection parameters = mojoAnnotatedClass.getParameters().values(); Assertions.assertThat( parameters ).isNotNull().isNotEmpty().hasSize( 2 ).contains( - new ParameterAnnotationContent( "bar", null, "thebar", "coolbar", true, false, String.class.getName() ), - new ParameterAnnotationContent( "beer", null, "thebeer", "coolbeer", false, false, - String.class.getName() ) ); + new ParameterAnnotationContent( "bar", null, "thebar", "coolbar", true, String.class.getName() ), + new ParameterAnnotationContent( "beer", null, "thebeer", "coolbeer", false, String.class.getName() ) ); } }