- 浏览: 985546 次
- 性别:
- 来自: 杭州
文章分类
- 全部博客 (826)
- 硬件 (8)
- 软件 (24)
- 软件工程 (34)
- JAVA (229)
- C/C++/C# (77)
- JavaScript (8)
- PHP (1)
- Ruby (3)
- MySQL (14)
- 数据库 (19)
- 心情记事 (12)
- 团队管理 (19)
- Hadoop (1)
- spring (22)
- mybatis(ibatis) (7)
- tomcat (16)
- velocity (0)
- 系统架构 (6)
- JMX (8)
- proxool (1)
- 开发工具 (16)
- python (10)
- JVM (27)
- servlet (5)
- JMS (26)
- ant (2)
- 设计模式 (5)
- 智力题 (2)
- 面试题收集 (1)
- 孙子兵法 (16)
- 测试 (1)
- 数据结构 (7)
- 算法 (22)
- Android (11)
- 汽车驾驶 (1)
- lucene (1)
- memcache (12)
- 技术架构 (7)
- OTP-Erlang (7)
- memcached (17)
- redis (20)
- 浏览器插件 (3)
- sqlite (3)
- Heritrix (9)
- Java线程 (1)
- scala (0)
- Mina (6)
- 汇编 (2)
- Netty (15)
- libevent (0)
- CentOS (12)
- mongod (5)
- mac os (0)
最新评论
-
kingasdfg:
你这里面存在一个错误添加多个任务 应该是这样的 /** * ...
Quartz的任务的临时启动和暂停和恢复【转】 -
kyzeng:
纠正一个错误,long型对应的符号是J,不是L。
Jni中C++和Java的参数传递 -
zhaohaolin:
抱歉,兄弟,只是留下作记录,方便学习,如果觉得资料不好,可以到 ...
netty的个人使用心得【转】 -
cccoooccooco:
谢谢!自己一直以为虚机得使用网线才可以与主机连接呢。。
主机网卡无网线连接与虚拟机通信 -
yuqilin001:
要转别人的东西,请转清楚点嘛,少了这么多类,误人子弟
netty的个人使用心得【转】
在上一篇文章中,讨论到在对maven的机制不熟悉的情况下,为了实现自己需要的打包格式而使用maven ant task以maven + ant的方式来实现非标准打包,而现在要介绍的是maven中针对打包任务而提供的标准插件:assembly plugin。
依然以上文(初学maven(4)-使用maven ant task实现非标准打包)的项目为例,要打包的程序如下:
1
2
3
4
5
6
7
8
9
10
11
12
|
demo1
|____lib
|_____demo1.jar
|_____*****.jar
|_____*****.jar
|____config
|_____*****.properties
|_____*****.xml
|____log
|_____*****.log
|____run.bat
|____run.sh
|
类似的建立java项目,文件结构如下:
1
2
3
4
5
6
7
8
9
10
|
demo1
|____src/main/java
|____src/main/config
|____src/main/bin
|____src/main/resources
|____src/main/assemble
|____src/test/java
|____src/test/resources
|____target
|____pom.xml
|
除开增加了src/main/assemble目录和没有ant的build文件外,其他内容完全一样:其中src/main/java下放java代 码;src/main/resources下放一个*.properties文件,这个资源文件是打包到 jar中,内容打包之后不需要改变的。src/main/config下放一个标准的log4j.xml,这个是有在安装运行前临时修改的需要的。src /main/bin下放置可执行文件。
assembly plugin的使用方式比较简单,主要有:
1. 修改pom.xml
pom.xml中设置如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<!--notappendassemblyidinreleasefilename-->
<appendAssemblyId>
false
</appendAssemblyId>
<descriptors>
<descriptor>src/main/assemble/
package
.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>
package
</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
|
其中<artifactId>maven-assembly-plugin</artifactId>的maven-assembly-plugin是这个插件的标准命名,在maven2.0.*中带的默认版本是
appendAssemblyId属性控制是否在生成的打包文件的文件名中包含assembly id。
descriptor属性指定maven-assembly-plugin的配置文件,当然我设置的是src/main/assemble/package.xml.容许使用多个,功能强大当然用法也复杂,对于简单情况一个足矣。
execution的设置是为了将maven-assembly-plugin继承到标准的maven打包过程中,这样在运行maven-package时就会执行maven-assembly-plugin的操作,从而实现我们需要的自定义打包。
2. assemble descriptor file
我的src/main/assemble/package.xml内容如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
<assemblyxmlns=
"http://maven.apache.org/POM/4.0.0
"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance
"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0http://maven.apache.org/xsd/assembly-1.0.0.xsd
"
>
<id>
package
</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>
true
</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>src/main/bin</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
<fileSet>
<directory>src/main/config</directory>
<outputDirectory>config</outputDirectory>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
<scope>runtime</scope>
</dependencySet>
</dependencySets>
</assembly>
|
详细的语法不介绍了,请参考官方指南,有非常详尽的说明:Assembly Descriptor Format reference
简单解释一下:
1) format
format=zip设置打包的最终文件格式为zip.
支持的其他格式还有gz,tar,tar.gz,tar.bz2。
2) fileset
1
2
3
4
|
<fileSet>
<directory>src/main/bin</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
|
将src/main/bin目录下的文件打包到根目录(/)下.
1
2
3
4
|
<fileSet>
<directory>src/main/config</directory>
<outputDirectory>config</outputDirectory>
</fileSet>
|
将src/main/config目录下的文件打包到config下.
3) dependencySets
1
2
3
4
|
<dependencySet>
<outputDirectory>lib</outputDirectory>
<scope>runtime</scope>
</dependencySet>
|
将scope为runtime的依赖包打包到lib目录下。
总结一下,pom.xml中引入maven-assembly-plugin,然后assemble descriptor file按需设置,最后在eclipse中执行Run As -> Maven package,在target目录下就会出现***.zip文件,里面的格式和要求的完全一致。
够简单明了吧?感觉比使用maven ant task要轻快不少,看来maven还是很强大的,继续学习......
发表评论
-
调试jdk中的源码,查看jdk局部变量
2013-06-15 23:30 1013调试jdk中的源码,查看jdk局部变量 2012-04 ... -
Eclipse快捷键 10个最有用的快捷键<转>
2013-04-11 23:28 1011Eclipse中10个最有用的快捷键组合 一个Eclip ... -
Lucene 3.6 中文分词、分页查询、高亮显示等
2012-12-09 23:35 17731、准备工作 下载lucene 3.6.1 : htt ... -
Maven实战(九)——打包的技巧(转)
2012-10-12 00:41 898“打包“这个词听起 ... -
基于Maven的web工程如何配置嵌入式Jetty Server开发调试环境(转)
2012-10-12 00:28 8721、首先在web工程的POM文件里添加依赖jar包如下: ... -
轻轻松松学Solr(1)--概述及安装[转]
2012-09-18 14:59 950概述 这段时间对企 ... -
分析Netty工作流程[转]
2012-09-04 19:02 846下面以Netty中Echo的例 ... -
让eclipse在ubuntu下面好看一点
2012-03-27 10:17 882<p> </p> <h1 cla ... -
zookeeper安装和应用场合(名字,配置,锁,队列,集群管理)[转]
2012-01-12 17:59 1615安装和配置详解 本文 ... -
Jakarta-Common-BeanUtils使用笔记[转]
2012-01-10 14:13 1120Jakarta-Common-BeanUtils ... -
一个关于Java Thread wait(),notify()的实用例【转】
2012-01-07 16:05 983///// // ProducerConsume ... -
Java基础:Java中的 assert 关键字解析【转】
2012-01-06 19:50 975J2SE 1.4在语言上提供了 ... -
一篇不错的讲解Java异常的文章(转载)----感觉很不错,读了以后很有启发[转]
2012-01-06 15:02 1217六种异常处理的陋习 ... -
如何解决HP QC(Quality Center)在Windows 7下不能工作的问题
2011-12-26 10:48 1538HP QC(Quantity Center) 是一款不错的测 ... -
JAVA读写文件,中文乱码 【转】
2011-12-19 23:43 2073最近在做HTML静态生成,需要从硬盘上把模版文件的内容读出来。 ... -
Java 6 JVM参数选项大全(中文版)【转】
2011-12-19 19:51 927Java 6 JVM参数选项大全(中文版) 作者 ... -
使用maven ant task实现非标准打包[转]
2011-12-13 01:56 1005maven很强大,但是总有些事情干起来不是得心应手,没有使用a ... -
Java日期转换SimpleDateFormat格式大全【转】
2011-12-08 20:22 126424小时制时间 显示: public clas ... -
使用Spring的表单标签库
2011-11-22 20:08 103413.9. 使用Spring的 ... -
WEB界面开发规范(转)
2011-11-02 20:06 899页面设计规则 页面命名规则 1、每个功能 ...
相关推荐
Maven-assembly-plugin是maven中针对打包任务而提供的标准插件,可以实现自定义打包。主要提供如下功能: ● 提供一个把工程依赖元素、模块、网站文档等其他文件存放到单个归档文件里。 ● 打包成指定格式分发包,...
Spring Boot项目使用maven-assembly-plugin根据不同环境打包成tar.gz或者zip
The Assembly Plugin for Maven is primarily intended to allow users to aggregate the project output along with its dependencies, modules, site documentation, and other files into a single distributable...
通过自定义plugin插件实现了javascript与Android的交互。
主要介绍了Maven3种打包方式中maven-assembly-plugin的使用,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
V2gazebo_plugin添加自定义话题数据,其中动态库文件可以不用复制到电脑
gazebo_plugin添加自定义话题数据发布,需要先编译自定义消息,然后再整个文件编译。如果找不到路径,则把路径添加到.bashrc文件中。最后启动launch文件即可。 如下: roslaunch gazebo_harogic hello.launch
maven-assembly-plugin-2.2-beta-5.jar
Qt Creator plugin动手实践(2)自己动手写qt creator插件,实现自定义工具栏按钮
博文链接:https://lengjing.iteye.com/blog/2259212
java运行依赖jar包
java运行依赖jar包
maven打包dubbo服务接口(maven-assembly-plugin)
自定义plugin插件,实现javascript与Android的交互
Android Studio 自定义 Gradle Plugin
Maven的组装插件的例子 该项目包含maven-assembly-plugin用法的示例阅读 yeoman generator(java)生成的项目
maven plugin打包下载
malihu-custom-scrollbar-plugin-master 自定义滚动条样式,可自定义滚动条颜色,长度,滚动条框的背景色等。
NULL 博文链接:https://dreamzhong.iteye.com/blog/1128392
自定义科尔多瓦插件自定义 Cordova 插件安装sudo phonegap local plugin add https://github.com/bensonnjonjo/custom-cordova-plugin.git 卸载sudo phonegap local plugin remove de.appplant.cordova.plugin....