You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2019/05/01 19:07:46 UTC

[maven-shade-plugin] branch master updated: [MSHADE-316] Configuration option New configuration option (default: true) When set to false providing an will NOT automatically exclude all other files anymore.

This is an automated email from the ASF dual-hosted git repository.

rfscholte pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 2f6663c  [MSHADE-316] Configuration option <excludeDefaults> New configuration option <excludeDefaults> (default: true) When set to false providing an <include> will NOT automatically exclude all other files anymore.
2f6663c is described below

commit 2f6663c725d5b7fd42a177d530eb3577f370f323
Author: rfscholte <rf...@apache.org>
AuthorDate: Wed May 1 21:07:35 2019 +0200

    [MSHADE-316] Configuration option <excludeDefaults>
    New configuration option <excludeDefaults> (default: true)
    When set to false providing an <include> will NOT automatically
    exclude all other files anymore.
    
    Signed-off-by: Markus KARG <ma...@headcrashing.eu>
---
 src/it/MSHADE-316/dependency/pom.xml               | 28 ++++++++
 .../dependency/src/main/java/SomeUnusedClass.java} | 29 +--------
 .../dependency/src/main/java/SomeUsedClass.java}   | 29 +--------
 .../src/main/java/x/y/z/AnotherExemptedClass.java} | 29 +--------
 .../src/main/java/x/y/z/SomeExemptedClass.java}    | 29 +--------
 src/it/MSHADE-316/invoker.properties               | 19 ++++++
 src/it/MSHADE-316/pom.xml                          | 39 +++++++++++
 src/it/MSHADE-316/test/pom.xml                     | 75 ++++++++++++++++++++++
 .../MSHADE-316/test/src/main/java/Main.java}       | 30 ++-------
 .../MSHADE-316/verify.bsh}                         | 44 +++++++------
 .../maven/plugins/shade/filter/SimpleFilter.java   | 35 +++++++++-
 .../maven/plugins/shade/mojo/ArchiveFilter.java    |  7 ++
 .../apache/maven/plugins/shade/mojo/ShadeMojo.java |  6 +-
 src/site/apt/examples/includes-excludes.apt.vm     | 18 ++++--
 .../plugins/shade/filter/SimpleFilterTest.java     | 19 ++++++
 15 files changed, 271 insertions(+), 165 deletions(-)

diff --git a/src/it/MSHADE-316/dependency/pom.xml b/src/it/MSHADE-316/dependency/pom.xml
new file mode 100644
index 0000000..a19099b
--- /dev/null
+++ b/src/it/MSHADE-316/dependency/pom.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<project>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.shade.mj</groupId>
+  <artifactId>dependency</artifactId>
+  <version>1.0</version>
+</project>
diff --git a/src/main/java/org/apache/maven/plugins/shade/mojo/ArchiveFilter.java b/src/it/MSHADE-316/dependency/src/main/java/SomeUnusedClass.java
similarity index 64%
copy from src/main/java/org/apache/maven/plugins/shade/mojo/ArchiveFilter.java
copy to src/it/MSHADE-316/dependency/src/main/java/SomeUnusedClass.java
index 665510c..fbf234e 100644
--- a/src/main/java/org/apache/maven/plugins/shade/mojo/ArchiveFilter.java
+++ b/src/it/MSHADE-316/dependency/src/main/java/SomeUnusedClass.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.shade.mojo;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -19,31 +17,6 @@ package org.apache.maven.plugins.shade.mojo;
  * under the License.
  */
 
-import java.util.Set;
-
-/**
- * @author David Blevins
- */
-public class ArchiveFilter
+public class SomeUnusedClass
 {
-    private String artifact;
-
-    private Set<String> includes;
-
-    private Set<String> excludes;
-
-    public String getArtifact()
-    {
-        return artifact;
-    }
-
-    public Set<String> getIncludes()
-    {
-        return includes;
-    }
-
-    public Set<String> getExcludes()
-    {
-        return excludes;
-    }
 }
diff --git a/src/main/java/org/apache/maven/plugins/shade/mojo/ArchiveFilter.java b/src/it/MSHADE-316/dependency/src/main/java/SomeUsedClass.java
similarity index 64%
copy from src/main/java/org/apache/maven/plugins/shade/mojo/ArchiveFilter.java
copy to src/it/MSHADE-316/dependency/src/main/java/SomeUsedClass.java
index 665510c..ea5d3a0 100644
--- a/src/main/java/org/apache/maven/plugins/shade/mojo/ArchiveFilter.java
+++ b/src/it/MSHADE-316/dependency/src/main/java/SomeUsedClass.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.shade.mojo;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -19,31 +17,8 @@ package org.apache.maven.plugins.shade.mojo;
  * under the License.
  */
 
