Author: jdcasey Date: Wed Jul 30 19:03:37 2008 New Revision: 681253 URL: http://svn.apache.org/viewvc?rev=681253&view=rev Log: Refactoring test to use isolated test-only plugin to avoid weirdness on windows when dependency artifact is present but isn't a valid jar.
Added: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3680-invalidDependencyPOM/maven-mng3680-plugin/ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3680-invalidDependencyPOM/maven-mng3680-plugin/pom.xml maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3680-invalidDependencyPOM/maven-mng3680-plugin/src/ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3680-invalidDependencyPOM/maven-mng3680-plugin/src/main/ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3680-invalidDependencyPOM/maven-mng3680-plugin/src/main/java/ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3680-invalidDependencyPOM/maven-mng3680-plugin/src/main/java/plugin/ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3680-invalidDependencyPOM/maven-mng3680-plugin/src/main/java/plugin/MyMojo.java Modified: maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3680InvalidDependencyPOMTest.java maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3680-invalidDependencyPOM/pom.xml Modified: maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3680InvalidDependencyPOMTest.java URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3680InvalidDependencyPOMTest.java?rev=681253&r1=681252&r2=681253&view=diff ============================================================================== --- maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3680InvalidDependencyPOMTest.java (original) +++ maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3680InvalidDependencyPOMTest.java Wed Jul 30 19:03:37 2008 @@ -25,10 +25,23 @@ throws Exception { File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3680-invalidDependencyPOM" ); + File pluginDir = new File( testDir, "maven-mng3680-plugin" ); + + Verifier verifier = new Verifier( pluginDir.getAbsolutePath() ); + + verifier.executeGoal( "install" ); + verifier.verifyErrorFreeLog(); + verifier.resetStreams(); - Verifier verifier = new Verifier( testDir.getAbsolutePath() ); + verifier = new Verifier( testDir.getAbsolutePath() ); + + verifier.deleteArtifact( "tests", "dep-L1", "1", "jar" ); + verifier.deleteArtifact( "tests", "dep-L1", "1", "pom" ); + + verifier.deleteArtifact( "tests", "dep-L1", "1", "jar" ); + verifier.deleteArtifact( "tests", "dep-L2", "1", "pom" ); - verifier.executeGoal( "compile" ); + verifier.executeGoal( "validate" ); verifier.verifyErrorFreeLog(); verifier.resetStreams(); } Added: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3680-invalidDependencyPOM/maven-mng3680-plugin/pom.xml URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3680-invalidDependencyPOM/maven-mng3680-plugin/pom.xml?rev=681253&view=auto ============================================================================== --- maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3680-invalidDependencyPOM/maven-mng3680-plugin/pom.xml (added) +++ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3680-invalidDependencyPOM/maven-mng3680-plugin/pom.xml Wed Jul 30 19:03:37 2008 @@ -0,0 +1,28 @@ +<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.mng3680</groupId> + <artifactId>maven-mng3680-plugin</artifactId> + <packaging>maven-plugin</packaging> + <version>1</version> + <name>maven-mng3680-plugin Maven Mojo</name> + <url>http://maven.apache.org</url> + <dependencies> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-plugin-api</artifactId> + <version>2.0</version> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-artifact</artifactId> + <version>2.0.9</version> + </dependency> + </dependencies> +</project> Added: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3680-invalidDependencyPOM/maven-mng3680-plugin/src/main/java/plugin/MyMojo.java URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3680-invalidDependencyPOM/maven-mng3680-plugin/src/main/java/plugin/MyMojo.java?rev=681253&view=auto ============================================================================== --- maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3680-invalidDependencyPOM/maven-mng3680-plugin/src/main/java/plugin/MyMojo.java (added) +++ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3680-invalidDependencyPOM/maven-mng3680-plugin/src/main/java/plugin/MyMojo.java Wed Jul 30 19:03:37 2008 @@ -0,0 +1,79 @@ +package plugin; + +/* + * Copyright 2001-2005 The Apache Software Foundation. + * + * Licensed 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.artifact.Artifact; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Iterator; +import java.util.List; + +/** + * Goal which touches a timestamp file. + * + * @goal check + * @requiresDependencyResolution compile + * @phase validate + */ +public class MyMojo + extends AbstractMojo +{ + /** + * @parameter expression="${project.compileArtifacts}" + * @required + */ + private List artifacts; + + public void execute() + throws MojoExecutionException + { + boolean foundL1 = false; + boolean foundL2 = false; + + if ( artifacts != null ) + { + for ( Iterator it = artifacts.iterator(); it.hasNext(); ) + { + Artifact artifact = (Artifact) it.next(); + + if ( !foundL1 && artifact.getArtifactId().equals( "dep-L1" ) ) + { + foundL1 = true; + } + else if ( !foundL2 && artifact.getArtifactId().equals( "dep-L2" ) ) + { + foundL2 = true; + } + + if ( foundL1 && foundL2 ) + { + break; + } + } + } + + if ( !foundL1 || !foundL2 ) + { + throw new MojoExecutionException( "Didn't find the following artifacts: " + ( foundL1 ? "" : "\n- dep-L1" ) + + ( foundL2 ? "" : "\n- dep-L2" ) ); + } + } +} Modified: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3680-invalidDependencyPOM/pom.xml URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3680-invalidDependencyPOM/pom.xml?rev=681253&r1=681252&r2=681253&view=diff ============================================================================== --- maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3680-invalidDependencyPOM/pom.xml (original) +++ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3680-invalidDependencyPOM/pom.xml Wed Jul 30 19:03:37 2008 @@ -31,20 +31,16 @@ <build> <plugins> <plugin> - <artifactId>maven-assembly-plugin</artifactId> - <version>2.2-beta-2</version> + <groupId>org.apache.maven.its.mng3680</groupId> + <artifactId>maven-mng3680-plugin</artifactId> + <version>1</version> <executions> <execution> - <id>assembly</id> - <phase>package</phase> + <id>check-deps</id> + <phase>validate</phase> <goals> - <goal>single</goal> + <goal>check</goal> </goals> - <configuration> - <descriptorRefs> - <descriptorRef>jar-with-dependencies</descriptorRef> - </descriptorRefs> - </configuration> </execution> </executions> </plugin>