Skip to content

Instantly share code, notes, and snippets.

@stephen-masters
Created September 3, 2012 13:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephen-masters/3609269 to your computer and use it in GitHub Desktop.
Save stephen-masters/3609269 to your computer and use it in GitHub Desktop.
Maven Shade Plugin example
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
</transformers>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
@stephen-masters
Copy link
Author

Using the shade plugin it's relatively simple to have your build create a single Jar file containing all dependencies. This can simplify deployments greatly and avoids the issues that come of having a lib directory on a server containing loads of Jar files, and you have no idea what version each of them is. This way, you ensure that all the dependencies you tested against in your build are definitely the ones that have been deployed with your code.

I find it particularly handy for FitNesse where I'm able to run a quick script to download the latest version of an artifact from a repository, and I know that what I'm getting includes all the dependencies I need. If a dependency version changes, or is added, I don't need to alter my deployment script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment