Return-Path: Delivered-To: apmail-maven-commits-archive@www.apache.org Received: (qmail 88854 invoked from network); 1 Jan 2010 08:42:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 1 Jan 2010 08:42:35 -0000 Received: (qmail 9312 invoked by uid 500); 1 Jan 2010 08:42:35 -0000 Delivered-To: apmail-maven-commits-archive@maven.apache.org Received: (qmail 9195 invoked by uid 500); 1 Jan 2010 08:42:35 -0000 Mailing-List: contact commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list commits@maven.apache.org Received: (qmail 9185 invoked by uid 99); 1 Jan 2010 08:42:35 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Jan 2010 08:42:35 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Jan 2010 08:42:34 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4071723888D1; Fri, 1 Jan 2010 08:42:14 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r894980 - in /maven/plugins/trunk/maven-dependency-plugin/src: it/copy-dependencies/ main/java/org/apache/maven/plugin/dependency/ main/java/org/apache/maven/plugin/dependency/fromConfiguration/ main/java/org/apache/maven/plugin/dependency/... Date: Fri, 01 Jan 2010 08:42:14 -0000 To: commits@maven.apache.org From: dantran@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100101084214.4071723888D1@eris.apache.org> Author: dantran Date: Fri Jan 1 08:42:13 2010 New Revision: 894980 URL: http://svn.apache.org/viewvc?rev=894980&view=rev Log: [MDEP-235] Better handling of comma separated string configurations. IT added Modified: maven/plugins/trunk/maven-dependency-plugin/src/it/copy-dependencies/pom.xml 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/it/copy-dependencies/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/copy-dependencies/pom.xml?rev=894980&r1=894979&r2=894980&view=diff ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/it/copy-dependencies/pom.xml (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/it/copy-dependencies/pom.xml Fri Jan 1 08:42:13 2010 @@ -73,7 +73,11 @@ copy-dependencies - sources,javadoc + + + sources, + javadoc + ${project.build.directory}/it/copy-dep-test-2 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=894980&r1=894979&r2=894980&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 08:42:13 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 ProjectTransitivityFilter( 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=894980&r1=894979&r2=894980&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 08:42:13 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=894980&r1=894979&r2=894980&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 08:42:13 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=894980&r1=894979&r2=894980&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 08:42:13 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=894980&r1=894979&r2=894980&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 08:42:13 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 ); + + } }