-import java.util.Set;
+import java.util.ServiceLoader;
 
-/**
- * @author David Blevins
- */
-public class ArchiveFilter
+public class SomeUsedClass
 {
-    private String artifact;
-
-    private Set<String> includes;
-
-    private Set<String> excludes;
-
-    public String getArtifact()
-    {
-        return artifact;
-    }
-
-    public Set<String> getIncludes()
-    {
-        return includes;
-    }
-
-    public Set<String> getExcludes()
-    {
-        return excludes;
-    }
 }
diff --git a/src/main/java/org/apache/maven/plugins/shade/mojo/ArchiveFilter.java b/src/it/MSHADE-316/dependency/src/main/java/x/y/z/AnotherExemptedClass.java
similarity index 64%
copy from src/main/java/org/apache/maven/plugins/shade/mojo/ArchiveFilter.java
copy to src/it/MSHADE-316/dependency/src/main/java/x/y/z/AnotherExemptedClass.java
index 665510c..473276c 100644
--- a/src/main/java/org/apache/maven/plugins/shade/mojo/ArchiveFilter.java
+++ b/src/it/MSHADE-316/dependency/src/main/java/x/y/z/AnotherExemptedClass.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.shade.mojo;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -19,31 +17,8 @@ package org.apache.maven.plugins.shade.mojo;
  * under the License.
  */
 
-import java.util.Set;
+package x.y.z;
 
-/**
- * @author David Blevins
- */
-public class ArchiveFilter
+public class AnotherExemptedClass
 {
-    private String artifact;
-
-    private Set<String> includes;
-
-    private Set<String> excludes;
-
-    public String getArtifact()
-    {
-        return artifact;
-    }
-
-    public Set<String> getIncludes()
-    {
-        return includes;
-    }
-
-    public Set<String> getExcludes()
-    {
-        return excludes;
-    }
 }
diff --git a/src/main/java/org/apache/maven/plugins/shade/mojo/ArchiveFilter.java b/src/it/MSHADE-316/dependency/src/main/java/x/y/z/SomeExemptedClass.java
similarity index 64%
copy from src/main/java/org/apache/maven/plugins/shade/mojo/ArchiveFilter.java
copy to src/it/MSHADE-316/dependency/src/main/java/x/y/z/SomeExemptedClass.java
index 665510c..f5ee280 100644
--- a/src/main/java/org/apache/maven/plugins/shade/mojo/ArchiveFilter.java
+++ b/src/it/MSHADE-316/dependency/src/main/java/x/y/z/SomeExemptedClass.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.shade.mojo;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -19,31 +17,8 @@ package org.apache.maven.plugins.shade.mojo;
  * under the License.
  */
 
-import java.util.Set;
+package x.y.z;
 
-/**
- * @author David Blevins
- */
-public class ArchiveFilter
+public class SomeExemptedClass
 {
-    private String artifact;
-
-    private Set<String> includes;
-
-    private Set<String> excludes;
-
-    public String getArtifact()
-    {
-        return artifact;
-    }
-
-    public Set<String> getIncludes()
-    {
-        return includes;
-    }
-
-    public Set<String> getExcludes()
-    {
-        return excludes;
-    }
 }
