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
master
Herve Boutemy 2012-05-19 22:42:30 +00:00
parent dd36eda12f
commit bf49e7e7b5
12 changed files with 11 additions and 44 deletions

View File

@ -64,16 +64,4 @@ public @interface Parameter
* @return <code>true</code> if the Mojo should fail when the parameter cannot be injected * @return <code>true</code> if the Mojo should fail when the parameter cannot be injected
*/ */
boolean required() default false; 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 <code>&lt;build&gt;&lt;finalName/&gt;&lt;/build&gt;</code> 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 <code>true</code> if the user should not be allowed to configure the parameter directly
*/
boolean readonly() default false;
} }

View File

@ -42,7 +42,7 @@ public abstract class AbstractFirstMojo
/** /**
* Project directory. * Project directory.
*/ */
@Parameter( defaultValue = "${basedir}", readonly = true ) @Parameter( defaultValue = "${basedir}" )
protected File basedir; protected File basedir;
@Parameter( property = "first.touchFile", defaultValue = "${project.build.directory}/touch.txt", @Parameter( property = "first.touchFile", defaultValue = "${project.build.directory}/touch.txt",

View File

@ -69,7 +69,7 @@ assert parameter.alias.isEmpty()
assert parameter.type.text() == 'java.io.File' assert parameter.type.text() == 'java.io.File'
assert parameter.deprecated.isEmpty() assert parameter.deprecated.isEmpty()
assert parameter.required.text() == 'false' assert parameter.required.text() == 'false'
assert parameter.editable.text() == 'false' assert parameter.editable.text() == 'true'
assert parameter.description.text() == 'Project directory.' assert parameter.description.text() == 'Project directory.'
mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "second"}[0] mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "second"}[0]

View File

@ -42,7 +42,7 @@ public abstract class AbstractFirstMojo
/** /**
* Project directory. * Project directory.
*/ */
@Parameter( defaultValue = "${basedir}", readonly = true ) @Parameter( defaultValue = "${basedir}" )
protected File basedir; protected File basedir;
@Parameter( property = "first.touchFile", defaultValue = "${project.build.directory}/touch.txt", @Parameter( property = "first.touchFile", defaultValue = "${project.build.directory}/touch.txt",

View File

@ -53,7 +53,7 @@ public class FirstMojo
@Component( role = "org.apache.maven.project.MavenProjectHelper" )//, roleHint = "default" @Component( role = "org.apache.maven.project.MavenProjectHelper" )//, roleHint = "default"
private Object projectHelper; private Object projectHelper;
@Parameter( defaultValue = "${project.artifacts}", required = true, readonly = true ) @Parameter( defaultValue = "${project.artifacts}", required = true )
private Set<Artifact> dependencies; private Set<Artifact> dependencies;
public void execute() public void execute()

View File

@ -73,7 +73,7 @@ assert parameter.alias.isEmpty()
assert parameter.type.text() == 'java.io.File' assert parameter.type.text() == 'java.io.File'
assert parameter.deprecated.isEmpty() assert parameter.deprecated.isEmpty()
assert parameter.required.text() == 'false' assert parameter.required.text() == 'false'
assert parameter.editable.text() == 'false' assert parameter.editable.text() == 'true'
assert parameter.description.text() == 'Project directory.' assert parameter.description.text() == 'Project directory.'
mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "second"}[0] mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "second"}[0]

View File

@ -45,7 +45,7 @@ public class FirstMojo
/** /**
* Project directory. * Project directory.
*/ */
@Parameter( defaultValue = "${basedir}", readonly = true ) @Parameter( defaultValue = "${basedir}" )
private File basedir; private File basedir;
@Parameter( property = "first.touchFile", defaultValue = "${project.build.directory}/touch.txt", @Parameter( property = "first.touchFile", defaultValue = "${project.build.directory}/touch.txt",

View File

@ -67,7 +67,7 @@ assert parameter.alias.isEmpty()
assert parameter.type.text() == 'java.io.File' assert parameter.type.text() == 'java.io.File'
assert parameter.deprecated.isEmpty() assert parameter.deprecated.isEmpty()
assert parameter.required.text() == 'false' assert parameter.required.text() == 'false'
assert parameter.editable.text() == 'false' assert parameter.editable.text() == 'true'
assert parameter.description.text() == 'Project directory.' assert parameter.description.text() == 'Project directory.'
mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "second" }[0] mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "second" }[0]

View File

@ -58,7 +58,7 @@ public class DummyReport
/** /**
* The Maven Project. * The Maven Project.
*/ */
@Parameter( property = "project", readonly = true, required = true ) @Parameter( property = "project", required = true )
private MavenProject project; private MavenProject project;

