mirror of https://github.com/apache/maven.git
[MNG-2720] Clean up the integration test for MNG-2720, so it uses one of the standard IT plugins (*-plugin-dependencies, to be specific).
git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@742607 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9bc2060366
commit
19d2d9492b
|
@ -19,15 +19,13 @@
|
|||
|
||||
package org.apache.maven.it;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
|
||||
import org.apache.maven.it.AbstractMavenIntegrationTestCase;
|
||||
import org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-2720">MNG-2720</a>.
|
||||
*
|
||||
|
@ -54,18 +52,34 @@ public class MavenITmng2720SiblingClasspathArtifactsTest
|
|||
throws Exception
|
||||
{
|
||||
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2720" );
|
||||
File pluginDir = new File( testDir, "plugin" );
|
||||
File projectDir = new File( testDir, "project-hierarchy" );
|
||||
|
||||
// First, install the plugin used for the test.
|
||||
Verifier verifier = new Verifier( pluginDir.getAbsolutePath() );
|
||||
verifier.executeGoal( "install" );
|
||||
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
|
||||
|
||||
verifier.executeGoal( "package" );
|
||||
verifier.verifyErrorFreeLog();
|
||||
verifier.resetStreams();
|
||||
|
||||
// Now, build the project hierarchy that uses the plugin to verify sibling dependencies.
|
||||
verifier = new Verifier( projectDir.getAbsolutePath() );
|
||||
verifier.executeGoal( "package" );
|
||||
verifier.verifyErrorFreeLog();
|
||||
List compileClassPath = verifier.loadLines( "child2/target/compile.classpath", "UTF-8" );
|
||||
assertTrue( find( "child1-1.jar", compileClassPath ) );
|
||||
|
||||
compileClassPath = verifier.loadLines( "child3/target/compile.classpath", "UTF-8" );
|
||||
assertFalse( find( "child1-1.jar", compileClassPath ) );
|
||||
assertTrue( find( "child1-1-tests.jar", compileClassPath ) );
|
||||
|
||||
}
|
||||
|
||||
private boolean find( String pathSubstr, List classPath )
|
||||
{
|
||||
for ( Iterator it = classPath.iterator(); it.hasNext(); )
|
||||
{
|
||||
String path = (String) it.next();
|
||||
|
||||
if ( path.indexOf( pathSubstr ) > -1 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.maven.its.mng2720</groupId>
|
||||
<artifactId>maven-mng2720-plugin</artifactId>
|
||||
<packaging>maven-plugin</packaging>
|
||||
<version>1</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-plugin-api</artifactId>
|
||||
<version>2.0.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-project</artifactId>
|
||||
<version>2.0.9</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,88 +0,0 @@
|
|||
package org.apache.maven.debug.mng2720;
|
||||
|
||||
import org.apache.maven.artifact.DependencyResolutionRequiredException;
|
||||
import org.apache.maven.plugin.Mojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.apache.maven.plugin.logging.Log;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @goal test
|
||||
* @requiresDependencyResolution compile
|
||||
* @phase package
|
||||
*/
|
||||
public class ClasspathMojo
|
||||
implements Mojo
|
||||
{
|
||||
|
||||
/**
|
||||
* @parameter default-value="${project}"
|
||||
* @readonly
|
||||
*/
|
||||
private MavenProject project;
|
||||
|
||||
/**
|
||||
* @parameter default-value="${project.compileClasspathElements}"
|
||||
* @readonly
|
||||
*/
|
||||
private List compileClasspathElements;
|
||||
|
||||
private Log log;
|
||||
|
||||
public void execute() throws MojoExecutionException, MojoFailureException
|
||||
{
|
||||
if ( "child2".equals( project.getArtifactId() ) )
|
||||
{
|
||||
boolean found = false;
|
||||
for ( Iterator it = compileClasspathElements.iterator(); it.hasNext(); )
|
||||
{
|
||||
String path = (String) it.next();
|
||||
if ( path.indexOf( "child1-1.jar" ) > -1 )
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !found )
|
||||
{
|
||||
throw new MojoExecutionException( "child1-1.jar dependency artifact path not found in compile classpath for project: " + project.getId() );
|
||||
}
|
||||
}
|
||||
else if ( "child3".equals( project.getArtifactId() ) )
|
||||
{
|
||||
boolean found = false;
|
||||
for ( Iterator it = compileClasspathElements.iterator(); it.hasNext(); )
|
||||
{
|
||||
String path = (String) it.next();
|
||||
if ( path.indexOf( "child1-1-tests.jar" ) > -1 )
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !found )
|
||||
{
|
||||
throw new MojoExecutionException( "child1-1-tests.jar dependency artifact path not found in compile classpath for project: " + project.getId() );
|
||||
}
|
||||
}
|
||||
|
||||
log.info( "Tests succeeded." );
|
||||
}
|
||||
|
||||
public Log getLog()
|
||||
{
|
||||
return log;
|
||||
}
|
||||
|
||||
public void setLog( Log log )
|
||||
{
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
<artifactId>project-hierarchy</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1</version>
|
||||
<name>MNG-2720 Project Hierarchy 1</name>
|
||||
<name>MNG-2720 Project Hierarchy</name>
|
||||
|
||||
<modules>
|
||||
<module>child1</module>
|
||||
|
@ -16,16 +16,19 @@
|
|||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.its.mng2720</groupId>
|
||||
<artifactId>maven-mng2720-plugin</artifactId>
|
||||
<version>1</version>
|
||||
<groupId>org.apache.maven.its.plugins</groupId>
|
||||
<artifactId>maven-it-plugin-dependency-resolution</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>test</id>
|
||||
<id>compile-classpath</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>test</goal>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<compileClassPath>${project.build.directory}/compile.classpath</compileClassPath>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
Loading…
Reference in New Issue