diff --git a/src/it/MSHADE-316/invoker.properties b/src/it/MSHADE-316/invoker.properties
new file mode 100644
index 0000000..f1e7ddb
--- /dev/null
+++ b/src/it/MSHADE-316/invoker.properties
@@ -0,0 +1,19 @@
+# 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.
+
+#jdependency-2.1.1 is Java8 compatible
+invoker.java.version = 1.8+
diff --git a/src/it/MSHADE-316/pom.xml b/src/it/MSHADE-316/pom.xml
new file mode 100644
index 0000000..88a5f81
--- /dev/null
+++ b/src/it/MSHADE-316/pom.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<project>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.shade.mj</groupId>
+  <artifactId>aggregate</artifactId>
+  <version>1.0</version>
+  <packaging>pom</packaging>
+
+  <name>MSHADE-316</name>
+  <description>
+    Prevent minimizeJar from excluding classes explicitly exempted.
+  </description>
+
+  <modules>
+    <module>dependency</module>
+    <module>test</module>
+  </modules>
+</project>
diff --git a/src/it/MSHADE-316/test/pom.xml b/src/it/MSHADE-316/test/pom.xml
new file mode 100644
index 0000000..24fc875
--- /dev/null
+++ b/src/it/MSHADE-316/test/pom.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<project>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.shade.mj</groupId>
+  <artifactId>test</artifactId>
+  <version>1.0</version>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.its.shade.mj</groupId>
+      <artifactId>dependency</artifactId>
+      <version>1.0</version>
+    </dependency>
+
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.3.2</version>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <version>@project.version@</version>
+        <executions>
+          <execution>
+            <id>attach-shade</id>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+            <configuration>
+              <shadedArtifactAttached>false</shadedArtifactAttached>
+              <minimizeJar>true</minimizeJar>
+              <filters>
+                <filter>
+                  <artifact>org.apache.maven.its.shade.mj:dependency</artifact>
+                  <excludeDefaults>false</excludeDefaults>
+                  <includes>
+                    <include>**/SomeExempted*</include>
+                    <include>**\AnotherExempted*</include>
+                  </includes>
+                </filter>
+              </filters>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/main/java/org/apache/maven/plugins/shade/mojo/ArchiveFilter.java b/src/it/MSHADE-316/test/src/main/java/Main.java
similarity index 65%
copy from src/main/java/org/apache/maven/plugins/shade/mojo/ArchiveFilter.java
copy to src/it/MSHADE-316/test/src/main/java/Main.java
index 665510c..26bec4c 100644
--- a/src/main/java/org/apache/maven/plugins/shade/mojo/ArchiveFilter.java
+++ b/src/it/MSHADE-316/test/src/main/java/Main.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.shade.mojo;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -19,31 +17,13 @@ package org.apache.maven.plugins.shade.mojo;
  * under the License.
  */
 
-import java.util.Set;
-
-/**
- * @author David Blevins
- */
-public class ArchiveFilter
+public class Main
 {
-    private String artifact;
-
-    private Set<String> includes;
-
-    private Set<String> excludes;
-
-    public String getArtifact()
-    {
-        return artifact;
-    }
-
-    public Set<String> getIncludes()
-    {
-        return includes;
-    }
+    public SomeUsedClass essentialDependency;
 
-    public Set<String> getExcludes()
+    public static void main( String[] args ) throws ClassNotFoundException
     {
-        return excludes;
+        Class.forName( "x.y.z.SomeExemptedClass" );
+        Class.forName( "x.y.z.AnotherExemptedClass" );
     }
 }
diff --git a/src/main/java/org/apache/maven/plugins/shade/mojo/ArchiveFilter.java b/src/it/MSHADE-316/verify.bsh
similarity index 56%
copy from src/main/java/org/apache/maven/plugins/shade/mojo/ArchiveFilter.java
copy to src/it/MSHADE-316/verify.bsh
index 665510c..04919e0 100644
--- a/src/main/java/org/apache/maven/plugins/shade/mojo/ArchiveFilter.java
+++ b/src/it/MSHADE-316/verify.bsh
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.shade.mojo;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -18,32 +16,38 @@ package org.apache.maven.plugins.shade.mojo;
  * specific language governing permissions and limitations
  * under the License.
  */
+import java.io.*;
+import java.util.jar.*;
 
-import java.util.Set;
-
-/**
- * @author David Blevins
- */
-public class ArchiveFilter
+String[] wanted =
 {
-    private String artifact;
+    "Main.class",
+    "SomeUsedClass.class",
+    "x/y/z/SomeExemptedClass.class",
+    "x/y/z/AnotherExemptedClass.class"
+};
 
-    private Set<String> includes;
+String[] unwanted =
+{
+    "SomeUnusedClass.class"
+};
 
-    private Set<String> excludes;
+JarFile jarFile = new JarFile( new File( basedir, "test/target/test-1.0.jar" ) );
 
-    public String getArtifact()
-    {
-        return artifact;
-    }
-
-    public Set<String> getIncludes()
+for ( String path : wanted )
+{
+    if ( jarFile.getEntry( path ) == null )
     {
-        return includes;
+        throw new IllegalStateException( "wanted path is missing: " + path );
     }
+}
 
-    public Set<String> getExcludes()
+for ( String path : unwanted )
+{
+    if ( jarFile.getEntry( path ) != null )
     {
-        return excludes;
+        throw new IllegalStateException( "unwanted path is present: " + path );
     }
 }
+
+jarFile.close();
diff --git a/src/main/java/org/apache/maven/plugins/shade/filter/SimpleFilter.java b/src/main/java/org/apache/maven/plugins/shade/filter/SimpleFilter.java
index 28d8386..d1b234c 100644
--- a/src/main/java/org/apache/maven/plugins/shade/filter/SimpleFilter.java
+++ b/src/main/java/org/apache/maven/plugins/shade/filter/SimpleFilter.java
@@ -23,8 +23,11 @@ import org.codehaus.plexus.util.SelectorUtils;
 
 import java.io.File;
 import java.util.HashSet;
+import java.util.Collections;
 import java.util.Set;
 
+import org.apache.maven.plugins.shade.mojo.ArchiveFilter;
+
 /**
  * @author David Blevins
  */
@@ -42,16 +45,42 @@ public class SimpleFilter
 
     private Set<String> excludes;
 
+    private boolean excludeDefaults = true;
+
     /**
+     * @deprecated As of release 3.2.2, replaced by {@link #SimpleFilter(Set<File>, ArchiveFilter)}
      * @param jars set of {@link File}s.
      * @param includes set of includes.
-     * @param excludes set of excludes
+     * @param excludes set of excludes.
      */
+    @Deprecated
     public SimpleFilter( Set<File> jars, Set<String> includes, Set<String> excludes )
     {
-        this.jars = ( jars != null ) ? new HashSet<>( jars ) : new HashSet<File>();
+        this( jars, includes, excludes, true );
+    }
+
+    /**
+     * @param jars set of {@link File}s.
+     * @param archiveFilters set of {@link ArchiveFilter}s.
+     */
+    public SimpleFilter( final Set<File> jars, final ArchiveFilter archiveFilter )
+    {
+        this( jars, archiveFilter.getIncludes(), archiveFilter.getExcludes(), archiveFilter.getExcludeDefaults() );
+    }
+
+    /**
+     * @param jars set of {@link File}s.
+     * @param includes set of includes.
+     * @param excludes set of excludes.
+     * @param excludeDefaults whether to exclude default includes once includes are provided explicitly.
+     */
+    private SimpleFilter( final Set<File> jars, final Set<String> includes, final Set<String> excludes,
+      final boolean excludeDefaults )
+    {
+        this.jars = ( jars != null ) ? Collections.<File>unmodifiableSet( jars ) : Collections.<File>emptySet();
         this.includes = normalizePatterns( includes );
         this.excludes = normalizePatterns( excludes );
+        this.excludeDefaults = excludeDefaults;
     }
 
     /** {@inheritDoc} */
