maven war plugin jar如何去掉不想打进去的包

maven war plugin插件中warSourceExcludes和packagingExcludes的差别 - 简书
<div class="fixed-btn note-fixed-download" data-toggle="popover" data-placement="left" data-html="true" data-trigger="hover" data-content=''>
写了819字,被0人关注,获得了0个喜欢
maven war plugin插件中warSourceExcludes和packagingExcludes的差别
maven的war plugin插件里有两个参数warSourceExcludes和packagingExcludes,从clean package后的效果来说,他们都能起到打war包时不包含指定文件夹或者指定文件的作用。
但是他们实现的方式不一样。按照plugin中对这两个参数的说明:
warSourceExcludes: The comma separated list of tokens to exclude when copying the content of the warSourceDirectory.
packagingExcludes: The comma separated list of tokens to exclude from the WAR before packaging.
With packagingExcludes, the tokens are completely excluded from the final war file. With warSourceExcludes, the tokens are just ignored when copying the war directory into the war file. As a result, if the tokens are present in the webappDirectory for example, they will not be ignored when using warSourceExcludes but will be when usingpackagingExcludes.
warSourceExcludes是在拷贝文件到war文件夹时忽略掉指定文件或者文件夹(但是如果war命令前没有clean指令,而war文件夹下已经包含了指定文件或者文件夹时,最后生成的war包里还是会包含这些文件或文件夹,哪怕没有拷贝它们到war文件夹).
packagingExcludes是在生成war包时不包含指定文件或文件夹到war文件中,不论它们是否存在于war文件夹下。
因此慎重起见,更倾向于使用packagingExcludes参数。
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
选择支付方式:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
您的访问请求被拒绝 403 Forbidden - ITeye技术社区
您的访问请求被拒绝
亲爱的会员,您的IP地址所在网段被ITeye拒绝服务,这可能是以下两种情况导致:
一、您所在的网段内有网络爬虫大量抓取ITeye网页,为保证其他人流畅的访问ITeye,该网段被ITeye拒绝
二、您通过某个代理服务器访问ITeye网站,该代理服务器被网络爬虫利用,大量抓取ITeye网页
请您点击按钮解除封锁&<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
您的访问请求被拒绝 403 Forbidden - ITeye技术社区
您的访问请求被拒绝
亲爱的会员,您的IP地址所在网段被ITeye拒绝服务,这可能是以下两种情况导致:
一、您所在的网段内有网络爬虫大量抓取ITeye网页,为保证其他人流畅的访问ITeye,该网段被ITeye拒绝
二、您通过某个代理服务器访问ITeye网站,该代理服务器被网络爬虫利用,大量抓取ITeye网页
请您点击按钮解除封锁&温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
I am a quiet boy.
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
&build&&&&&&&plugins&&&&&&......&&&&&&&plugin&&&&&&&&&&&groupId&org.apache.maven.plugins&/groupId&&&&&&&&&&&artifactId&maven-war-plugin&/artifactId&&&&&&&&&&&version&2.0.2&/version&&&&&&&&&&&configuration&&&&&&&&&&&&&&warSourceExcludes&WEB-INF/lib/log4j-${log4j.version}.jar&/warSourceExcludes&&&&&&&&&&&/configuration&&&&&&&&/plugin&&&&&&&/plugins&&&&&/build&&&&当然你可以指定war包的名称,输出的目录,webapp目录等等。可以在需要打包的工程中直接设定:&pom&war&/pom&这样在install的时候就会对此工程生成相应配置的war包,原来此web工程依赖的其他工程全部会以jar包的形式出现在lib目录下,所以不需要再去关心war包中集成的jar包是否完整,maven已经帮你做完了。&顺便提一句,在jboss中发布war包,如果包中包含log4j.jar,会报错,所以在本例中将此jar包排除在外。&方法二:不用war插件,而是用到另外三个插件:maven-dependency-plugin 、maven-antrun-plugin&、 build-helper-maven-plugin下面分别说明下着三个插件在此过程扮演的角色:maven-dependency-plugin :相当于数据收集器,该依赖那些jar包,该加载那些resource信息。maven-antrun-plugin:完成收集完文件夹的压缩和包的重命名。build-helper-maven-plugin:让压缩包拥有男人本色,oh sorry 是war本色。&在写pom.xml配置前,先说明下目录结构root||---template||---wardir&其中这两个目录都作为maven的独立工程,下面要写配置在wardir下的pom.xml中Xml代码&&&build&&&&&&&plugins&&&&&&&&&&plugin&&&&&&&&&&&&groupId&org.apache.maven.plugins&/groupId&&&&&&&&&&&&artifactId&maven-dependency-plugin&/artifactId&&&&&&&&&&&&version&2.0&/version&&&&&&&&&&&&executions&&&&&&&&&&&&&&&execution&&&&&&&&&&&&&&&&&&id&create-structure&/id&&&&&&&&&&&&&&&&&&phase&process-resources&/phase&&&&&&&&&&&&&&&&&&&goals&&&&&&&&&&&&&&&&&&&&&&&goal&unpack&/goal&&&&&&&&&&&&&&&&&&&&/goals&&&&&&&&&&&&&&&&&&&&configuration&&&&&&&&&&&&&&&&&&&&&&&&artifactItems&&&&&&&&&&&&&&&&&&&&&&&&&&&artifactItem&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&groupId&GROUPID&/groupId&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&artifactId&template&/artifactId&&&&&&&&&&&&&&&&&&&&&&&&&&&/artifactItem&&&&&&&&&&&&&&&&&&&&&/artifactItems&&&&&&&&&&&&&&&&&&&&&outputDirectory&&&&&&&&&&&&&&&&&&&&&&&&${project.build.directory}/${assembly.name}.war&&&&&&&&&&&&&&&&&&&&&/outputDirectory&&&&&&&&&&&&&&&&&&&&/configuration&&&&&&&&&&&&&&&&&/execution&&&&&&&&&&&&&&&&&execution&&&&&&&&&&&&&&&&&&&&&id&copy-libs&/id&&&&&&&&&&&&&&&&&&&&&&phase&process-resources&/phase&&&&&&&&&&&&&&&&&&&&&&&goals&&&&&&&&&&&&&&&&&&&&&&&&&&goal&copy&/goal&&&&&&&&&&&&&&&&&&&&&&&/goals&&&&&&&&&&&&&&&&&&&&&&&configuration&&&&&&&&&&&&&&&&&&&&&&&&&&artifactItems&&&&&&&&&&&&&&&&&&&&&&&&&&&&&artifactItem&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&groupId&jdom&/groupId&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&artifactId&jdom&/artifactId&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&/artifactItem&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&......&&&&&&&&&&&&&&&&&&&&&&&&&&/artifactItems&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&outputDirectory&${project.build.directory}/${assembly.name}.war/WEB-INF/lib&/outputDirectory&&&&&&&&&&&&&&&&&&&&&&&&/configuration&&&&&&&&&&&&&&&&&&&&&/execution&&&&&&&&&&&&&&&&/executions&&&&&&&&&&&/plugin&&&&&&&&&&&&plugin&&&&&&&&&&&&&&&&groupId&org.apache.maven.plugins&/groupId&&&&&&&&&&&&&&&&artifactId&maven-antrun-plugin&/artifactId&&&&&&&&&&&&&&&&version&1.3&/version&&&&&&&&&&&&&&&&executions&&&&&&&&&&&&&&&&&&&execution&&&&&&&&&&&&&&&&&&&&&&id&copy-config&/id&&&&&&&&&&&&&&&&&&&&&&phase&process-resources&/phase&&&&&&&&&&&&&&&&&&&&&&goals&&&&&&&&&&&&&&&&&&&&&&&&&&goal&run&/goal&&&&&&&&&&&&&&&&&&&&&&&/goals&&&&&&&&&&&&&&&&&&&&&&&configuration&&&&&&&&&&&&&&&&&&&&&&&tasks&&&&&&&&&&&&&&&&&&&&&&&&&&&copy&todir="${project.build.directory}/${assembly.name}.war"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&fileset&dir="src/main/resources"&/&&&&&&&&&&&&&&&&&&&&&&&&&&&/copy&&&&&&&&&&&&&&&&&&&&&&&&&&&zip&destfile="${project.build.directory}/${assembly.name}-${project.version}-war.zip"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&zipfileset&dir="${project.build.directory}/${assembly.name}.war"&includes="**\*.*"&&excludes="*.zip"&/&&&&&&&&&&&&&&&&&&&&&&&&&&&/zip&&&&&&&&&&&&&&&&&&&&&&&&&&&copy&file="${project.build.directory}/${assembly.name}-${project.version}-war.zip"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&tofile="${project.build.directory}/${assembly.name}-${project.version}.war"&/&&&&&&&&&&&&&&&&&&&&&&&&&/tasks&&&&&&&&&&&&&&&&&&&&&&&&&/configuration&&&&&&&&&&&&&&&&&&&&/execution&&&&&&&&&&&&&&&&/executions&&&&&&&&&&&/plugin&&&&&&&&&&&plugin&&&&&&&&&&&&&&&groupId&org.codehaus.mojo&/groupId&&&&&&&&&&&&&&&artifactId&build-helper-maven-plugin&/artifactId&&&&&&&&&&&&&&&version&1.4&/version&&&&&&&&&&&&&&&executions&&&&&&&&&&&&&&&&&&execution&&&&&&&&&&&&&&&&&&id&attach-artifacts&/id&&&&&&&&&&&&&&&&&&phase&package&/phase&&&&&&&&&&&&&&&&&&&&&goals&&&&&&&&&&&&&&&&&&&&&&&&&goal&attach-artifact&/goal&&&&&&&&&&&&&&&&&&&&&/goals&&&&&&&&&&&&&&&&&&&&&configuration&&&&&&&&&&&&&&&&&&&&&&&&&&artifacts&&&&&&&&&&&&&&&&&&&&&&&&&&&&&artifact&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&file&${project.build.directory}/${assembly.name}-${project.version}.war&/file&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&type&war&/type&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&/artifact&&&&&&&&&&&&&&&&&&&&&&&&&&&/artifacts&&&&&&&&&&&&&&&&&&&&&&/configuration&&&&&&&&&&&&&&&&&&&/execution&&&&&&&&&&&&&&&&/executions&&&&&&&&&&&&&/plugin&&&&&&&&/plugins&&&&/build&&&&当然这种方式也可以用来打ear包。对于打无页面操作系统的war包,个人认为用后者更灵活,当然建立假web工程,再依赖工程,通过第一种方式同样可以达到最终的结果。看个人喜好了。&结束语:maven真的很强大!
阅读(37312)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
loftPermalink:'',
id:'fks_',
blogTitle:'maven生成war包的两种方式',
blogAbstract:'&war包即对WEB应用程序进行打包,用于应用容器的部署。如在jboss中只要把war包丢入deploy目录下即可发布自己的应用了。打包方式有很多中,很多工具本身就支持此功能。下面主要介绍通过maven来操作的两种方式:方法一:&& 即第一反应的那种啦,就是利用maven的maven-war-plugin。',
blogTag:'',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:0,
publishTime:6,
permalink:'blog/static/',
commentCount:22,
mainCommentCount:22,
recommendCount:0,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:true,
hostIntro:'I am a quiet boy.\nI love my
hmcon:'1',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}

我要回帖

更多关于 maven war plugin 2.4 的文章

 

随机推荐