improve test of requiresDependencyResolution

git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1338386 13f79535-47bb-0310-9956-ffa450edef68
master
Olivier Lamy 2012-05-14 20:26:18 +00:00
parent dea91901e7
commit 650437ad74
3 changed files with 33 additions and 5 deletions

View File

@ -45,6 +45,11 @@ under the License.
<artifactId>maven-plugin-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
@ -78,6 +83,17 @@ under the License.
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-exec</artifactId>
<version>1.1</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>

View File

@ -19,6 +19,7 @@ package org.apache.maven.plugin.coreit;
* under the License.
*/
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.DependencyScope;
@ -27,13 +28,16 @@ import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import java.util.Set;
/**
* Touches a test file.
*
* @since 1.2
* @deprecated Don't use!
*/
@Mojo( name = "first", requiresDependencyResolution = DependencyScope.TEST, defaultPhase = LifecyclePhase.INTEGRATION_TEST )
@Mojo( name = "first", requiresDependencyResolution = DependencyScope.COMPILE,
defaultPhase = LifecyclePhase.INTEGRATION_TEST )
@Execute( phase = LifecyclePhase.GENERATE_SOURCES, lifecycle = "cobertura" )
public class FirstMojo
extends AbstractFirstMojo
@ -49,14 +53,17 @@ public class FirstMojo
@Component( role = "org.apache.maven.project.MavenProjectHelper" )//, roleHint = "default"
private Object projectHelper;
@Parameter( defaultValue = "${project.artifacts}", required = true, readonly = true )
private Set<Artifact> dependencies;
public void execute()
throws MojoExecutionException
{
if (basedir == null)
if ( basedir == null )
{
throw new MojoExecutionException( "basedir == null" );
}
if (touchFile == null)
if ( touchFile == null )
{
throw new MojoExecutionException( "touchFile == null" );
}
@ -69,6 +76,11 @@ public class FirstMojo
throw new MojoExecutionException( "compilerManager == null" );
}
if ( dependencies.isEmpty() )
{
throw new MojoExecutionException( "dependencies.isEmpty()" );
}
}
}

View File

@ -19,7 +19,7 @@ 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!"
assert mojo.requiresDependencyResolution.text() == 'test'
assert mojo.requiresDependencyResolution.text() == 'compile'
assert mojo.requiresDependencyCollection.text() == 'runtime'
assert mojo.requiresProject.text() == 'true'
assert mojo.requiresOnline.text() == 'false'
@ -44,7 +44,7 @@ assert mojo.requirements.requirement[2].role.text() == 'org.apache.maven.project
//assert mojo.requirements.requirement[2].'role-hint'.text() == 'default'
assert mojo.requirements.requirement[2].'field-name'.text() == 'projectHelper'
assert mojo.parameters.parameter.size() == 3
assert mojo.parameters.parameter.size() == 4
def parameter = mojo.parameters.parameter.findAll{ it.name.text() == "aliasedParam"}[0]