Author: bentmann
Date: Wed Dec 30 11:49:56 2009
New Revision: 894596
URL: http://svn.apache.org/viewvc?rev=894596&view=rev
Log:
[MSHADE-70] Artifact filter does not recognize pattern ending with slash
Added:
maven/plugins/trunk/maven-shade-plugin/src/test/java/org/apache/maven/plugins/shade/filter/
maven/plugins/trunk/maven-shade-plugin/src/test/java/org/apache/maven/plugins/shade/filter/SimpleFilterTest.java
(with props)
Modified:
maven/plugins/trunk/maven-shade-plugin/src/it/filter-artifact-contents/pom.xml
maven/plugins/trunk/maven-shade-plugin/src/it/filter-artifact-contents/repo/org/apache/maven/its/shade/fac/b/0.1/b-0.1-client.jar
maven/plugins/trunk/maven-shade-plugin/src/it/filter-artifact-contents/verify.bsh
maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/filter/SimpleFilter.java
Modified:
maven/plugins/trunk/maven-shade-plugin/src/it/filter-artifact-contents/pom.xml
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/filter-artifact-contents/pom.xml?rev=894596&r1=894595&r2=894596&view=diff
==============================================================================
---
maven/plugins/trunk/maven-shade-plugin/src/it/filter-artifact-contents/pom.xml
(original)
+++
maven/plugins/trunk/maven-shade-plugin/src/it/filter-artifact-contents/pom.xml
Wed Dec 30 11:49:56 2009
@@ -85,6 +85,7 @@
<artifact>org.apache.maven.its.shade.fac:b:client</artifact>
<excludes>
<exclude>org/apache/*</exclude>
+ <exclude>org/apache/maven/b/</exclude>
</excludes>
</filter>
<filter>
Modified:
maven/plugins/trunk/maven-shade-plugin/src/it/filter-artifact-contents/repo/org/apache/maven/its/shade/fac/b/0.1/b-0.1-client.jar
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/filter-artifact-contents/repo/org/apache/maven/its/shade/fac/b/0.1/b-0.1-client.jar?rev=894596&r1=894595&r2=894596&view=diff
==============================================================================
Binary files - no diff available.
Modified:
maven/plugins/trunk/maven-shade-plugin/src/it/filter-artifact-contents/verify.bsh
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/filter-artifact-contents/verify.bsh?rev=894596&r1=894595&r2=894596&view=diff
==============================================================================
---
maven/plugins/trunk/maven-shade-plugin/src/it/filter-artifact-contents/verify.bsh
(original)
+++
maven/plugins/trunk/maven-shade-plugin/src/it/filter-artifact-contents/verify.bsh
Wed Dec 30 11:49:56 2009
@@ -16,6 +16,7 @@
"org/a.properties",
"org/b.properties",
"org/apache/b.properties",
+ "org/apache/maven/b/b.properties",
};
JarFile jarFile = new JarFile( new File( basedir, "target/test-1.0.jar" ) );
Modified:
maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/filter/SimpleFilter.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/filter/SimpleFilter.java?rev=894596&r1=894595&r2=894596&view=diff
==============================================================================
---
maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/filter/SimpleFilter.java
(original)
+++
maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/filter/SimpleFilter.java
Wed Dec 30 11:49:56 2009
@@ -41,7 +41,7 @@
public SimpleFilter( Set jars, Set includes, Set excludes )
{
- this.jars = new HashSet( jars );
+ this.jars = ( jars != null ) ? new HashSet( jars ) : new HashSet();
this.includes = normalizePatterns( includes );
this.excludes = normalizePatterns( excludes );
}
@@ -95,7 +95,7 @@
private String normalizePath( String path )
{
- return ( path != null ) ? path.replace( '/', File.separatorChar
).replace( '\\', File.separatorChar ) : null;
+ return ( path != null ) ? path.replace( File.separatorChar == '/' ?
'\\' : '/', File.separatorChar ) : null;
}
private Set normalizePatterns( Set patterns )
@@ -107,7 +107,15 @@
for ( Iterator it = patterns.iterator(); it.hasNext(); )
{
String pattern = (String) it.next();
- result.add( normalizePath( pattern ) );
+
+ pattern = normalizePath( pattern );
+
+ if ( pattern.endsWith( File.separator ) )
+ {
+ pattern += "**";
+ }
+
+ result.add( pattern );
}
}
Added:
maven/plugins/trunk/maven-shade-plugin/src/test/java/org/apache/maven/plugins/shade/filter/SimpleFilterTest.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/test/java/org/apache/maven/plugins/shade/filter/SimpleFilterTest.java?rev=894596&view=auto
==============================================================================
---
maven/plugins/trunk/maven-shade-plugin/src/test/java/org/apache/maven/plugins/shade/filter/SimpleFilterTest.java
(added)
+++
maven/plugins/trunk/maven-shade-plugin/src/test/java/org/apache/maven/plugins/shade/filter/SimpleFilterTest.java
Wed Dec 30 11:49:56 2009
@@ -0,0 +1,77 @@
+package org.apache.maven.plugins.shade.filter;
+
+/*
+ * 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.Collections;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Benjamin Bentmann
+ */
+public class SimpleFilterTest
+ extends TestCase
+{
+
+ public void testIsFiltered()
+ {
+ SimpleFilter filter;
+
+ filter = new SimpleFilter( null, null, null );
+ assertFalse( filter.isFiltered( "a.properties" ) );
+ assertFalse( filter.isFiltered( "org/Test.class" ) );
+
+ filter = new SimpleFilter( null, Collections.EMPTY_SET,
Collections.EMPTY_SET );
+ assertFalse( filter.isFiltered( "a.properties" ) );
+ assertFalse( filter.isFiltered( "org/Test.class" ) );
+
+ filter = new SimpleFilter( null, Collections.singleton(
"org/Test.class" ), Collections.EMPTY_SET );
+ assertTrue( filter.isFiltered( "a.properties" ) );
+ assertFalse( filter.isFiltered( "org/Test.class" ) );
+ assertTrue( filter.isFiltered( "org/Test.properties" ) );
+
+ filter = new SimpleFilter( null, Collections.EMPTY_SET,
Collections.singleton( "org/Test.class" ) );
+ assertFalse( filter.isFiltered( "a.properties" ) );
+ assertTrue( filter.isFiltered( "org/Test.class" ) );
+ assertFalse( filter.isFiltered( "org/Test.properties" ) );
+
+ filter = new SimpleFilter( null, Collections.singleton(
"**/a.properties" ), Collections.EMPTY_SET );
+ assertFalse( filter.isFiltered( "a.properties" ) );
+ assertFalse( filter.isFiltered( "org/a.properties" ) );
+ assertFalse( filter.isFiltered( "org/maven/a.properties" ) );
+ assertTrue( filter.isFiltered( "org/maven/a.class" ) );
+
+ filter = new SimpleFilter( null, Collections.EMPTY_SET,
Collections.singleton( "org/*" ) );
+ assertFalse( filter.isFiltered( "Test.class" ) );
+ assertTrue( filter.isFiltered( "org/Test.class" ) );
+ assertFalse( filter.isFiltered( "org/apache/Test.class" ) );
+
+ filter = new SimpleFilter( null, Collections.EMPTY_SET,
Collections.singleton( "org/**" ) );
+ assertFalse( filter.isFiltered( "Test.class" ) );
+ assertTrue( filter.isFiltered( "org/Test.class" ) );
+ assertTrue( filter.isFiltered( "org/apache/Test.class" ) );
+
+ filter = new SimpleFilter( null, Collections.EMPTY_SET,
Collections.singleton( "org/" ) );
+ assertFalse( filter.isFiltered( "Test.class" ) );
+ assertTrue( filter.isFiltered( "org/Test.class" ) );
+ assertTrue( filter.isFiltered( "org/apache/Test.class" ) );
+ }
+
+}
Propchange:
maven/plugins/trunk/maven-shade-plugin/src/test/java/org/apache/maven/plugins/shade/filter/SimpleFilterTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/plugins/trunk/maven-shade-plugin/src/test/java/org/apache/maven/plugins/shade/filter/SimpleFilterTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision