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 2009/08/25 15:41:42 UTC

svn commit: r807623 - /maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/AggregateTestMojo.java

Author: bentmann
Date: Tue Aug 25 13:41:42 2009
New Revision: 807623

URL: http://svn.apache.org/viewvc?rev=807623&view=rev
Log:
o Added mojo to test dependency resolution + aggregation

Added:
    maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/AggregateTestMojo.java   (with props)

Added: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/AggregateTestMojo.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/AggregateTestMojo.java?rev=807623&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/AggregateTestMojo.java (added)
+++ maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/AggregateTestMojo.java Tue Aug 25 13:41:42 2009
@@ -0,0 +1,118 @@
+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 resolution with aggregation. The path parameters of this mojo support the token
+ * <code>&#64;artifactId&#64;</code> 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 path to the output file for the test class path, relative to the project base directory. Each line of
+     * this UTF-8 encoded file specifies the absolute path to a class path element. If not specified, the class path
+     * will not be written to disk.
+     * 
+     * @parameter expression="${depres.testClassPath}"
+     */
+    private String testClassPath;
+
+    /**
+     * The path to the properties file for the checksums of the test class path elements, relative to the project base
+     * directory. The (trimmed) path to a JAR is used as the property key, the property value is the SHA-1 hash of the
+     * JAR. If not specified, the class path checksums will not be calculated.
+     * 
+     * @parameter expression="${depres.testClassPathChecksums}"
+     */
+    private String testClassPathChecksums;
+
+    /**
+     * 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() );
+                writeClassPath( filter( testClassPath, project ), project.getTestClasspathElements() );
+                writeClassPathChecksums( filter( testClassPathChecksums, project ), 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;
+    }
+
+}

Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/AggregateTestMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/AggregateTestMojo.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision