[Apache Maven Shade Plugin] [example] [001] 官方例子:includes-excludes
链接地址:[Selecting Contents for Uber JAR](http://maven.apache.org/plugins/maven-shade-plugin/examples/includes-excludes.html)
apache网站在国内打开太慢了。因此我将这些有用的资源收集起来,保存在博客中!
Apache Maven Shade Plugin:是一个Maven打包的插件。其官网英文定义如下:This plugin provides the capability to package the artifact in an uber-jar, including its dependencies and to shade
001.
- <project>
- ...
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <version>2.4.3</version>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <artifactSet>
- <excludes>
- <exclude>classworlds:classworlds</exclude>
- <exclude>junit:junit</exclude>
- <exclude>jmock:*</exclude>
- <exclude>*:xml-apis</exclude>
- <exclude>org.apache.maven:lib:tests</exclude>
- <exclude>log4j:log4j:jar:</exclude>
- </excludes>
- </artifactSet>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- ...
- </project>
002.
- <project>
- ...
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <version>2.4.3</version>
- <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>
- <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>
- </plugins>
- </build>
- ...
- </project>
003.
- <project>
- ...
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <version>2.4.3</version>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <minimizeJar>true</minimizeJar>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- ...
- </project>
004.
- <project>
- ...
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <version>2.4.3</version>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <minimizeJar>true</minimizeJar>
- <filters>
- <filter>
- <artifact>log4j:log4j</artifact>
- <includes>
- <include>**</include>
- </includes>
- </filter>
- <filter>
- <artifact>commons-logging:commons-logging</artifact>
- <includes>
- <include>**</include>
- </includes>
- </filter>
- </filters>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- ...
- </project>
(001)`Shade`官网上的介绍也不多。可能因为其相对比较简单吧。但是,我这个菜鸟仍然很头疼如何配置`Shade`。网上的资料比较少,估计也是认为比较简单吧,没人撰文详细介绍`Shade`。所以,官方提供的例子就成为最有价值的资料了。
(002)结合`Shade`源码,我开始踏上研究如何使用的`Shade`旅程。源码的获得比较简单,为了研究`Shade`可以将其添加到pom.xml的`dependencies`中。当然也可以去官网镜像下载。
(003)研究任何`Maven Plugin`之前,都应该先看看这篇插件的介绍 [Guide to Configuring Plug-ins](http://maven.apache.org/guides/mini/guide-configuring-plugins.html),这会让你少走很多弯路(我不会告诉你我是掉坑里了爬起来才知道的)。
(003001)在这篇官方文档里,我首次看到了`Mojo`,这是Maven Plugin使用的一个IOC框架。(当下我并没有去研究Mojo所以知道的有限也许未来会去研究下。有兴趣的朋友可以去搜索下。)
(003002)`Mojo`中的字段是和plugin中的配置对应的,如果对例子中的配置很疑惑,就可以翻开源码中的`Mojo`顺藤摸瓜,找到它们的原理。`Shade`中的`Mojo`就是`ShadeMojo.java`了。
(004)end.
[Apache Maven Shade Plugin] [example] [001] 官方例子:includes-excludes的更多相关文章
- 施用 maven shade plugin 解决 jar 或类的多版本冲突
施用 maven shade plugin 解决 jar 或类的多版本冲突 使用 maven shade plugin 解决 jar 或类的多版本冲突java 应用经常会碰到的依赖的三方库出现版本 ...
- maven shade插件小记
maven shade plugin插件小用 项目中一直使用assembly插件来整合依赖包到一个胖jar,在做这个akka http项目的时候,在scala ide的run/debug中都执行正常, ...
- maven Error resolving version for plugin 'org.apache.maven.plugins:maven-eclipse-plugin' from the repositories 解决
报错:Error resolving version for plugin 'org.apache.maven.plugins:maven-eclipse-plugin' from the repos ...
- CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be resolved
CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin ...
- Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.5
Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of ...
- maven install 报错Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin
Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of ...
- Maven命令行创建web项目,并部署到jobss当中(解决No plugin found for prefix 'jboss-as' in the current project and in the plugin groups [org.apache.maven.plugins,问题)
首件创建项目:此处可参照:http://maven.apache.org/guides/mini/guide-webapp.html mvn archetype:generate -DgroupId= ...
- Eclipse使用Maven,创建项目出现:Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resour
使用maven创建简单的项目时候经常会遇到 Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resource ...
- eclipse导入maven项目时报Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources
在用Eclipse IDE for Java EE Developers进行maven项目的开发时,报错Could not calculate build plan: Plugin org.apach ...
随机推荐
- ios开发——实用技术篇&应用间跳转
应用之间的跳转 说明:本文介绍app如何打开另一个app,并且传递数据. 一.简单说明 新建两个应用,分别为应用A和应用B. 实现要求:在appA的页面中点击对应的按钮,能够打开appB这个应用. 1 ...
- Unity3d截图保存到Android相册的实现
Unity3d截图保存到Android相册的实现-----------------------------ultrasoon 季风原创--------------------------------- ...
- linux下的十六进制编辑器---wxHexEdit
....其实wxHexEdit是一个跨平台的十六进制编辑器,支持windows,linux,mac. 之所以标题用linux...是因为windows下多数都用winhex,UE之类的编辑器,而lin ...
- HDU 4605 Magic Ball Game 树状数组
题目大意很简单. 有一颗树(10^5结点),所有结点要么没有子结点,要么有两个子结点.然后每个结点都有一个重量值,根结点是1 然后有一个球,从结点1开始往子孙结点走. 每碰到一个结点,有三种情况 如果 ...
- git的.gitignore配置
.gitignore 配置文件用于配置不需要加入版本管理的文件,配置好该文件可以为我们的版本管理带来很大的便利,以下是个人对于配置 .gitignore 的一些心得. 1.配置语法: 以斜杠“/”开头 ...
- 基于ARM-LINUX的温度传感器驱动-DS18B20
转载:http://blog.csdn.net/ayangke/article/details/6883244 作者:冯建,华清远见嵌入式学院讲师. DS18B20数字温度传感器接线方便,封装成后可应 ...
- mysql ERROR1405 access deny 问题解决
sudo /usr/local/mysql/bin/mysqld_safe --user=mysql --skip-grant-tables --skip-networking 使用这条命令可以跳过开 ...
- CEP简介
CEP即Complex Event Processing缩写,翻译过来就是复杂事件处理(复合事件可能更加准确). 1.为什么我们需要CEP?CEP是具有实时分析以及快速响应等等功能.下面让我们通过 ...
- 【Shell脚本学习3】什么时候使用Shell
因为Shell似乎是各UNIX系统之间通用的功能,并且经过了POSIX的标准化.因此,Shell脚本只要“用心写”一次,即可应用到很多系统上.因此,之所以要使用Shell脚本是基于: 简单性:Shel ...
- iOS - UI - UIWebView
1.UIWebView UIWebView 是 苹果提供的用来展示网页的UI控件.它也是最占内存的控件. iOS8.0 webkit框架. WKWebView,相比UIWebView,节省了1/3~1 ...