[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 ...
随机推荐
- [Angular 2] Select From Multiple Nested Angular 2 Elements
You have complete control over the elements you nest inside of your component instance by using sele ...
- iOS NSData
NSData全部API学习. 学习NSData,在网上找资料竟然都是拷贝的纯代码,没人去解释.在这种网上没资料的情况下,整理这个API文件好难,好艰辛.在这贡献给大家了,么么哒~示例程序用红色标注. ...
- iOS 原生地图(MapKit、MKMapView)轨迹渐变
WechatIMG2.png 项目已接入高德地图,并且大部分功能已经实现好,但BOSS觉得iOS自带的地图效果更好...本着面向老板编程的思想,换之.还好,高德地图是在MapKit上封装的,大部分ap ...
- Android Widget 小部件(三) 在Activity中加入Widget
package com.stone.ui; import static android.util.Log.d; import android.app.Activity; import android. ...
- h5 -1
<header></header> 页眉 主要用于页面的头部的信息介绍,也可用于板块头部 <hgroup></hgroup> 页面上的一个标题组合 一个 ...
- 一款纯css3实现的条纹加载条
之前为大家带来了很多加载动画. 基于prefixfree.js的进度加载条 ,基于jquery带百分比的响应式进度加载条.今天给大家分享一款纯css3实现的条纹加载条.带有响应式的效果.效果图如下 : ...
- 项目源码--JAVA基于LBS地理位置信息应用的服务端
技术要点: 1. LBS应用框架服务端实现 2. JAVA服务端技术 3. MYSQL数据库技术 4. 源码带详细的中文注释 ...... 详细介绍: 1. LBS应用框架服务端实现 此套源码是基 ...
- redis源码学习
上帝禁区 http://blog.csdn.net/a600423444/article/details/8944601
- Android——AnimationDrawable 实现动画
Android中的AnimationDrawable可以加载Drawable资源实现帧动画.实现步骤如下: 一.设置动画播放的帧资源 <?xml version="1.0" ...
- go can't find import: "github.com/** 错误
go get 后 go build 错误 can't find import: "github.com/ 原因: 1.gopath 没配好 2.go get 后要先 go install , ...