Author: hboutemy Date: Mon May 28 10:03:40 2012 New Revision: 1343181 URL: http://svn.apache.org/viewvc?rev=1343181&view=rev Log: extended IT for annotations
Added: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/Maximal.java (with props) maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/Minimal.java (with props) Removed: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/SecondMojo.java Modified: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy Added: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/Maximal.java URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/Maximal.java?rev=1343181&view=auto ============================================================================== --- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/Maximal.java (added) +++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/Maximal.java Mon May 28 10:03:40 2012 @@ -0,0 +1,76 @@ +package org.apache.maven.plugin.coreit; + +/* + * 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. + */ + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugins.annotations.Component; +import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.plugins.annotations.Execute; +import org.apache.maven.plugins.annotations.InstanciationStrategy; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProjectHelper; + +/** + * Checks maximum annotations with non-default values. + * + * @since since-text + * @deprecated deprecated-text + */ +@Mojo( name = "maximal", + aggregator = true, + configurator = "configurator-hint", + requiresDependencyResolution = ResolutionScope.TEST, + requiresDependencyCollection = ResolutionScope.COMPILE, + defaultPhase = LifecyclePhase.PACKAGE, + executionStrategy = "always", + instantiationStrategy = InstanciationStrategy.SINGLETON, + inheritByDefault = false, + requiresDirectInvocation = true, + requiresOnline = true, + requiresProject = false, + requiresReports = true, + threadSafe = true ) +@Execute( phase = LifecyclePhase.COMPILE ) +public class Maximal + extends AbstractMojo +{ + /** + * Parameter description. + * + * @since since-text + * @deprecated deprecated-text + */ + @Parameter( alias = "myAlias", + property = "aProperty", + defaultValue = "${anExpression}", + readonly = true, + required = true ) + private String param; + + @Component( role = MavenProjectHelper.class, hint = "test" ) + private Object projectHelper; + + public void execute() + { + } + +} Propchange: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/Maximal.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/Maximal.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Propchange: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/Maximal.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/Minimal.java URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/Minimal.java?rev=1343181&view=auto ============================================================================== --- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/Minimal.java (added) +++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/Minimal.java Mon May 28 10:03:40 2012 @@ -0,0 +1,43 @@ +package org.apache.maven.plugin.coreit; + +/* + * 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. + */ + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugins.annotations.Component; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProjectHelper; + +// minimum annotations => default values +@Mojo( name = "minimal" ) +public class Minimal + extends AbstractMojo +{ + @Parameter + private String param; + + @Component + private MavenProjectHelper projectHelper; + + public void execute() + { + } + +} Propchange: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/Minimal.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/Minimal.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Propchange: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/Minimal.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy?rev=1343181&r1=1343180&r2=1343181&view=diff ============================================================================== --- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy (original) +++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy Mon May 28 10:03:40 2012 @@ -132,9 +132,76 @@ assert parameter.required.text() == 'tru assert parameter.editable.text() == 'true' assert parameter.description.text() == '' -mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "second" }[0] +// check default values +mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "minimal"}[0] -assert mojo.requiresDependencyCollection.text() == 'compile' +assert mojo.goal.text() == 'minimal' +assert mojo.implementation.text() == 'org.apache.maven.plugin.coreit.Minimal' +assert mojo.language.text() == 'java' +assert mojo.description.text() == '' +assert mojo.deprecated.text() == '' +assert mojo.requiresDependencyResolution.text() == '' +assert mojo.requiresDependencyCollection.text() == '' +assert mojo.requiresProject.text() == 'true' +assert mojo.requiresOnline.text() == 'false' +assert mojo.requiresDirectInvocation.text() == 'false' +assert mojo.requiresReports.text() == 'false' +assert mojo.aggregator.text() == 'false' +assert mojo.threadSafe.text() == 'false' +assert mojo.phase.text() == '' +assert mojo.executePhase.text() == '' +assert mojo.executeLifecycle.text() == '' +assert mojo.executionStrategy.text() == 'once-per-session' +assert mojo.inheritedByDefault.text() == 'true' +assert mojo.instantiationStrategy.text() == 'per-lookup' + +parameter = mojo.parameters.parameter.findAll{ it.name.text() == "param" }[0] +assert parameter.name.text() == 'param' +assert parameter.alias.text() == '' +assert parameter.type.text() == 'java.lang.String' +assert parameter.deprecated.text() == '' +assert parameter.required.text() == 'false' +assert parameter.editable.text() == 'true' +assert parameter.description.text() == '' + +def requirement = mojo.requirements.requirement.findAll{ it.'field-name'.text() == "projectHelper" }[0] +assert requirement.role.text() == 'org.apache.maven.project.MavenProjectHelper' + +// check values set by every annotation +mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "maximal"}[0] + +assert mojo.goal.text() == 'maximal' +assert mojo.implementation.text() == 'org.apache.maven.plugin.coreit.Maximal' +assert mojo.language.text() == 'java' +assert mojo.description.text() == 'Checks maximum annotations with non-default values.' +assert mojo.deprecated.text() == 'deprecated-text' +assert mojo.requiresDependencyResolution.text() == 'compile' +assert mojo.requiresDependencyCollection.text() == 'test' +assert mojo.requiresProject.text() == 'false' +assert mojo.requiresOnline.text() == 'true' +assert mojo.requiresDirectInvocation.text() == 'true' +assert mojo.requiresReports.text() == 'true' +assert mojo.aggregator.text() == 'true' +assert mojo.configurator.text() == 'configurator-hint' assert mojo.threadSafe.text() == 'true' +assert mojo.phase.text() == 'package' +assert mojo.executePhase.text() == 'compile' +assert mojo.executeLifecycle.text() == '' +assert mojo.executionStrategy.text() == 'always' +assert mojo.inheritedByDefault.text() == 'false' +assert mojo.instantiationStrategy.text() == 'singleton' + +parameter = mojo.parameters.parameter.findAll{ it.name.text() == "param" }[0] +assert parameter.name.text() == 'param' +assert parameter.alias.text() == 'myAlias' +assert parameter.type.text() == 'java.lang.String' +assert parameter.since.text() == 'since-text' +assert parameter.deprecated.text() == 'deprecated-text' +assert parameter.required.text() == 'true' +assert parameter.editable.text() == 'false' +assert parameter.description.text() == 'Parameter description.' + +requirement = mojo.requirements.requirement.findAll{ it.'field-name'.text() == "projectHelper" }[0] +assert requirement.role.text() == 'org.apache.maven.project.MavenProjectHelper' return true;