Maven Shade Plugin
  1. Maven Shade Plugin
  2. MSHADE-62

We need an <obliterate/> element - to TRULY exclude classes from resulting jar

    Details

    • Type: New Feature New Feature
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      'exclusions' is misnamed - it should be 'leaveAsIs' or somesuch.

      I want to totally exclude some packages or classes from the resulting jar. As in leave them out, or kill them, or don't have them at all in the resulting jar. Neither as their original class name nor their potential new class name.

      Perforce has an 'obliterate' concept, given exclude is already used in shade, maybe obliterate is the new element for this essential feature.

        Activity

        Hide
        Benjamin Bentmann added a comment -

        Paul, can you be more specific why the "fine-grained control of which classes from the selected dependencies are included" from the example Selecting Contents for Uber JAR does not work?

        Show
        Benjamin Bentmann added a comment - Paul, can you be more specific why the "fine-grained control of which classes from the selected dependencies are included" from the example Selecting Contents for Uber JAR does not work?
        Hide
        Paul Hammant added a comment -

        I thought I could exclude classes that would never be used by PicoContainer like so :-

         
              <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>1.2.1</version>
                <executions>
                  <execution>
                    <phase>package</phase>
                    <goals>
                      <goal>shade</goal>
                    </goals>
                    <configuration>
                      <shadedArtifactId>picocontainer</shadedArtifactId>
                      <artifactSet>
                        <excludes>
                          <exclude>javax.annotation:jsr250-api</exclude>
                        </excludes>
                      </artifactSet>
                      <relocations>
                        <relocation>
                          <pattern>com.thoughtworks.paranamer</pattern>
                          <shadedPattern>org.picocontainer.paranamer</shadedPattern>
                          <excludes>
                            <exclude>com.thoughtworks.paranamer.JavadocParanamer</exclude>
                          </excludes>
                        </relocation>
                      </relocations>
                    </configuration>
                  </execution>
                </executions>
              </plugin>
        

        Unfortunately, exclude does not mean exclude it means "don't re-package" .....

         
        ph-mbp:container paul$ jar -tvf target/picocontainer-2.9-SNAPSHOT.jar | grep paranamer
             0 Sun Sep 06 11:06:50 CDT 2009 org/picocontainer/paranamer/
          3150 Sun Sep 06 11:06:50 CDT 2009 org/picocontainer/paranamer/AdaptiveParanamer.class
           809 Sun Sep 06 11:06:50 CDT 2009 org/picocontainer/paranamer/BytecodeReadingParanamer$1.class
          7803 Sun Sep 06 11:06:50 CDT 2009 org/picocontainer/paranamer/BytecodeReadingParanamer$ClassReader.class
          2977 Sun Sep 06 11:06:50 CDT 2009 org/picocontainer/paranamer/BytecodeReadingParanamer$MethodCollector.class
          4662 Sun Sep 06 11:06:50 CDT 2009 org/picocontainer/paranamer/BytecodeReadingParanamer$Type.class
          6262 Sun Sep 06 11:06:50 CDT 2009 org/picocontainer/paranamer/BytecodeReadingParanamer$TypeCollector.class
          6198 Sun Sep 06 11:06:50 CDT 2009 org/picocontainer/paranamer/BytecodeReadingParanamer.class
          2535 Sun Sep 06 11:06:50 CDT 2009 org/picocontainer/paranamer/CachingParanamer.class
          5336 Sun Sep 06 11:06:50 CDT 2009 org/picocontainer/paranamer/DefaultParanamer.class
             0 Sun Sep 06 11:06:50 CDT 2009 com/thoughtworks/paranamer/
         10630 Sun Sep 06 11:06:50 CDT 2009 com/thoughtworks/paranamer/JavadocParanamer.class
          1432 Sun Sep 06 11:06:50 CDT 2009 org/picocontainer/paranamer/NullParanamer.class
           964 Sun Sep 06 11:06:50 CDT 2009 org/picocontainer/paranamer/ParameterNamesNotFoundException.class
           762 Sun Sep 06 11:06:50 CDT 2009 org/picocontainer/paranamer/Paranamer.class
           549 Sun Sep 06 11:06:50 CDT 2009 org/picocontainer/paranamer/ParanamerConstants.class
             0 Sun Sep 06 11:06:50 CDT 2009 META-INF/maven/com.thoughtworks.paranamer/
             0 Sun Sep 06 11:06:50 CDT 2009 META-INF/maven/com.thoughtworks.paranamer/paranamer/
          1290 Sun Sep 06 11:06:50 CDT 2009 META-INF/maven/com.thoughtworks.paranamer/paranamer/pom.xml
           127 Sun Sep 06 11:06:50 CDT 2009 META-INF/maven/com.thoughtworks.paranamer/paranamer/pom.properties
        

        Specifically, its these two lines that I'd rather were left out completely (not in the jar, not in the jar in re-packaged form) ..

         
             0 Sun Sep 06 11:06:50 CDT 2009 com/thoughtworks/paranamer/
         10630 Sun Sep 06 11:06:50 CDT 2009 com/thoughtworks/paranamer/JavadocParanamer.class
        

        Also, I'd rather do without the pom.xml stuff for paranamer too, but that's a different issue.

        • Paul
        Show
        Paul Hammant added a comment - I thought I could exclude classes that would never be used by PicoContainer like so :- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>1.2.1</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <shadedArtifactId>picocontainer</shadedArtifactId> <artifactSet> <excludes> <exclude>javax.annotation:jsr250-api</exclude> </excludes> </artifactSet> <relocations> <relocation> <pattern>com.thoughtworks.paranamer</pattern> <shadedPattern>org.picocontainer.paranamer</shadedPattern> <excludes> <exclude>com.thoughtworks.paranamer.JavadocParanamer</exclude> </excludes> </relocation> </relocations> </configuration> </execution> </executions> </plugin> Unfortunately, exclude does not mean exclude it means "don't re-package" ..... ph-mbp:container paul$ jar -tvf target/picocontainer-2.9-SNAPSHOT.jar | grep paranamer 0 Sun Sep 06 11:06:50 CDT 2009 org/picocontainer/paranamer/ 3150 Sun Sep 06 11:06:50 CDT 2009 org/picocontainer/paranamer/AdaptiveParanamer.class 809 Sun Sep 06 11:06:50 CDT 2009 org/picocontainer/paranamer/BytecodeReadingParanamer$1.class 7803 Sun Sep 06 11:06:50 CDT 2009 org/picocontainer/paranamer/BytecodeReadingParanamer$ClassReader.class 2977 Sun Sep 06 11:06:50 CDT 2009 org/picocontainer/paranamer/BytecodeReadingParanamer$MethodCollector.class 4662 Sun Sep 06 11:06:50 CDT 2009 org/picocontainer/paranamer/BytecodeReadingParanamer$Type.class 6262 Sun Sep 06 11:06:50 CDT 2009 org/picocontainer/paranamer/BytecodeReadingParanamer$TypeCollector.class 6198 Sun Sep 06 11:06:50 CDT 2009 org/picocontainer/paranamer/BytecodeReadingParanamer.class 2535 Sun Sep 06 11:06:50 CDT 2009 org/picocontainer/paranamer/CachingParanamer.class 5336 Sun Sep 06 11:06:50 CDT 2009 org/picocontainer/paranamer/DefaultParanamer.class 0 Sun Sep 06 11:06:50 CDT 2009 com/thoughtworks/paranamer/ 10630 Sun Sep 06 11:06:50 CDT 2009 com/thoughtworks/paranamer/JavadocParanamer.class 1432 Sun Sep 06 11:06:50 CDT 2009 org/picocontainer/paranamer/NullParanamer.class 964 Sun Sep 06 11:06:50 CDT 2009 org/picocontainer/paranamer/ParameterNamesNotFoundException.class 762 Sun Sep 06 11:06:50 CDT 2009 org/picocontainer/paranamer/Paranamer.class 549 Sun Sep 06 11:06:50 CDT 2009 org/picocontainer/paranamer/ParanamerConstants.class 0 Sun Sep 06 11:06:50 CDT 2009 META-INF/maven/com.thoughtworks.paranamer/ 0 Sun Sep 06 11:06:50 CDT 2009 META-INF/maven/com.thoughtworks.paranamer/paranamer/ 1290 Sun Sep 06 11:06:50 CDT 2009 META-INF/maven/com.thoughtworks.paranamer/paranamer/pom.xml 127 Sun Sep 06 11:06:50 CDT 2009 META-INF/maven/com.thoughtworks.paranamer/paranamer/pom.properties Specifically, its these two lines that I'd rather were left out completely (not in the jar, not in the jar in re-packaged form) .. 0 Sun Sep 06 11:06:50 CDT 2009 com/thoughtworks/paranamer/ 10630 Sun Sep 06 11:06:50 CDT 2009 com/thoughtworks/paranamer/JavadocParanamer.class Also, I'd rather do without the pom.xml stuff for paranamer too, but that's a different issue. Paul
        Hide
        Benjamin Bentmann added a comment -

        Paul, did you try the example I pointed at, e.g. something like

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-shade-plugin</artifactId>
          <version>1.2.1</version>
          <executions>
            <execution>
              <phase>package</phase>
              <goals>
                <goal>shade</goal>
              </goals>
              <configuration>
                <filters>
                  <filter>
                    <artifact>com.thoughtworks.paranamer:paranamer</artifact>
                    <excludes>
                      <exclude>com/thoughtworks/paranamer/**</exclude>
                    </excludes>
                  </filter>
                </filters>
              </configuration>
            </execution>
          </executions>
        </plugin>
        
        Show
        Benjamin Bentmann added a comment - Paul, did you try the example I pointed at, e.g. something like <plugin> <groupId> org.apache.maven.plugins </groupId> <artifactId> maven-shade-plugin </artifactId> <version> 1.2.1 </version> <executions> <execution> <phase> package </phase> <goals> <goal> shade </goal> </goals> <configuration> <filters> <filter> <artifact> com.thoughtworks.paranamer:paranamer </artifact> <excludes> <exclude> com/thoughtworks/paranamer/** </exclude> </excludes> </filter> </filters> </configuration> </execution> </executions> </plugin>
        Hide
        Paul Hammant added a comment -

        You're right Ben, the following was what I wanted ...

              <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>1.2.1</version>
                <executions>
                  <execution>
                    <phase>package</phase>
                    <goals>
                      <goal>shade</goal>
                    </goals>
                    <configuration>
                      <shadedArtifactId>picocontainer</shadedArtifactId>
                        <filters>
                            <filter>
                                <artifact>com.thoughtworks.paranamer:paranamer</artifact>
                                <excludes>
                                    <exclude>com/thoughtworks/paranamer/Javadoc*</exclude>
                                </excludes>
                            </filter>
                        </filters>
                        <relocations>
                          <relocation>
                            <pattern>com.thoughtworks.paranamer</pattern>
                            <shadedPattern>org.picocontainer.paranamer</shadedPattern>
                          </relocation>
                      </relocations>
                    </configuration>
                  </execution>
                </executions>
              </plugin>
        

        This bug can be closed - sorry for wasting your time

        Show
        Paul Hammant added a comment - You're right Ben, the following was what I wanted ... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>1.2.1</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <shadedArtifactId>picocontainer</shadedArtifactId> <filters> <filter> <artifact>com.thoughtworks.paranamer:paranamer</artifact> <excludes> <exclude>com/thoughtworks/paranamer/Javadoc*</exclude> </excludes> </filter> </filters> <relocations> <relocation> <pattern>com.thoughtworks.paranamer</pattern> <shadedPattern>org.picocontainer.paranamer</shadedPattern> </relocation> </relocations> </configuration> </execution> </executions> </plugin> This bug can be closed - sorry for wasting your time

          People

          • Assignee:
            Benjamin Bentmann
            Reporter:
            Paul Hammant
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: