最近需要将项目进行打包,本来使用默认的maven-dependency-plugin 就足够了,但是现在需要一些自定义的处理,需要将依赖的包打入lib目录,同时将main class jar与lib文件夹一起压缩成zip包。
这时候maven-dependency-plugin就不管用了,需要上maven-assembly-plugin了。
目标文件目录
+helloworld.zip
helloworld.jar
+lib/
dependency1.jar
dependency1.jar
POM配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
< plugin >
< artifactId >maven-jar-plugin</ artifactId >
< configuration >
< archive >
< manifest >
< addClasspath >true</ addClasspath >
< classpathPrefix >lib/</ classpathPrefix >
< mainClass >xxx.MainJob</ mainClass >
</ manifest >
</ archive >
< finalName >${project.artifactId}-${env}-${project.version}</ finalName >
</ configuration >
</ plugin >
< plugin >
< groupId >org.apache.maven.plugins</ groupId >
< artifactId >maven-assembly-plugin</ artifactId >
< configuration >
< descriptors >
< descriptor >assembly.xml</ descriptor >
</ descriptors >
</ configuration >
< executions >
< execution >
< id >make-assembly</ id >
< phase >package</ phase >
< goals >
< goal >single</ goal >
</ goals >
</ execution >
</ executions >
</ plugin >
|
Assembly.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
< assembly xmlns = "http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation = "http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd" >
< id ></ id >
< formats >
<!--<format>tar.gz</format>-->
<!--<format>tar.bz2</format>-->
< format >zip</ format >
</ formats >
< fileSets >
< fileSet >
< directory >${project.basedir}</ directory >
< outputDirectory >/</ outputDirectory >
< includes >
< include >README*</ include >
< include >LICENSE*</ include >
< include >NOTICE*</ include >
</ includes >
</ fileSet >
< fileSet >
< directory >${project.build.directory}/site</ directory >
< outputDirectory >docs</ outputDirectory >
</ fileSet >
< fileSet >
< directory >${project.build.directory}/</ directory >
< outputDirectory >/</ outputDirectory >
< includes >
< include >*.jar</ include >
</ includes >
</ fileSet >
</ fileSets >
< dependencySets >
< dependencySet >
< outputDirectory >/lib</ outputDirectory >
< useProjectArtifact >false</ useProjectArtifact >
< scope >runtime</ scope >
</ dependencySet >
</ dependencySets >
</ assembly >
|
执行命令
1
|
mvn package |
相关推荐
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...
直接离线安装eclipse中的maven插件,在你的eclipse安装根目录下创建两个文件夹:links,myplugins(文件夹名字可以自定义),所在路径D:\eclipse。将下载下来的maven插件放到myplugins下。载links目录下创建一个...
eclipse maven3插件,eclipse-maven3-plugin,m2e
Spring Boot项目使用maven-assembly-plugin根据不同环境打包成tar.gz或者zip
Maven-assembly-plugin是maven中针对打包任务而提供的标准插件,可以实现自定义打包。主要提供如下功能: ● 提供一个把工程依赖元素、模块、网站文档等其他文件存放到单个归档文件里。 ● 打包成指定格式分发包,...
xjar-maven-plugin 项目相关jar包。包括xjar-maven-plugin-4.0.2.jar loadkitv1.0.1.jar xjar-4.0.2.jar
dockerfile-maven-plugin 支持 maven 直接发布项目至 docker 镜像库
Maven使用tomcat8-maven-plugin插件
eclipse-maven3-plugin插件 包含apache-maven-3.3.9和eclipse-maven3-plugin
echo-maven-plugin.zip,Echo Maven插件旨在打印
解决tomcat8-maven-plugin-3.0-r1655215.jar阿里云同有的问题。放到路径org\apache\tomcat\maven\tomcat8-maven-plugin\3.0-r1655215\就可以了
maven-tomcat-plugin让maven与tomcat配合得很好。它可以把应用部署到Tomcat服务器,也可以把tomcat作为内嵌服务器启动,就像jetty一样。 使用JPDA启动tomcat的远程调试功能。这样就能与eclipse配合起来,轻松地实现...
maven-assembly-plugin-2.2-beta-5.jar
mvn se.vandmo:dependency-lock-maven-plugin:lock将创建一个dependencies-lock.json文件。 然后,您应该将该文件提交给您选择的源控件。 如果某些依赖项是同一多模块项目的一部分,则您可能希望这些依赖项与锁定...
mustache-maven-plugin.zip,在maven构建中运行胡子模板的maven插件。它接受yaml格式的上下文
java运行依赖jar包
java运行依赖jar包
findbugs-maven-plugin, 为了生成基于FindBugs分析器的报告,Maven Mojo插件 Maven 插件 最新快照请从这里下载最新的快照。构建findbugs-maven-plugin需求Java 7是必需的。这将允许分析字节码到 Java 8 findbugs-...
修改版tomcat7-maven-plugin-2.2.jar
yuicompressor-maven-plugin, 用于压缩 (Minify/Ofuscate/Aggregate) Javascript文件和使用 YUI 压缩器的CSS文件的Maven 插件 [[Flattr this git repo] ( http://api.flattr.com/button/flattr-badge-large.png)]...