You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2010/09/09 17:20:13 UTC
svn commit: r995456 - in /maven/core-integration-testing/trunk:
core-it-suite/src/test/java/org/apache/maven/it/
core-it-suite/src/test/resources/mng-4785/
core-it-suite/src/test/resources/mng-4785/repo/
core-it-suite/src/test/resources/mng-4785/repo/o...
Author: bentmann
Date: Thu Sep 9 15:20:12 2010
New Revision: 995456
URL: http://svn.apache.org/viewvc?rev=995456&view=rev
Log:
[MNG-4785] NPE in dependency resolution code for TC plugin
o Added IT
Added:
maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4785TransitiveResolutionInForkedThreadTest.java (with props)
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/pom.xml (with props)
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/repo/
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/repo/org/
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/repo/org/apache/
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/repo/org/apache/maven/
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/repo/org/apache/maven/its/
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/repo/org/apache/maven/its/mng4785/
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/repo/org/apache/maven/its/mng4785/dep/
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/repo/org/apache/maven/its/mng4785/dep/0.1-SNAPSHOT/
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/repo/org/apache/maven/its/mng4785/dep/0.1-SNAPSHOT/dep-0.1-20100909.144341-1.jar (with props)
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/repo/org/apache/maven/its/mng4785/dep/0.1-SNAPSHOT/dep-0.1-20100909.144341-1.pom
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/repo/org/apache/maven/its/mng4785/dep/0.1-SNAPSHOT/maven-metadata.xml (with props)
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/settings-template.xml (with props)
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveTransitiveMojo.java (with props)
Modified:
maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveMojo.java
Modified: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java?rev=995456&r1=995455&r2=995456&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java (original)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java Thu Sep 9 15:20:12 2010
@@ -87,6 +87,7 @@ public class IntegrationTestSuite
suite.addTestSuite( MavenITmng4789ScopeInheritanceMeetsConflictTest.class );
suite.addTestSuite( MavenITmng4788InstallationToCustomLocalRepoTest.class );
suite.addTestSuite( MavenITmng4786AntBased21xMojoSupportTest.class );
+ suite.addTestSuite( MavenITmng4785TransitiveResolutionInForkedThreadTest.class );
suite.addTestSuite( MavenITmng4781DeploymentToNexusStagingRepoTest.class );
suite.addTestSuite( MavenITmng4779MultipleDepsWithVersionRangeFromLocalRepoTest.class );
suite.addTestSuite( MavenITmng4776ForkedReactorPluginVersionResolutionTest.class );
Added: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4785TransitiveResolutionInForkedThreadTest.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4785TransitiveResolutionInForkedThreadTest.java?rev=995456&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4785TransitiveResolutionInForkedThreadTest.java (added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4785TransitiveResolutionInForkedThreadTest.java Thu Sep 9 15:20:12 2010
@@ -0,0 +1,67 @@
+package org.apache.maven.it;
+
+/*
+ * 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.it.Verifier;
+import org.apache.maven.it.util.ResourceExtractor;
+
+import java.io.File;
+import java.util.Properties;
+
+/**
+ * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4785">MNG-4785</a>.
+ *
+ * @author Benjamin Bentmann
+ */
+public class MavenITmng4785TransitiveResolutionInForkedThreadTest
+ extends AbstractMavenIntegrationTestCase
+{
+
+ public MavenITmng4785TransitiveResolutionInForkedThreadTest()
+ {
+ super( "[2.0.3,3.0-alpha-1),[3.0-beta-4,)" );
+ }
+
+ /**
+ * Verify that dependency resolution using the 2.x API in forked threads works (e.g. has access to any required
+ * session state).
+ */
+ public void testit()
+ throws Exception
+ {
+ File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4785" );
+
+ Verifier verifier = newVerifier( testDir.getAbsolutePath() );
+ verifier.setAutoclean( false );
+ verifier.deleteDirectory( "target" );
+ verifier.deleteArtifacts( "org.apache.maven.its.mng4785" );
+ verifier.getCliOptions().add( "-s" );
+ verifier.getCliOptions().add( "settings.xml" );
+ verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties() );
+ verifier.executeGoal( "validate" );
+ verifier.verifyErrorFreeLog();
+ verifier.resetStreams();
+
+ Properties props = verifier.loadProperties( "target/artifacts.properties" );
+ String path = props.getProperty( "org.apache.maven.its.mng4785:dep:jar:0.1-SNAPSHOT", "" );
+ assertTrue( path, path.endsWith( "dep-0.1-SNAPSHOT.jar" ) );
+ }
+
+}
Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4785TransitiveResolutionInForkedThreadTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4785TransitiveResolutionInForkedThreadTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/pom.xml?rev=995456&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/pom.xml (added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/pom.xml Thu Sep 9 15:20:12 2010
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<project>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.its.mng4785</groupId>
+ <artifactId>test</artifactId>
+ <version>0.1</version>
+ <packaging>jar</packaging>
+
+ <name>Maven Integration Test :: MNG-4785</name>
+ <description>
+ Verify that dependency resolution using 2.x API in forked threads works (e.g. has access to any required
+ session state).
+ </description>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.its.plugins</groupId>
+ <artifactId>maven-it-plugin-artifact</artifactId>
+ <version>2.1-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <id>test</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>resolve-transitive</goal>
+ </goals>
+ <configuration>
+ <propertiesFile>target/artifacts.properties</propertiesFile>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.its.mng4785</groupId>
+ <artifactId>dep</artifactId>
+ <version>0.1-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/repo/org/apache/maven/its/mng4785/dep/0.1-SNAPSHOT/dep-0.1-20100909.144341-1.jar
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/repo/org/apache/maven/its/mng4785/dep/0.1-SNAPSHOT/dep-0.1-20100909.144341-1.jar?rev=995456&view=auto
==============================================================================
Binary file - no diff available.
Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/repo/org/apache/maven/its/mng4785/dep/0.1-SNAPSHOT/dep-0.1-20100909.144341-1.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/repo/org/apache/maven/its/mng4785/dep/0.1-SNAPSHOT/dep-0.1-20100909.144341-1.pom
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/repo/org/apache/maven/its/mng4785/dep/0.1-SNAPSHOT/dep-0.1-20100909.144341-1.pom?rev=995456&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/repo/org/apache/maven/its/mng4785/dep/0.1-SNAPSHOT/dep-0.1-20100909.144341-1.pom (added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/repo/org/apache/maven/its/mng4785/dep/0.1-SNAPSHOT/dep-0.1-20100909.144341-1.pom Thu Sep 9 15:20:12 2010
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<project>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.its.mng4785</groupId>
+ <artifactId>dep</artifactId>
+ <version>0.1-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <distributionManagement>
+ <repository>
+ <id>maven-core-it</id>
+ <url>file:///${basedir}/repo</url>
+ </repository>
+ </distributionManagement>
+</project>
Added: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/repo/org/apache/maven/its/mng4785/dep/0.1-SNAPSHOT/maven-metadata.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/repo/org/apache/maven/its/mng4785/dep/0.1-SNAPSHOT/maven-metadata.xml?rev=995456&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/repo/org/apache/maven/its/mng4785/dep/0.1-SNAPSHOT/maven-metadata.xml (added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/repo/org/apache/maven/its/mng4785/dep/0.1-SNAPSHOT/maven-metadata.xml Thu Sep 9 15:20:12 2010
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<metadata>
+ <groupId>org.apache.maven.its.mng4785</groupId>
+ <artifactId>dep</artifactId>
+ <version>0.1-SNAPSHOT</version>
+ <versioning>
+ <snapshot>
+ <timestamp>20100909.144341</timestamp>
+ <buildNumber>1</buildNumber>
+ </snapshot>
+ <lastUpdated>20100909144341</lastUpdated>
+ </versioning>
+</metadata>
Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/repo/org/apache/maven/its/mng4785/dep/0.1-SNAPSHOT/maven-metadata.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/repo/org/apache/maven/its/mng4785/dep/0.1-SNAPSHOT/maven-metadata.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/settings-template.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/settings-template.xml?rev=995456&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/settings-template.xml (added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/settings-template.xml Thu Sep 9 15:20:12 2010
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<settings>
+ <profiles>
+ <profile>
+ <id>maven-core-it-repo</id>
+ <repositories>
+ <repository>
+ <id>maven-core-it</id>
+ <url>@baseurl@/repo</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <checksumPolicy>ignore</checksumPolicy>
+ </snapshots>
+ </repository>
+ </repositories>
+ </profile>
+ </profiles>
+ <activeProfiles>
+ <activeProfile>maven-core-it-repo</activeProfile>
+ </activeProfiles>
+</settings>
Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/settings-template.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4785/settings-template.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveMojo.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveMojo.java?rev=995456&r1=995455&r2=995456&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveMojo.java (original)
+++ maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveMojo.java Thu Sep 9 15:20:12 2010
@@ -26,10 +26,8 @@ import org.apache.maven.artifact.resolve
import org.apache.maven.model.Dependency;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
import java.io.File;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
@@ -96,10 +94,10 @@ public class ResolveMojo
/**
* Runs this mojo.
*
- * @throws MojoFailureException If the artifact file has not been set.
+ * @throws MojoFailureException If the artifact could not be resolved
*/
public void execute()
- throws MojoExecutionException, MojoFailureException
+ throws MojoExecutionException
{
getLog().info( "[MAVEN-CORE-IT-LOG] Resolving artifacts" );
@@ -163,6 +161,7 @@ public class ResolveMojo
private String getId( Artifact artifact )
{
+ artifact.isSnapshot(); // decouple from MNG-2961
return artifact.getId();
}
Added: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveTransitiveMojo.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveTransitiveMojo.java?rev=995456&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveTransitiveMojo.java (added)
+++ maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveTransitiveMojo.java Thu Sep 9 15:20:12 2010
@@ -0,0 +1,221 @@
+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.artifact.Artifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.model.Dependency;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+/**
+ * Resolves user-specified artifacts transitively. As an additional exercise, the resolution happens in a forked thread
+ * to test access to any shared session state.
+ *
+ * @goal resolve-transitive
+ *
+ * @author Benjamin Bentmann
+ */
+public class ResolveTransitiveMojo
+ extends AbstractMojo
+{
+
+ /**
+ * The local repository.
+ *
+ * @parameter default-value="${localRepository}"
+ * @readonly
+ * @required
+ */
+ private ArtifactRepository localRepository;
+
+ /**
+ * The remote repositories of the current Maven project.
+ *
+ * @parameter default-value="${project.remoteArtifactRepositories}"
+ * @readonly
+ * @required
+ */
+ private List remoteRepositories;
+
+ /**
+ * The artifact resolver.
+ *
+ * @component
+ */
+ private ArtifactResolver resolver;
+
+ /**
+ * The artifact factory.
+ *
+ * @component
+ */
+ private ArtifactFactory factory;
+
+ /**
+ * The metadata source.
+ *
+ * @component
+ */
+ private ArtifactMetadataSource metadataSource;
+
+ /**
+ * The dependencies to resolve.
+ *
+ * @parameter
+ */
+ private Dependency[] dependencies;
+
+ /**
+ * The path to a properties file to store the resolved artifact paths in.
+ *
+ * @parameter
+ */
+ private File propertiesFile;
+
+ /**
+ * Runs this mojo.
+ *
+ * @throws MojoExecutionException If the artifacts couldn't be resolved.
+ */
+ public void execute()
+ throws MojoExecutionException
+ {
+ getLog().info( "[MAVEN-CORE-IT-LOG] Resolving artifacts" );
+
+ ResolverThread thread = new ResolverThread();
+ thread.start();
+ while ( thread.isAlive() )
+ {
+ try
+ {
+ thread.join();
+ }
+ catch ( InterruptedException e )
+ {
+ e.printStackTrace();
+ }
+ }
+
+ if ( thread.error != null )
+ {
+ throw new MojoExecutionException( "Failed to resolve artifacts: " + thread.error.getMessage(), thread.error );
+ }
+
+ if ( propertiesFile != null )
+ {
+ getLog().info( "[MAVEN-CORE-IT-LOG] Creating properties file " + propertiesFile );
+
+ try
+ {
+ propertiesFile.getParentFile().mkdirs();
+
+ FileOutputStream fos = new FileOutputStream( propertiesFile );
+ try
+ {
+ thread.props.store( fos, "MAVEN-CORE-IT" );
+ }
+ finally
+ {
+ fos.close();
+ }
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Failed to create properties file: " + e.getMessage(), e );
+ }
+ }
+ }
+
+ private String getId( Artifact artifact )
+ {
+ artifact.isSnapshot(); // decouple from MNG-2961
+ return artifact.getId();
+ }
+
+ class ResolverThread
+ extends Thread
+ {
+
+ Properties props = new Properties();
+
+ Exception error;
+
+ public void run()
+ {
+ if ( dependencies != null )
+ {
+ try
+ {
+ Set artifacts = new LinkedHashSet();
+
+ for ( int i = 0; i < dependencies.length; i++ )
+ {
+ Dependency dependency = dependencies[i];
+
+ Artifact artifact =
+ factory.createArtifactWithClassifier( dependency.getGroupId(), dependency.getArtifactId(),
+ dependency.getVersion(), dependency.getType(),
+ dependency.getClassifier() );
+
+ getLog().info( "[MAVEN-CORE-IT-LOG] Resolving " + getId( artifact ) );
+
+ artifacts.add( artifact );
+ }
+
+ Artifact origin = factory.createArtifact( "it", "it", "0.1", null, "pom" );
+
+ artifacts =
+ resolver.resolveTransitively( artifacts, origin, remoteRepositories, localRepository,
+ metadataSource ).getArtifacts();
+
+ for ( Iterator it = artifacts.iterator(); it.hasNext(); )
+ {
+ Artifact artifact = (Artifact) it.next();
+
+ if ( artifact.getFile() != null )
+ {
+ props.setProperty( getId( artifact ), artifact.getFile().getPath() );
+ }
+
+ getLog().info( "[MAVEN-CORE-IT-LOG] " + artifact.getFile() );
+ }
+ }
+ catch ( Exception e )
+ {
+ error = e;
+ }
+ }
+ }
+ }
+
+}
Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveTransitiveMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveTransitiveMojo.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision