maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dant...@apache.org
Subject svn commit: r894970 - in /maven/plugins/trunk/maven-dependency-plugin/src: main/java/org/apache/maven/plugin/dependency/ main/java/org/apache/maven/plugin/dependency/fromConfiguration/ main/java/org/apache/maven/plugin/dependency/utils/ test/java/org/a...
Date Fri, 01 Jan 2010 04:08:00 GMT
Author: dantran
Date: Fri Jan  1 04:08:00 2010
New Revision: 894970

URL: http://svn.apache.org/viewvc?rev=894970&view=rev
Log:
[MDEP-235] Better handling of comma separated string configurations

Modified:
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyFilterMojo.java
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/UnpackDependenciesMojo.java
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/ArtifactItem.java
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/DependencyUtil.java
    maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/TestDependencyUtil.java

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyFilterMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyFilterMojo.java?rev=894970&r1=894969&r2=894970&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyFilterMojo.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyFilterMojo.java
Fri Jan  1 04:08:00 2010
@@ -1,22 +1,18 @@
 package org.apache.maven.plugin.dependency;
 
 /*
- * 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
- *
+ * 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.    
+ * 
+ * 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.io.File;
@@ -25,6 +21,7 @@
 
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.dependency.utils.DependencyStatusSets;
+import org.apache.maven.plugin.dependency.utils.DependencyUtil;
 import org.apache.maven.plugin.dependency.utils.resolvers.ArtifactsResolver;
 import org.apache.maven.plugin.dependency.utils.resolvers.DefaultArtifactsResolver;
 import org.apache.maven.plugin.dependency.utils.translators.ArtifactTranslator;
@@ -218,7 +215,8 @@
      * @return A HashSet of artifacts
      * @throws MojoExecutionException 
      */
-    protected Set getResolvedDependencies( boolean stopOnFailure )throws MojoExecutionException
+    protected Set getResolvedDependencies( boolean stopOnFailure )
+        throws MojoExecutionException
 
     {
         DependencyStatusSets status = getDependencySets( stopOnFailure );
@@ -244,11 +242,21 @@
         FilterArtifacts filter = new FilterArtifacts();
 
         filter.addFilter( new TransitivityFilter( project.getDependencyArtifacts(), this.excludeTransitive
) );
-        filter.addFilter( new ScopeFilter( this.includeScope, this.excludeScope ) );
-        filter.addFilter( new TypeFilter( this.includeTypes, this.excludeTypes ) );
-        filter.addFilter( new ClassifierFilter( this.includeClassifiers, this.excludeClassifiers
) );
-        filter.addFilter( new GroupIdFilter( this.includeGroupIds, this.excludeGroupIds )
);
-        filter.addFilter( new ArtifactIdFilter( this.includeArtifactIds, this.excludeArtifactIds
) );
+
+        filter.addFilter( new ScopeFilter( DependencyUtil.cleanToBeTokenizedString( this.includeScope
), DependencyUtil
+            .cleanToBeTokenizedString( this.excludeScope ) ) );
+
+        filter.addFilter( new TypeFilter( DependencyUtil.cleanToBeTokenizedString( this.includeTypes
), DependencyUtil
+            .cleanToBeTokenizedString( this.excludeTypes ) ) );
+
+        filter.addFilter( new ClassifierFilter( DependencyUtil.cleanToBeTokenizedString(
this.includeClassifiers ),
+                                                DependencyUtil.cleanToBeTokenizedString(
this.excludeClassifiers ) ) );
+
+        filter.addFilter( new GroupIdFilter( DependencyUtil.cleanToBeTokenizedString( this.includeGroupIds
),
+                                             DependencyUtil.cleanToBeTokenizedString( this.excludeGroupIds
) ) );
+
+        filter.addFilter( new ArtifactIdFilter( DependencyUtil.cleanToBeTokenizedString(
this.includeArtifactIds ),
+                                                DependencyUtil.cleanToBeTokenizedString(
this.excludeArtifactIds ) ) );
 
         // start with all artifacts.
         Set artifacts = project.getArtifacts();
@@ -260,7 +268,7 @@
         }
         catch ( ArtifactFilterException e )
         {
-            throw new MojoExecutionException(e.getMessage(),e);
+            throw new MojoExecutionException( e.getMessage(), e );
         }
 
         // transform artifacts if classifier is set
@@ -346,7 +354,7 @@
         }
         catch ( ArtifactFilterException e )
         {
-            throw new MojoExecutionException(e.getMessage(),e);
+            throw new MojoExecutionException( e.getMessage(), e );
         }
 
         // calculate the skipped artifacts

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/UnpackDependenciesMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/UnpackDependenciesMojo.java?rev=894970&r1=894969&r2=894970&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/UnpackDependenciesMojo.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/UnpackDependenciesMojo.java
Fri Jan  1 04:08:00 2010
@@ -111,7 +111,7 @@
      */
     public String getExcludes ()
     {
-        return this.excludes;
+        return DependencyUtil.cleanToBeTokenizedString( this.excludes );
     }
     
     /**
@@ -125,16 +125,16 @@
     }
     
     /**
-     * @return Returns a comma seperated list of included items
+     * @return Returns a comma separated list of included items
      */
     public String getIncludes()
     {
-    	return this.includes;
+        return DependencyUtil.cleanToBeTokenizedString( this.includes );
     }
 
     /**
      * @param includes
-     * 			A comma seperated list of items to inmclude 
+     * 			A comma separated list of items to include 
      * 			i.e.  **\/*.xml, **\/*.properties
      */
     public void setIncludes ( String includes )

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/ArtifactItem.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/ArtifactItem.java?rev=894970&r1=894969&r2=894970&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/ArtifactItem.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/ArtifactItem.java
Fri Jan  1 04:08:00 2010
@@ -22,6 +22,7 @@
 import java.io.File;
 
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.dependency.utils.DependencyUtil;
 import org.codehaus.plexus.util.StringUtils;
 
 /**
@@ -328,7 +329,7 @@
      */
     public String getExcludes ()
     {
-        return this.excludes;
+        return DependencyUtil.cleanToBeTokenizedString( this.excludes );
     }
     
     /**
@@ -346,7 +347,7 @@
      */
     public String getIncludes()
     {
-    	return this.includes;
+    	return DependencyUtil.cleanToBeTokenizedString( this.includes );
     }
 
     /**

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/DependencyUtil.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/DependencyUtil.java?rev=894970&r1=894969&r2=894970&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/DependencyUtil.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/DependencyUtil.java
Fri Jan  1 04:08:00 2010
@@ -226,4 +226,26 @@
 
         reader.close();
     }
+
+    //
+    // mainly used to parse excludes,includes configuration
+    //
+    public static String [] tokenizer( String str )
+    {
+        return StringUtils.split( cleanToBeTokenizedString( str ), "," );
+    }
+    
+    //
+    // clean up configuration string before it can be tokenized
+    //
+    public static String cleanToBeTokenizedString( String str )
+    {
+        String ret = "";
+        if ( ! StringUtils.isEmpty( str ) )
+        {
+            ret = StringUtils.join( StringUtils.split( str ), "," );
+        }
+        
+        return ret;
+    }    
 }

Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/TestDependencyUtil.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/TestDependencyUtil.java?rev=894970&r1=894969&r2=894970&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/TestDependencyUtil.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/TestDependencyUtil.java
Fri Jan  1 04:08:00 2010
@@ -259,4 +259,20 @@
         assertEquals( expectedResult, name );
 
     }
+    
+    public void testTokenizer()
+    {
+        
+        String [] tokens = DependencyUtil.tokenizer( " \r\n a, \t \n \r b \t \n \r" );
+        assertEquals( 2, tokens.length );
+        assertEquals( "a", tokens[0] );
+        assertEquals( "b", tokens[1] );
+        
+        tokens = DependencyUtil.tokenizer( null );
+        assertEquals( 0, tokens.length );
+        
+        tokens = DependencyUtil.tokenizer( "  " );
+        assertEquals( 0, tokens.length );
+        
+    }
 }



Mime
View raw message