improve test of requiresDependencyResolution
git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1338386 13f79535-47bb-0310-9956-ffa450edef68master
parent
dea91901e7
commit
650437ad74
|
|
@ -45,6 +45,11 @@ under the License.
|
||||||
<artifactId>maven-plugin-api</artifactId>
|
<artifactId>maven-plugin-api</artifactId>
|
||||||
<version>2.0</version>
|
<version>2.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven</groupId>
|
||||||
|
<artifactId>maven-artifact</artifactId>
|
||||||
|
<version>2.0</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven</groupId>
|
<groupId>org.apache.maven</groupId>
|
||||||
<artifactId>maven-project</artifactId>
|
<artifactId>maven-project</artifactId>
|
||||||
|
|
@ -78,6 +83,17 @@ under the License.
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</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>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ package org.apache.maven.plugin.coreit;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.plugins.annotations.Component;
|
import org.apache.maven.plugins.annotations.Component;
|
||||||
import org.apache.maven.plugins.annotations.DependencyScope;
|
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.Mojo;
|
||||||
import org.apache.maven.plugins.annotations.Parameter;
|
import org.apache.maven.plugins.annotations.Parameter;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Touches a test file.
|
* Touches a test file.
|
||||||
*
|
*
|
||||||
* @since 1.2
|
* @since 1.2
|
||||||
* @deprecated Don't use!
|
* @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" )
|
@Execute( phase = LifecyclePhase.GENERATE_SOURCES, lifecycle = "cobertura" )
|
||||||
public class FirstMojo
|
public class FirstMojo
|
||||||
extends AbstractFirstMojo
|
extends AbstractFirstMojo
|
||||||
|
|
@ -49,14 +53,17 @@ 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 )
|
||||||
|
private Set<Artifact> dependencies;
|
||||||
|
|
||||||
public void execute()
|
public void execute()
|
||||||
throws MojoExecutionException
|
throws MojoExecutionException
|
||||||
{
|
{
|
||||||
if (basedir == null)
|
if ( basedir == null )
|
||||||
{
|
{
|
||||||
throw new MojoExecutionException( "basedir == null" );
|
throw new MojoExecutionException( "basedir == null" );
|
||||||
}
|
}
|
||||||
if (touchFile == null)
|
if ( touchFile == null )
|
||||||
{
|
{
|
||||||
throw new MojoExecutionException( "touchFile == null" );
|
throw new MojoExecutionException( "touchFile == null" );
|
||||||
}
|
}
|
||||||
|
|
@ -69,6 +76,11 @@ public class FirstMojo
|
||||||
throw new MojoExecutionException( "compilerManager == null" );
|
throw new MojoExecutionException( "compilerManager == null" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( dependencies.isEmpty() )
|
||||||
|
{
|
||||||
|
throw new MojoExecutionException( "dependencies.isEmpty()" );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ assert mojo.implementation.text() == 'org.apache.maven.plugin.coreit.FirstMojo'
|
||||||
assert mojo.language.text() == 'java'
|
assert mojo.language.text() == 'java'
|
||||||
assert mojo.description.text() == 'Touches a test file.'
|
assert mojo.description.text() == 'Touches a test file.'
|
||||||
assert mojo.deprecated.text() == "Don't use!"
|
assert mojo.deprecated.text() == "Don't use!"
|
||||||
assert mojo.requiresDependencyResolution.text() == 'test'
|
assert mojo.requiresDependencyResolution.text() == 'compile'
|
||||||
assert mojo.requiresDependencyCollection.text() == 'runtime'
|
assert mojo.requiresDependencyCollection.text() == 'runtime'
|
||||||
assert mojo.requiresProject.text() == 'true'
|
assert mojo.requiresProject.text() == 'true'
|
||||||
assert mojo.requiresOnline.text() == 'false'
|
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].'role-hint'.text() == 'default'
|
||||||
assert mojo.requirements.requirement[2].'field-name'.text() == 'projectHelper'
|
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]
|
def parameter = mojo.parameters.parameter.findAll{ it.name.text() == "aliasedParam"}[0]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue