[Apache Maven Shade Plugin] [example] [001] official example: javasdes-excludes, mavenshadeplugin

Source: Internet
Author: User

[Apache Maven Shade Plugin] [example] [001] official example: javasdes-excludes, mavenshadeplugin

Link: [Selecting Contents for Uber JAR] (http://maven.apache.org/plugins/maven-shade-plugin/examples/includes-excludes.html)

It is too slow to open the apache website in China. So I collected these useful resources and saved them in my blog!

Apache Maven Shade Plugin: a plug-in packaged by Maven. Its official website is defined as follows in English: This plugin provides the capability to package the artifact in an uber-jar, including its dependencies andShade

001.

1 <project> 2... 3 <build> 4 <plugins> 5 <plugin> 6 <groupId> org. apache. maven. plugins </groupId> 7 <artifactId> maven-shade-plugin </artifactId> 8 <version> 2.4.3 </version> 9 <executions> 10 <execution> 11 <phase> package </phase> 12 <goals> 13 <goal> shade </goal> 14 </goals> 15 <configuration> 16 <artifactSet> 17 <excludes> 18 <exclude> classworlds: classworlds </exclude> 19 <exclude> junit: junit </exclude> 20 <exclude> jmock: * </exclude> 21 <exclude> *: xml-apis </exclude> 22 <exclude> org. apache. maven: lib: tests </exclude> 23 <exclude> log4j: log4j: jar: </exclude> 24 </excludes> 25 </artifactSet> 26 </configuration> 27 </execution> 28 </executions> 29 </plugin> 30 </plugins> 31 </build> 32... 33 </project>View Code

002.

1 <project> 2... 3 <build> 4 <plugins> 5 <plugin> 6 <groupId> org. apache. maven. plugins </groupId> 7 <artifactId> maven-shade-plugin </artifactId> 8 <version> 2.4.3 </version> 9 <executions> 10 <execution> 11 <phase> package </phase> 12 <goals> 13 <goal> shade </goal> 14 </goals> 15 <configuration> 16 <filters> 17 <filter> 18 <artifact> junit: junit </artifact> 19 <shortdes> 20 <include> junit/framework/** </include> 21 <include> org/junit/** </include> 22 </ primary des> 23 <excludes> 24 <exclude> org/junit/experimental/** </exclude> 25 <exclude> org/junit/runners/** </exclude> 26 </excludes> 27 </filter> 28 <filter> 29 <artifact> *: * </artifact> 30 <excludes> 31 <exclude> META-INF /*. SF </exclude> 32 <exclude> META-INF /*. DSA </exclude> 33 <exclude> META-INF /*. RSA </exclude> 34 </excludes> 35 </filter> 36 </filters> 37 </configuration> 38 </execution> 39 </executions> 40 </plugin> 41 </plugins> 42 </build> 43... 44 </project>View Code

003.

1 <project> 2... 3 <build> 4 <plugins> 5 <plugin> 6 <groupId> org. apache. maven. plugins </groupId> 7 <artifactId> maven-shade-plugin </artifactId> 8 <version> 2.4.3 </version> 9 <executions> 10 <execution> 11 <phase> package </phase> 12 <goals> 13 <goal> shade </goal> 14 </goals> 15 <configuration> 16 <minimizeJar> true </minimizeJar> 17 </configuration> 18 </execution> 19 </executions> 20 </plugin> 21 </plugins> 22 </build> 23... 24 </project>View Code

004.

1 <project> 2... 3 <build> 4 <plugins> 5 <plugin> 6 <groupId> org. apache. maven. plugins </groupId> 7 <artifactId> maven-shade-plugin </artifactId> 8 <version> 2.4.3 </version> 9 <executions> 10 <execution> 11 <phase> package </phase> 12 <goals> 13 <goal> shade </goal> 14 </goals> 15 <configuration> 16 <minimizeJar> true </minimizeJar> 17 <filters> 18 <filter> 19 <artifact> log4j: log4j </artifact> 20 <shortdes> 21 <include> ** </include> 22 </shortdes> 23 </filter> 24 <filter> 25 <artifact> commons-logging: commons-logging </artifact> 26 <shortdes> 27 <include> ** </include> 28 </shortdes> 29 </filter> 30 </filters> 31 </configuration> 32 </execution> 33 </executions> 34 </plugin> 35 </plugins> 36 </build> 37... 38 </project>View Code

 

(001) there are not many introductions on the 'shade 'Official website. Probably because it is relatively simple. However, the cainiao still has a headache in configuring 'shade '. There is a small amount of information on the Internet. It is estimated that it is relatively simple. No one has written an article to introduce 'shade 'in detail '. Therefore, the official examples have become the most valuable materials.

(002) combined with the 'shade 'source code, I began to study how to use the 'shade' journey. The source code is relatively simple. To study 'shade ', you can add it to 'dependencies' in pom. xml. You can also download images from the official website.

(003) before studying any 'maven plugin', you should first take a look at the introduction of this Plug-in [Guide to understanding ing Plug-ins] (http://maven.apache.org/guides/mini/guide-configuring-plugins.html ), this will save you a lot of detours (I will not tell you that I learned it when I got up and fell into the trap ).

(003001) in this official document, I first saw 'mojo ', an IOC framework used by Maven Plugin. (Now I have not studied Mojo, so I may be able to study Mojo in the future. If you are interested, you can search .)

(003002) the fields in 'mojo 'correspond to the configuration in the plugin. If you are confused about the configuration in the example, you can open the 'mojo' in the source code and find out their principles. The 'mojo 'in 'shade' is 'shademojo. Java.

(004) end.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.