Last Published: 2008-05-29  | Version: 1.1
Apache | Maven 1.x | Maven 2.x | Maven 2.x Plugins | Continuum | SCM | Wagon | JXR | Doxia

Overview
  • Introduction
  • Goals
  • Usage
  • Examples
Project Documentation
  • Project Information
  • Project Reports
Built by Maven
  • Shade Plugin with no relocation
    <project>
      ...
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>shade</goal>
                </goals>
                <configuration>
                  <artifactSet>
                    <excludes>
                      <exclude>classworlds:classworlds</exclude>
                      <exclude>junit:junit</exclude>
                      <exclude>jmock:jmock</exclude>
                      <exclude>xml-apis:xml-apis</exclude>
                    </excludes>
                  </artifactSet>
                  <transformers>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer"/>
                  </transformers>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
      ...
    </project>
  • Shade Plugin with shaded relocation
    <project>
      ...
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>shade</goal>
                </goals>
                <configuration>
                  <artifactSet>
                    <excludes>
                      <exclude>classworlds:classworlds</exclude>
                      <exclude>junit:junit</exclude>
                      <exclude>jmock:jmock</exclude>
                      <exclude>xml-apis:xml-apis</exclude>
                    </excludes>
                  </artifactSet>
                  <relocations>
                    <relocation>
                      <pattern>org.codehaus.plexus.util</pattern>
                      <shadedPattern>org.shaded.plexus.util</shadedPattern>
                      <excludes>
                        <exclude>org.codehaus.plexus.util.xml.Xpp3Dom</exclude>
                        <exclude>org.codehaus.plexus.util.xml.pull.*</exclude>
                      </excludes>
                    </relocation>
                  </relocations>
                  <transformers>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer"/>
                  </transformers>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
      ...
    </project>
  • Shade Plugin with renamed but unattached artifact
    <project>
      ...
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>shade</goal>
                </goals>
                <configuration>
                  <shadedArtifactId>shaded-artifact</shadedArtifactId>
                  <artifactSet>
                    <excludes>
                      <exclude>classworlds:classworlds</exclude>
                      <exclude>junit:junit</exclude>
                      <exclude>jmock:jmock</exclude>
                      <exclude>xml-apis:xml-apis</exclude>
                    </excludes>
                  </artifactSet>
                  <relocations>
                    <relocation>
                      <pattern>org.codehaus.plexus.util</pattern>
                      <excludes>
                        <exclude>org.codehaus.plexus.util.xml.Xpp3Dom</exclude>
                        <exclude>org.codehaus.plexus.util.xml.pull.*</exclude>
                      </excludes>
                    </relocation>
                  </relocations>
                  <transformers>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer"/>
                  </transformers>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
      ...
    </project>
  • Shade Plugin with renamed and attached artifact
    <project>
      ...
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>shade</goal>
                </goals>
                <configuration>
                  <shadedArtifactId>shaded-artifact</shadedArtifactId>
                  <shadedArtifactAttached>true</shadedArtifactAttached>
                  <shadedClassifierName>jackofall</shadedClassifierName> <!-- Any name that makes sense -->
                  <artifactSet>
                    <excludes>
                      <exclude>classworlds:classworlds</exclude>
                      <exclude>junit:junit</exclude>
                      <exclude>jmock:jmock</exclude>
                      <exclude>xml-apis:xml-apis</exclude>
                    </excludes>
                  </artifactSet>
                  <relocations>
                    <relocation>
                      <pattern>org.codehaus.plexus.util</pattern>
                      <excludes>
                        <exclude>org.codehaus.plexus.util.xml.Xpp3Dom</exclude>
                        <exclude>org.codehaus.plexus.util.xml.pull.*</exclude>
                      </excludes>
                    </relocation>
                  </relocations>
                  <transformers>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer"/>
                  </transformers>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
      ...
    </project>
  • Shade Plugin with artifact filtering using includes
    <project>
      ...
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>shade</goal>
                </goals>
                <configuration>
                <filters>
                  <filter>
                    <artifact>junit:junit</artifact>
                    <includes>
                      <include>junit/framework/**</include>
                      <include>org/junit/**</include>
                    </includes>
                  </filter>
                </filters>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
      ...
    </project>
  • Shade Plugin with artifact filtering using includes and excludes
    <project>
      ...
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>shade</goal>
                </goals>
                <configuration>
                <filters>
                  <filter>
                    <artifact>junit:junit</artifact>
                    <includes>
                      <include>junit/framework/**</include>
                      <include>org/junit/**</include>
                    </includes>
                    <excludes>
                      <exclude>org/junit/experimental/**</exclude>
                      <exclude>org/junit/runners/**</exclude>
                    </excludes>
                  </filter>
                </filters>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
      ...
    </project>
  • Shade Plugin with artifact filtering using excludes only
    <project>
      ...
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>shade</goal>
                </goals>
                <configuration>
                <filters>
                  <filter>
                    <artifact>junit:junit</artifact>
                    <excludes>
                      <exclude>junit/textui/**</include>
                      <exclude>junit/runner/**</include>
                      <exclude>junit/extensions/**</include>
                      <exclude>org/junit/experimental/**</include>
                      <exclude>org/junit/runners/**</include>
                    </excludes>
                  </filter>
                </filters>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
      ...
    </project>

© 2002-2008 The Apache Software Foundation