@@ -65,7 +94,7 @@ public class SimpleFilter
     {
         String path = normalizePath( classFile );
 
-        return !( isIncluded( path ) && !isExcluded( path ) );
+        return !( ( !excludeDefaults || isIncluded( path ) ) && !isExcluded( path ) );
     }
 
     /**
diff --git a/src/main/java/org/apache/maven/plugins/shade/mojo/ArchiveFilter.java b/src/main/java/org/apache/maven/plugins/shade/mojo/ArchiveFilter.java
index 665510c..8c8b5d1 100644
--- a/src/main/java/org/apache/maven/plugins/shade/mojo/ArchiveFilter.java
+++ b/src/main/java/org/apache/maven/plugins/shade/mojo/ArchiveFilter.java
@@ -32,6 +32,8 @@ public class ArchiveFilter
 
     private Set<String> excludes;
 
+    private boolean excludeDefaults = true;
+
     public String getArtifact()
     {
         return artifact;
@@ -46,4 +48,9 @@ public class ArchiveFilter
     {
         return excludes;
     }
+
+    public boolean getExcludeDefaults()
+    {
+        return excludeDefaults;
+    }
 }
diff --git a/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java b/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
index c99ed42..30d1b6e 100644
--- a/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
+++ b/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
@@ -490,7 +490,7 @@ public class ShadeMojo
                         replaceFile( finalFile, testJar );
                         testJar = finalFile;
                     }
-                    
+                
                     renamed = true;
                 }
 
@@ -712,7 +712,7 @@ public class ShadeMojo
         coordinate.setVersion( artifact.getVersion() );
         coordinate.setExtension( "jar" );
         coordinate.setClassifier( "sources" );
-        
+
         Artifact resolvedArtifact;
         try
         {
@@ -809,7 +809,7 @@ public class ShadeMojo
                     continue;
                 }
 
-                simpleFilters.add( new SimpleFilter( jars, filter.getIncludes(), filter.getExcludes() ) );
+                simpleFilters.add( new SimpleFilter( jars, filter ) );
             }
         }
 
diff --git a/src/site/apt/examples/includes-excludes.apt.vm b/src/site/apt/examples/includes-excludes.apt.vm
index e83126f..4af01de 100644
--- a/src/site/apt/examples/includes-excludes.apt.vm
+++ b/src/site/apt/examples/includes-excludes.apt.vm
@@ -66,7 +66,7 @@ Selecting Contents for Uber JAR
   Of course, <<<\<includes\>>>> can be used as well to specify a white list of artifacts. Artifacts are denoted by a
   composite idenitifer of the form <groupId>:<artifactId>[[:<type>]:<classifier>]. Since plugin version 1.3, the
   wildcard characters '*' and '?' can be used to do glob-like pattern matching.
-  
+
 
   For fine-grained control of which classes from the selected dependencies are included, artifact filters can be used:
 
@@ -154,8 +154,9 @@ Selecting Contents for Uber JAR
 
   As of version 1.6, minimizeJar will respect classes that were specifically marked for inclusion in a filter.
   Note that specifying an include filter for classes in an artifact implicitly excludes all non-specified
-  classes in that artifact.
-  
+  classes in that artifact. <<<\<excludeDefaults\>false\<\\excludeDefaults\>>>> will override this behavior so that all
+  non-specified classes still will be included though.
+
 +-----
 <project>
   ...
@@ -186,7 +187,14 @@ Selecting Contents for Uber JAR
                        <include>**</include>
                    </includes>
                 </filter>
-              </filters>            
+                <filter>
+                   <artifact>foo:bar</artifact>
+                   <excludeDefaults>false</excludeDefaults>
+                   <includes>
+                       <include>foo/Bar.class</include>
+                   </includes>
+                </filter>
+              </filters>
             </configuration>
           </execution>
         </executions>
@@ -195,4 +203,4 @@ Selecting Contents for Uber JAR
   </build>
   ...
 </project>
-+-----  
\ No newline at end of file
++-----
\ No newline at end of file
diff --git a/src/test/java/org/apache/maven/plugins/shade/filter/SimpleFilterTest.java b/src/test/java/org/apache/maven/plugins/shade/filter/SimpleFilterTest.java
index fcb4e3a..a2dff0e 100644
--- a/src/test/java/org/apache/maven/plugins/shade/filter/SimpleFilterTest.java
+++ b/src/test/java/org/apache/maven/plugins/shade/filter/SimpleFilterTest.java
@@ -19,9 +19,13 @@ package org.apache.maven.plugins.shade.filter;
  * under the License.
  */
 
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
 import java.util.Collections;
 
 import junit.framework.TestCase;
+import org.apache.maven.plugins.shade.mojo.ArchiveFilter;
 
 /**
  * @author Benjamin Bentmann
@@ -72,6 +76,21 @@ public class SimpleFilterTest
         assertFalse( filter.isFiltered( "Test.class" ) );
         assertTrue( filter.isFiltered( "org/Test.class" ) );
         assertTrue( filter.isFiltered( "org/apache/Test.class" ) );
+
+        // given defaults shall be excluded and a specific include is given when filtering then only specific file must be included
+        final ArchiveFilter archiveFilter = mock( ArchiveFilter.class );
+        when( archiveFilter.getIncludes() ).thenReturn( Collections.singleton( "specific include" ) );
+        when( archiveFilter.getExcludes() ).thenReturn( Collections.<String> emptySet() );
+        when( archiveFilter.getExcludeDefaults() ).thenReturn( true );
+        filter = new SimpleFilter( null, archiveFilter );
+        assertFalse( filter.isFiltered( "specific include" ) );
+        assertTrue( filter.isFiltered( "some other file matched by default include" ) );
+
+        // given defaults shall be included and a specific include is given when filtering then all files must be included
+        when( archiveFilter.getExcludeDefaults() ).thenReturn( false );
+        filter = new SimpleFilter( null, archiveFilter );
+        assertFalse( filter.isFiltered( "specific include" ) );
+        assertFalse( filter.isFiltered( "some other file matched by default include" ) );
     }
 
 }