maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r637892 - in /maven/plugins/trunk/maven-remote-resources-plugin: pom.xml src/main/java/org/apache/maven/plugin/resources/remote/ProcessRemoteResourcesMojo.java
Date Mon, 17 Mar 2008 14:02:23 GMT
Author: dkulp
Date: Mon Mar 17 07:02:12 2008
New Revision: 637892

URL: http://svn.apache.org/viewvc?rev=637892&view=rev
Log:
[MRRESOURCES-22] Provide "excludes" for artifacts that are passed into velocity
[MRRESOURCES-23] Introduce a parameter to define the scopes of the libraries to be included
in the NOTICE licensing.

Copied some code from the dependency plugin to handle the above.  Very easy.  Should have
been done a long time ago. :-)

Modified:
    maven/plugins/trunk/maven-remote-resources-plugin/pom.xml
    maven/plugins/trunk/maven-remote-resources-plugin/src/main/java/org/apache/maven/plugin/resources/remote/ProcessRemoteResourcesMojo.java

Modified: maven/plugins/trunk/maven-remote-resources-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-remote-resources-plugin/pom.xml?rev=637892&r1=637891&r2=637892&view=diff
==============================================================================
--- maven/plugins/trunk/maven-remote-resources-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-remote-resources-plugin/pom.xml Mon Mar 17 07:02:12 2008
@@ -80,6 +80,11 @@
       <artifactId>velocity-dep</artifactId>
       <version>1.4</version>
     </dependency>
+    <dependency>
+        <groupId>org.apache.maven.shared</groupId>
+        <artifactId>maven-common-artifact-filters</artifactId>
+        <version>1.0</version>
+    </dependency>
 
     <dependency>
       <groupId>org.apache.maven.shared</groupId>

Modified: maven/plugins/trunk/maven-remote-resources-plugin/src/main/java/org/apache/maven/plugin/resources/remote/ProcessRemoteResourcesMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-remote-resources-plugin/src/main/java/org/apache/maven/plugin/resources/remote/ProcessRemoteResourcesMojo.java?rev=637892&r1=637891&r2=637892&view=diff
==============================================================================
--- maven/plugins/trunk/maven-remote-resources-plugin/src/main/java/org/apache/maven/plugin/resources/remote/ProcessRemoteResourcesMojo.java
(original)
+++ maven/plugins/trunk/maven-remote-resources-plugin/src/main/java/org/apache/maven/plugin/resources/remote/ProcessRemoteResourcesMojo.java
Mon Mar 17 07:02:12 2008
@@ -41,6 +41,14 @@
 import org.apache.maven.project.ProjectUtils;
 import org.apache.maven.project.inheritance.ModelInheritanceAssembler;
 import org.apache.maven.reporting.MavenReportException;
+import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException;
+import org.apache.maven.shared.artifact.filter.collection.ArtifactIdFilter;
+import org.apache.maven.shared.artifact.filter.collection.ClassifierFilter;
+import org.apache.maven.shared.artifact.filter.collection.FilterArtifacts;
+import org.apache.maven.shared.artifact.filter.collection.GroupIdFilter;
+import org.apache.maven.shared.artifact.filter.collection.ScopeFilter;
+import org.apache.maven.shared.artifact.filter.collection.TransitivityFilter;
+import org.apache.maven.shared.artifact.filter.collection.TypeFilter;
 import org.apache.maven.shared.downloader.DownloadException;
 import org.apache.maven.shared.downloader.DownloadNotFoundException;
 import org.apache.maven.shared.downloader.Downloader;
@@ -77,6 +85,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.TreeMap;
 
 /**
@@ -96,7 +105,7 @@
  * </p>
  *
  * @goal process
- * @requiresDependencyResolution runtime
+ * @requiresDependencyResolution test
  * @phase generate-resources
  */
 public class ProcessRemoteResourcesMojo
@@ -106,6 +115,8 @@
      * The local repository taken from Maven's runtime. Typically $HOME/.m2/repository.
      *
      * @parameter expression="${localRepository}"
+     * @readonly
+     * @required
      */
     private ArtifactRepository localRepository;
 
@@ -113,6 +124,8 @@
      * The remote repositories used as specified in your POM.
      *
      * @parameter expression="${project.repositories}"
+     * @readonly
+     * @required
      */
     private List repositories;
 
@@ -129,6 +142,8 @@
      * The current Maven project.
      *
      * @parameter expression="${project}"
