diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
index 95f14c7d02..53c03bcc1e 100644
--- a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
+++ b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
@@ -86,6 +86,7 @@ public class IntegrationTestSuite
// suite.addTestSuite( MavenIT0109ReleaseUpdateTest.class );
// suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
+ suite.addTestSuite( MavenITmng4331DependencyCollectionTest.class );
suite.addTestSuite( MavenITmng4328PrimitiveMojoParameterConfigurationTest.class );
suite.addTestSuite( MavenITmng4327ExcludeForkingMojoFromForkedLifecycleTest.class );
suite.addTestSuite( MavenITmng4321CliUsesPluginMgmtConfigTest.class );
diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4331DependencyCollectionTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4331DependencyCollectionTest.java
new file mode 100644
index 0000000000..c023fdce5a
--- /dev/null
+++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4331DependencyCollectionTest.java
@@ -0,0 +1,96 @@
+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.List;
+
+/**
+ * This is a test set for MNG-4331.
+ *
+ * @author Benjamin Bentmann
+ */
+public class MavenITmng4331DependencyCollectionTest
+ extends AbstractMavenIntegrationTestCase
+{
+
+ public MavenITmng4331DependencyCollectionTest()
+ {
+ super( "[3.0-alpha-3,)" );
+ }
+
+ /**
+ * Test that @requiresDependencyCollection works for a goal that is bound into a very early lifecycle phase
+ * like "validate" where none of the reactor projects have an artifact file. The Enforcer Plugin is the
+ * real world example for this use case.
+ */
+ public void testitEarlyLifecyclePhase()
+ throws Exception
+ {
+ File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4331" );
+
+ Verifier verifier = new Verifier( testDir.getAbsolutePath() );
+ verifier.setAutoclean( false );
+ verifier.deleteArtifacts( "org.apache.maven.its.mng4331" );
+ verifier.deleteDirectory( "sub-2/target" );
+ verifier.setLogFileName( "log-lifecycle.txt" );
+ verifier.executeGoal( "validate" );
+ verifier.verifyErrorFreeLog();
+ verifier.resetStreams();
+
+ List artifacts = verifier.loadLines( "sub-2/target/compile.txt", "UTF-8" );
+ assertTrue( artifacts.toString(), artifacts.contains( "org.apache.maven.its.mng4331:sub-1:jar:0.1" ) );
+ assertEquals( 1, artifacts.size() );
+ }
+
+ /**
+ * Test that @requiresDependencyCollection works for an aggregator goal that is invoked from the command line.
+ * The Release Plugin is the real world example for this use case.
+ */
+ public void testitCliAggregator()
+ throws Exception
+ {
+ File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4331" );
+
+ Verifier verifier = new Verifier( testDir.getAbsolutePath() );
+ verifier.setAutoclean( false );
+ verifier.deleteDirectory( "target" );
+ verifier.deleteArtifacts( "org.apache.maven.its.mng4331" );
+ verifier.getCliOptions().add( "-Ddepres.projectArtifacts=target/@artifactId@.txt" );
+ verifier.setLogFileName( "log-aggregator.txt" );
+ verifier.executeGoal( "org.apache.maven.its.plugins:maven-it-plugin-dependency-collection:2.1-SNAPSHOT:aggregate-test" );
+ verifier.verifyErrorFreeLog();
+ verifier.resetStreams();
+
+ List artifacts = verifier.loadLines( "target/sub-2.txt", "UTF-8" );
+ assertTrue( artifacts.toString(), artifacts.contains( "org.apache.maven.its.mng4331:sub-1:jar:0.1" ) );
+ assertEquals( 1, artifacts.size() );
+
+ artifacts = verifier.loadLines( "target/sub-1.txt", "UTF-8" );
+ assertEquals( 0, artifacts.size() );
+
+ artifacts = verifier.loadLines( "target/test.txt", "UTF-8" );
+ assertEquals( 0, artifacts.size() );
+ }
+
+}
diff --git a/its/core-it-suite/src/test/resources/bootstrap/pom.xml b/its/core-it-suite/src/test/resources/bootstrap/pom.xml
index 3fbf587495..d02131b6f5 100644
--- a/its/core-it-suite/src/test/resources/bootstrap/pom.xml
+++ b/its/core-it-suite/src/test/resources/bootstrap/pom.xml
@@ -91,6 +91,12 @@ under the License.
${itPluginVersion}
runtime
+
+ org.apache.maven.its.plugins
+ maven-it-plugin-dependency-collection
+ ${itPluginVersion}
+ runtime
+
org.apache.maven.its.plugins
maven-it-plugin-dependency-resolution
diff --git a/its/core-it-suite/src/test/resources/mng-4331/pom.xml b/its/core-it-suite/src/test/resources/mng-4331/pom.xml
new file mode 100644
index 0000000000..0bdc595d74
--- /dev/null
+++ b/its/core-it-suite/src/test/resources/mng-4331/pom.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+ 4.0.0
+
+ org.apache.maven.its.mng4331
+ test
+ 0.1
+ pom
+
+ Maven Integration Test :: MNG-4331
+
+ Verify that the mojo annotation @requiresDependencyCollection allows to grab the transitive dependencies
+ without resolving their artifact files.
+
+
+
+ sub-1
+ sub-2
+
+
+
diff --git a/its/core-it-suite/src/test/resources/mng-4331/sub-1/pom.xml b/its/core-it-suite/src/test/resources/mng-4331/sub-1/pom.xml
new file mode 100644
index 0000000000..ea993c6e00
--- /dev/null
+++ b/its/core-it-suite/src/test/resources/mng-4331/sub-1/pom.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+ 4.0.0
+
+ org.apache.maven.its.mng4331
+ sub-1
+ 0.1
+ jar
+
+ Maven Integration Test :: MNG-4331 :: Sub-1
+
+ Verify that the mojo annotation @requiresDependencyCollection allows to grab the transitive dependencies
+ without resolving their artifact files.
+
+
+
diff --git a/its/core-it-suite/src/test/resources/mng-4331/sub-2/pom.xml b/its/core-it-suite/src/test/resources/mng-4331/sub-2/pom.xml
new file mode 100644
index 0000000000..d8fb4ce820
--- /dev/null
+++ b/its/core-it-suite/src/test/resources/mng-4331/sub-2/pom.xml
@@ -0,0 +1,66 @@
+
+
+
+
+
+ 4.0.0
+
+ org.apache.maven.its.mng4331
+ sub-2
+ 0.1
+ jar
+
+ Maven Integration Test :: MNG-4331 :: Sub-2
+
+ Verify that the mojo annotation @requiresDependencyCollection allows to grab the transitive dependencies
+ without resolving their artifact files.
+
+
+
+
+
+ org.apache.maven.its.mng4331
+ sub-1
+ 0.1
+
+
+
+
+
+
+ org.apache.maven.its.plugins
+ maven-it-plugin-dependency-collection
+ 2.1-SNAPSHOT
+
+
+ test
+ validate
+
+ compile
+
+
+ target/compile.txt
+
+
+
+
+
+
+
diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/pom.xml b/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/pom.xml
new file mode 100644
index 0000000000..e3935da7b0
--- /dev/null
+++ b/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/pom.xml
@@ -0,0 +1,86 @@
+
+
+
+
+
+ 4.0.0
+
+
+ maven-it-plugins
+ org.apache.maven.its.plugins
+ 2.1-SNAPSHOT
+
+
+ maven-it-plugin-dependency-collection
+ maven-plugin
+
+ Maven Integration Test Plugin :: Dependency Collection
+
+ A test plugin that provides several goals which employ @requiresDependencyCollection with different scopes. If
+ desired, the resulting artifact identifiers can be written to a text file.
+
+ 2008
+
+
+ true
+
+
+
+
+ org.apache.maven
+ maven-plugin-api
+ 2.0
+
+
+ org.apache.maven
+ maven-project
+ 2.0
+
+
+ org.apache.maven
+ maven-artifact
+ 2.0
+
+
+
+
+
+
+ maven-antrun-plugin
+ 1.2
+
+
+ delete-incomplete-plugin-descriptor
+ generate-resources
+
+ run
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/java/org/apache/maven/plugin/coreit/AbstractDependencyMojo.java b/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/java/org/apache/maven/plugin/coreit/AbstractDependencyMojo.java
new file mode 100644
index 0000000000..286dae53ab
--- /dev/null
+++ b/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/java/org/apache/maven/plugin/coreit/AbstractDependencyMojo.java
@@ -0,0 +1,130 @@
+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.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.util.Collection;
+import java.util.Iterator;
+
+/**
+ * Provides common services for all mojos of this plugin.
+ *
+ * @author Benjamin Bentmann
+ * @version $Id$
+ */
+public abstract class AbstractDependencyMojo
+ extends AbstractMojo
+{
+
+ /**
+ * The current Maven project.
+ *
+ * @parameter default-value="${project}"
+ * @required
+ * @readonly
+ */
+ protected MavenProject project;
+
+ /**
+ * Writes the specified artifacts to the given output file.
+ *
+ * @param pathname The path to the output file, relative to the project base directory, may be null
or
+ * empty if the output file should not be written.
+ * @param artifacts The list of artifacts to write to the file, may be null
.
+ * @throws MojoExecutionException If the output file could not be written.
+ */
+ protected void writeArtifacts( String pathname, Collection artifacts )
+ throws MojoExecutionException
+ {
+ if ( pathname == null || pathname.length() <= 0 )
+ {
+ return;
+ }
+
+ File file = resolveFile( pathname );
+
+ getLog().info( "[MAVEN-CORE-IT-LOG] Dumping artifact list: " + file );
+
+ BufferedWriter writer = null;
+ try
+ {
+ file.getParentFile().mkdirs();
+
+ writer = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( file ), "UTF-8" ) );
+
+ if ( artifacts != null )
+ {
+ for ( Iterator it = artifacts.iterator(); it.hasNext(); )
+ {
+ Artifact artifact = (Artifact) it.next();
+ writer.write( artifact.getId() );
+ writer.newLine();
+ getLog().info( "[MAVEN-CORE-IT-LOG] " + artifact.getId() );
+ }
+ }
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Failed to write artifact list", e );
+ }
+ finally
+ {
+ if ( writer != null )
+ {
+ try
+ {
+ writer.close();
+ }
+ catch ( IOException e )
+ {
+ // just ignore
+ }
+ }
+ }
+ }
+
+ // NOTE: We don't want to test path translation here so resolve relative path manually for robustness
+ private File resolveFile( String pathname )
+ {
+ File file = null;
+
+ if ( pathname != null )
+ {
+ file = new File( pathname );
+
+ if ( !file.isAbsolute() )
+ {
+ file = new File( project.getBasedir(), pathname );
+ }
+ }
+
+ return file;
+ }
+
+}
diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/java/org/apache/maven/plugin/coreit/AggregateTestMojo.java b/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/java/org/apache/maven/plugin/coreit/AggregateTestMojo.java
new file mode 100644
index 0000000000..3526682e92
--- /dev/null
+++ b/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/java/org/apache/maven/plugin/coreit/AggregateTestMojo.java
@@ -0,0 +1,101 @@
+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 java.util.Iterator;
+import java.util.List;
+
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+
+/**
+ * Combines dependency collection with aggregation. The path parameters of this mojo support the token
+ * @artifactId@
to dynamically adjust the output file for each project in the reactor whose
+ * dependencies are dumped.
+ *
+ * @goal aggregate-test
+ * @requiresDependencyResolution test
+ * @aggregator true
+ *
+ * @author Benjamin Bentmann
+ * @version $Id$
+ */
+public class AggregateTestMojo
+ extends AbstractDependencyMojo
+{
+
+ /**
+ * The path to the output file for the project artifacts, relative to the project base directory. Each line of this
+ * UTF-8 encoded file specifies an artifact identifier. If not specified, the artifact list will not be written to
+ * disk. Unlike the test artifacts, the collection of project artifacts additionally contains those artifacts that
+ * do not contribute to the class path.
+ *
+ * @parameter expression="${depres.projectArtifacts}"
+ */
+ private String projectArtifacts;
+
+ /**
+ * The Maven projects in the reactor.
+ *
+ * @parameter default-value="${reactorProjects}"
+ * @readonly
+ */
+ private List reactorProjects;
+
+ /**
+ * Runs this mojo.
+ *
+ * @throws MojoExecutionException If the output file could not be created or any dependency could not be resolved.
+ */
+ public void execute()
+ throws MojoExecutionException
+ {
+ try
+ {
+ for ( Iterator it = reactorProjects.iterator(); it.hasNext(); )
+ {
+ MavenProject project = (MavenProject) it.next();
+
+ writeArtifacts( filter( projectArtifacts, project ), project.getArtifacts() );
+
+ // NOTE: We can't make any assumptions about the class path but as a minimum it must not cause an exception
+ project.getTestClasspathElements();
+ }
+ }
+ catch ( DependencyResolutionRequiredException e )
+ {
+ throw new MojoExecutionException( "Failed to resolve dependencies", e );
+ }
+ }
+
+ private String filter( String filename, MavenProject project )
+ {
+ String result = filename;
+
+ if ( filename != null )
+ {
+ result = result.replaceAll( "@artifactId@", project.getArtifactId() );
+ }
+
+ return result;
+ }
+
+}
diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/java/org/apache/maven/plugin/coreit/CompileMojo.java b/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/java/org/apache/maven/plugin/coreit/CompileMojo.java
new file mode 100644
index 0000000000..287c5556e1
--- /dev/null
+++ b/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/java/org/apache/maven/plugin/coreit/CompileMojo.java
@@ -0,0 +1,79 @@
+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.DependencyResolutionRequiredException;
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * Creates text files that list the dependencies with scope compile in the order returned from the Maven core.
+ *
+ * @goal compile
+ * @requiresDependencyResolution compile
+ *
+ * @author Benjamin Bentmann
+ * @version $Id$
+ */
+public class CompileMojo
+ extends AbstractDependencyMojo
+{
+
+ /**
+ * The path to the output file for the project artifacts, relative to the project base directory. Each line of this
+ * UTF-8 encoded file specifies an artifact identifier. If not specified, the artifact list will not be written to
+ * disk. Unlike the compile artifacts, the collection of project artifacts additionally contains those artifacts
+ * that do not contribute to the class path.
+ *
+ * @parameter expression="${depres.projectArtifacts}"
+ */
+ private String projectArtifacts;
+
+ /**
+ * The path to the output file for the compile artifacts, relative to the project base directory. Each line of this
+ * UTF-8 encoded file specifies an artifact identifier. If not specified, the artifact list will not be written to
+ * disk.
+ *
+ * @parameter expression="${depres.compileArtifacts}"
+ */
+ private String compileArtifacts;
+
+ /**
+ * Runs this mojo.
+ *
+ * @throws MojoExecutionException If the output file could not be created or any dependency could not be resolved.
+ */
+ public void execute()
+ throws MojoExecutionException
+ {
+ try
+ {
+ writeArtifacts( projectArtifacts, project.getArtifacts() );
+ writeArtifacts( compileArtifacts, project.getCompileArtifacts() );
+
+ // NOTE: We can't make any assumptions about the class path but as a minimum it must not cause an exception
+ project.getCompileClasspathElements();
+ }
+ catch ( DependencyResolutionRequiredException e )
+ {
+ throw new MojoExecutionException( "Failed to resolve dependencies", e );
+ }
+ }
+
+}
diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/java/org/apache/maven/plugin/coreit/RuntimeMojo.java b/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/java/org/apache/maven/plugin/coreit/RuntimeMojo.java
new file mode 100644
index 0000000000..fd3841ed49
--- /dev/null
+++ b/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/java/org/apache/maven/plugin/coreit/RuntimeMojo.java
@@ -0,0 +1,79 @@
+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.DependencyResolutionRequiredException;
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * Creates text files that list the dependencies with scope runtime in the order returned from the Maven core.
+ *
+ * @goal runtime
+ * @requiresDependencyResolution runtime
+ *
+ * @author Benjamin Bentmann
+ * @version $Id$
+ */
+public class RuntimeMojo
+ extends AbstractDependencyMojo
+{
+
+ /**
+ * The path to the output file for the project artifacts, relative to the project base directory. Each line of this
+ * UTF-8 encoded file specifies an artifact identifier. If not specified, the artifact list will not be written to
+ * disk. Unlike the runtime artifacts, the collection of project artifacts additionally contains those artifacts
+ * that do not contribute to the class path.
+ *
+ * @parameter expression="${depres.projectArtifacts}"
+ */
+ private String projectArtifacts;
+
+ /**
+ * The path to the output file for the runtime artifacts, relative to the project base directory. Each line of this
+ * UTF-8 encoded file specifies an artifact identifier. If not specified, the artifact list will not be written to
+ * disk.
+ *
+ * @parameter expression="${depres.runtimeArtifacts}"
+ */
+ private String runtimeArtifacts;
+
+ /**
+ * Runs this mojo.
+ *
+ * @throws MojoExecutionException If the output file could not be created or any dependency could not be resolved.
+ */
+ public void execute()
+ throws MojoExecutionException
+ {
+ try
+ {
+ writeArtifacts( projectArtifacts, project.getArtifacts() );
+ writeArtifacts( runtimeArtifacts, project.getRuntimeArtifacts() );
+
+ // NOTE: We can't make any assumptions about the class path but as a minimum it must not cause an exception
+ project.getRuntimeClasspathElements();
+ }
+ catch ( DependencyResolutionRequiredException e )
+ {
+ throw new MojoExecutionException( "Failed to resolve dependencies", e );
+ }
+ }
+
+}
diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/java/org/apache/maven/plugin/coreit/TestMojo.java b/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/java/org/apache/maven/plugin/coreit/TestMojo.java
new file mode 100644
index 0000000000..8eb479201b
--- /dev/null
+++ b/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/java/org/apache/maven/plugin/coreit/TestMojo.java
@@ -0,0 +1,79 @@
+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.DependencyResolutionRequiredException;
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * Creates text files that list the dependencies with scope test in the order returned from the Maven core.
+ *
+ * @goal test
+ * @requiresDependencyResolution test
+ *
+ * @author Benjamin Bentmann
+ * @version $Id$
+ */
+public class TestMojo
+ extends AbstractDependencyMojo
+{
+
+ /**
+ * The path to the output file for the project artifacts, relative to the project base directory. Each line of this
+ * UTF-8 encoded file specifies an artifact identifier. If not specified, the artifact list will not be written to
+ * disk. Unlike the test artifacts, the collection of project artifacts additionally contains those artifacts that
+ * do not contribute to the class path.
+ *
+ * @parameter expression="${depres.projectArtifacts}"
+ */
+ private String projectArtifacts;
+
+ /**
+ * The path to the output file for the test artifacts, relative to the project base directory. Each line of this
+ * UTF-8 encoded file specifies an artifact identifier. If not specified, the artifact list will not be written to
+ * disk.
+ *
+ * @parameter expression="${depres.testArtifacts}"
+ */
+ private String testArtifacts;
+
+ /**
+ * Runs this mojo.
+ *
+ * @throws MojoExecutionException If the output file could not be created or any dependency could not be resolved.
+ */
+ public void execute()
+ throws MojoExecutionException
+ {
+ try
+ {
+ writeArtifacts( projectArtifacts, project.getArtifacts() );
+ writeArtifacts( testArtifacts, project.getTestArtifacts() );
+
+ // NOTE: We can't make any assumptions about the class path but as a minimum it must not cause an exception
+ project.getTestClasspathElements();
+ }
+ catch ( DependencyResolutionRequiredException e )
+ {
+ throw new MojoExecutionException( "Failed to resolve dependencies", e );
+ }
+ }
+
+}
diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/resources/META-INF/maven/plugin.xml b/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/resources/META-INF/maven/plugin.xml
new file mode 100644
index 0000000000..6af6520fdc
--- /dev/null
+++ b/its/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/resources/META-INF/maven/plugin.xml
@@ -0,0 +1,279 @@
+
+
+ A test plugin that provides several goals which employ @requiresDependencyCollection with different scopes. If
+ desired, the resulting artifact identifiers can be written to a text file.
+ org.apache.maven.its.plugins
+ maven-it-plugin-dependency-collection
+ 2.1-SNAPSHOT
+ itdependency-collection
+ false
+ true
+
+
+ compile
+ Creates text files that list the dependencies with scope compile in the order returned from the Maven core.
+ compile
+ false
+ true
+ false
+ false
+ false
+ true
+ org.apache.maven.plugin.coreit.CompileMojo
+ java
+ per-lookup
+ once-per-session
+
+
+ compileArtifacts
+ java.lang.String
+ false
+ true
+ The path to the output file for the compile artifacts, relative to the project base directory. Each line of this
+UTF-8 encoded file specifies an artifact identifier. If not specified, the artifact list will not be written to
+disk.
+
+
+ project
+ org.apache.maven.project.MavenProject
+ true
+ false
+ The current Maven project.
+
+
+ projectArtifacts
+ java.lang.String
+ false
+ true
+ The path to the output file for the project artifacts, relative to the project base directory. Each line of this
+UTF-8 encoded file specifies an artifact identifier. If not specified, the artifact list will not be written to
+disk. Unlike the compile artifacts, the collection of project artifacts additionally contains those artifacts
+that do not contribute to the class path.
+
+
+
+
+ ${depres.compileArtifacts}
+ ${depres.projectArtifacts}
+
+
+
+ aggregate-test
+ Combines dependency collection with aggregation. The path parameters of this mojo support the token
+<code>@artifactId@</code> to dynamically adjust the output file for each project in the reactor whose
+dependencies are dumped.
+ test
+ false
+ true
+ false
+ true
+ false
+ true
+ org.apache.maven.plugin.coreit.AggregateTestMojo
+ java
+ per-lookup
+ once-per-session
+
+
+ project
+ org.apache.maven.project.MavenProject
+ true
+ false
+ The current Maven project.
+
+
+ projectArtifacts
+ java.lang.String
+ false
+ true
+ The path to the output file for the project artifacts, relative to the project base directory. Each line of this
+UTF-8 encoded file specifies an artifact identifier. If not specified, the artifact list will not be written to
+disk. Unlike the test artifacts, the collection of project artifacts additionally contains those artifacts that
+do not contribute to the class path.
+
+
+ reactorProjects
+ java.util.List
+ false
+ false
+ The Maven projects in the reactor.
+
+
+
+
+ ${depres.projectArtifacts}
+
+
+
+
+ test
+ Creates text files that list the dependencies with scope test in the order returned from the Maven core.
+ test
+ false
+ true
+ false
+ false
+ false
+ true
+ org.apache.maven.plugin.coreit.TestMojo
+ java
+ per-lookup
+ once-per-session
+
+
+ project
+ org.apache.maven.project.MavenProject
+ true
+ false
+ The current Maven project.
+
+
+ projectArtifacts
+ java.lang.String
+ false
+ true
+ The path to the output file for the project artifacts, relative to the project base directory. Each line of this
+UTF-8 encoded file specifies an artifact identifier. If not specified, the artifact list will not be written to
+disk. Unlike the test artifacts, the collection of project artifacts additionally contains those artifacts that
+do not contribute to the class path.
+
+
+ testArtifacts
+ java.lang.String
+ false
+ true
+ The path to the output file for the test artifacts, relative to the project base directory. Each line of this
+UTF-8 encoded file specifies an artifact identifier. If not specified, the artifact list will not be written to
+disk.
+
+
+
+
+ ${depres.projectArtifacts}
+ ${depres.testArtifacts}
+
+
+
+ runtime
+ Creates text files that list the dependencies with scope runtime in the order returned from the Maven core.
+ runtime
+ false
+ true
+ false
+ false
+ false
+ true
+ org.apache.maven.plugin.coreit.RuntimeMojo
+ java
+ per-lookup
+ once-per-session
+
+
+ project
+ org.apache.maven.project.MavenProject
+ true
+ false
+ The current Maven project.
+
+
+ projectArtifacts
+ java.lang.String
+ false
+ true
+ The path to the output file for the project artifacts, relative to the project base directory. Each line of this
+UTF-8 encoded file specifies an artifact identifier. If not specified, the artifact list will not be written to
+disk. Unlike the runtime artifacts, the collection of project artifacts additionally contains those artifacts
+that do not contribute to the class path.
+
+
+ runtimeArtifacts
+ java.lang.String
+ false
+ true
+ The path to the output file for the runtime artifacts, relative to the project base directory. Each line of this
+UTF-8 encoded file specifies an artifact identifier. If not specified, the artifact list will not be written to
+disk.
+
+
+
+
+ ${depres.projectArtifacts}
+ ${depres.runtimeArtifacts}
+
+
+
+
+
+ org.apache.maven
+ maven-plugin-api
+ jar
+ 2.0
+
+
+ org.apache.maven
+ maven-project
+ jar
+ 2.0
+
+
+ org.apache.maven
+ maven-profile
+ jar
+ 2.0
+
+
+ org.apache.maven
+ maven-model
+ jar
+ 2.0
+
+
+ org.codehaus.plexus
+ plexus-utils
+ jar
+ 1.0.4
+
+
+ org.codehaus.plexus
+ plexus-container-default
+ jar
+ 1.0-alpha-8
+
+
+ junit
+ junit
+ jar
+ 3.8.1
+
+
+ classworlds
+ classworlds
+ jar
+ 1.1-alpha-2
+
+
+ org.apache.maven
+ maven-artifact-manager
+ jar
+ 2.0
+
+
+ org.apache.maven
+ maven-repository-metadata
+ jar
+ 2.0
+
+
+ org.apache.maven
+ maven-artifact
+ jar
+ 2.0
+
+
+ org.apache.maven.wagon
+ wagon-provider-api
+ jar
+ 1.0-alpha-5
+
+
+
\ No newline at end of file
diff --git a/its/core-it-support/core-it-plugins/pom.xml b/its/core-it-support/core-it-plugins/pom.xml
index b4a662ce45..857cc56b40 100644
--- a/its/core-it-support/core-it-plugins/pom.xml
+++ b/its/core-it-support/core-it-plugins/pom.xml
@@ -38,6 +38,7 @@ under the License.
maven-it-plugin-configuration
maven-it-plugin-context-passing
maven-it-plugin-core-stubs
+ maven-it-plugin-dependency-collection
maven-it-plugin-dependency-resolution
maven-it-plugin-expression
maven-it-plugin-error