View File

@ -490,7 +490,6 @@ public class JavaAnnotationsMojoDescriptorExtractor
parameter.setDefaultValue( parameterAnnotationContent.defaultValue() ); parameter.setDefaultValue( parameterAnnotationContent.defaultValue() );
parameter.setDeprecated( parameterAnnotationContent.getDeprecated() ); parameter.setDeprecated( parameterAnnotationContent.getDeprecated() );
parameter.setDescription( parameterAnnotationContent.getDescription() ); parameter.setDescription( parameterAnnotationContent.getDescription() );
parameter.setEditable( !parameterAnnotationContent.readonly() );
String property = parameterAnnotationContent.property(); String property = parameterAnnotationContent.property();
if ( StringUtils.contains( property, '$' ) || StringUtils.contains( property, '{' ) if ( StringUtils.contains( property, '$' ) || StringUtils.contains( property, '{' )
|| StringUtils.contains( property, '}' ) ) || StringUtils.contains( property, '}' ) )

View File

@ -40,8 +40,6 @@ public class ParameterAnnotationContent
private boolean required = false; private boolean required = false;
private boolean readonly = false;
private String className; private String className;
public ParameterAnnotationContent( String fieldName, 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, public ParameterAnnotationContent( String fieldName, String alias, String property, String defaultValue,
boolean required, boolean readonly, String className ) boolean required, String className )
{ {
this( fieldName, className ); this( fieldName, className );
this.alias = alias; this.alias = alias;
this.property = property; this.property = property;
this.defaultValue = defaultValue; this.defaultValue = defaultValue;
this.required = required; this.required = required;
this.readonly = readonly;
} }
public String alias() public String alias()
@ -101,16 +98,6 @@ public class ParameterAnnotationContent
this.required = required; this.required = required;
} }
public boolean readonly()
{
return readonly;
}
public void readonly( boolean readonly )
{
this.readonly = readonly;
}
public Class<? extends Annotation> annotationType() public Class<? extends Annotation> annotationType()
{ {
return null; return null;
@ -136,7 +123,6 @@ public class ParameterAnnotationContent
sb.append( ", property='" ).append( property ).append( '\'' ); sb.append( ", property='" ).append( property ).append( '\'' );
sb.append( ", defaultValue='" ).append( defaultValue ).append( '\'' ); sb.append( ", defaultValue='" ).append( defaultValue ).append( '\'' );
sb.append( ", required=" ).append( required ); sb.append( ", required=" ).append( required );
sb.append( ", readonly=" ).append( readonly );
sb.append( '}' ); sb.append( '}' );
return sb.toString(); return sb.toString();
} }
@ -155,10 +141,6 @@ public class ParameterAnnotationContent
ParameterAnnotationContent that = (ParameterAnnotationContent) o; ParameterAnnotationContent that = (ParameterAnnotationContent) o;
if ( readonly != that.readonly )
{
return false;
}
if ( required != that.required ) if ( required != that.required )
{ {
return false; return false;
@ -193,7 +175,6 @@ public class ParameterAnnotationContent
result = 31 * result + ( property != null ? property.hashCode() : 0 ); result = 31 * result + ( property != null ? property.hashCode() : 0 );
result = 31 * result + ( defaultValue != null ? defaultValue.hashCode() : 0 ); result = 31 * result + ( defaultValue != null ? defaultValue.hashCode() : 0 );
result = 31 * result + ( required ? 1 : 0 ); result = 31 * result + ( required ? 1 : 0 );
result = 31 * result + ( readonly ? 1 : 0 );
return result; return result;
} }
} }

View File

@ -83,8 +83,7 @@ public class TestAnnotationsReader
Collection<ParameterAnnotationContent> parameters = mojoAnnotatedClass.getParameters().values(); Collection<ParameterAnnotationContent> parameters = mojoAnnotatedClass.getParameters().values();
Assertions.assertThat( parameters ).isNotNull().isNotEmpty().hasSize( 2 ).contains( Assertions.assertThat( parameters ).isNotNull().isNotEmpty().hasSize( 2 ).contains(
new ParameterAnnotationContent( "bar", null, "thebar", "coolbar", true, false, String.class.getName() ), new ParameterAnnotationContent( "bar", null, "thebar", "coolbar", true, String.class.getName() ),
new ParameterAnnotationContent( "beer", null, "thebeer", "coolbeer", false, false, new ParameterAnnotationContent( "beer", null, "thebeer", "coolbeer", false, String.class.getName() ) );
String.class.getName() ) );
} }
} }