+     * @readonly
+     * @required
      */
     private MavenProject project;
 
@@ -169,6 +184,8 @@
      * incomplete POM metadata.
      *
      * @component
+     * @readonly
+     * @required
      */
     private ModelInheritanceAssembler inheritanceAssembler;
 
@@ -215,6 +232,7 @@
      * The list of resources defined for the project.
      *
      * @parameter expression="${project.resources}"
+     * @readonly
      * @required
      */
     private List resources;
@@ -223,6 +241,8 @@
      * Artifact downloader.
      *
      * @component
+     * @readonly
+     * @required
      */
     private Downloader downloader;
 
@@ -230,6 +250,8 @@
      * Velocity component.
      *
      * @component
+     * @readonly
+     * @required
      */
     private VelocityComponent velocity;
 
@@ -242,6 +264,8 @@
      * Artifact repository factory component.
      *
      * @component
+     * @readonly
+     * @required
      */
     private ArtifactRepositoryFactory artifactRepositoryFactory;
 
@@ -249,6 +273,8 @@
      * Artifact factory, needed to create artifacts.
      *
      * @component
+     * @readonly
+     * @required
      */
     private ArtifactFactory artifactFactory;
 
@@ -256,6 +282,8 @@
      * The Maven session.
      *
      * @parameter expression="${session}"
+     * @readonly
+     * @required
      */
     private MavenSession mavenSession;
 
@@ -274,6 +302,70 @@
      * @readonly
      */
     private ResourceManager locator;
+    
+    
+    /**
+     * Scope to include. An Empty string indicates all scopes (default).
+     * 
+     * @since 1.0
+     * @parameter expression="${includeScope}" default-value="runtime"
+     * @optional
+     */
+    protected String includeScope;
+
+    /**
+     * Scope to exclude. An Empty string indicates no scopes (default).
+     * 
+     * @since 1.0
+     * @parameter expression="${excludeScope}" default-value=""
+     * @optional
+     */
+    protected String excludeScope;
+    
+    /**
+     * Comma separated list of Artifact names too exclude.
+     * 
+     * @since 1.0
+     * @optional
+     * @parameter expression="${excludeArtifactIds}" default-value=""
+     */
+    protected String excludeArtifactIds;
+
+    /**
+     * Comma separated list of Artifact names to include.
+     * 
+     * @since 1.0
+     * @optional
+     * @parameter expression="${includeArtifactIds}" default-value=""
+     */
+    protected String includeArtifactIds;
+
+    /**
+     * Comma separated list of GroupId Names to exclude.
+     * 
+     * @since 1.0
+     * @optional
+     * @parameter expression="${excludeGroupIds}" default-value=""
+     */
+    protected String excludeGroupIds;
+
+    /**
+     * Comma separated list of GroupIds to include.
+     * 
+     * @since 1.0
+     * @optional
+     * @parameter expression="${includeGroupIds}" default-value=""
+     */
+    protected String includeGroupIds;
+
+    /**
+     * If we should exclude transitive dependencies
+     * 
+     * @since 1.0
+     * @optional
+     * @parameter expression="${excludeTransitive}" default-value="false"
+     */
+    protected boolean excludeTransitive;
 
     public void execute()
         throws MojoExecutionException
@@ -367,8 +459,29 @@
         throws MojoExecutionException
     {
         List projects = new ArrayList();
+        
+        // add filters in well known order, least specific to most specific
+        FilterArtifacts filter = new FilterArtifacts();
+
+        filter.addFilter( new TransitivityFilter( project.getDependencyArtifacts(), this.excludeTransitive
) );
+        filter.addFilter( new ScopeFilter( this.includeScope, this.excludeScope ) );
+        filter.addFilter( new GroupIdFilter( this.includeGroupIds, this.excludeGroupIds )
);
+        filter.addFilter( new ArtifactIdFilter( this.includeArtifactIds, this.excludeArtifactIds
) );
+
+        // start with all artifacts.
+        Set artifacts = project.getArtifacts();
+        // perform filtering
+        try
+        {
+            artifacts = filter.filter( artifacts );
+        }
+        catch ( ArtifactFilterException e )
+        {
+            throw new MojoExecutionException(e.getMessage(),e);
+        }
+
 
-        for ( Iterator it = project.getArtifacts().iterator(); it.hasNext(); )
+        for ( Iterator it = artifacts.iterator(); it.hasNext(); )
         {
             Artifact artifact = (Artifact) it.next();
             try



Mime
View raw message