您的位置:首页 > 其它

Maven打包时排除某些文件

2018-01-08 17:14 471 查看
需求:有时会打不同环境的包,如测试、正式等;有时会要排除一些静态资源。

解决:使用maven-war-plugin插件加warSourceExcludespackagingExcludes这两个参数来配置。这两个参数的官网解释如下:

warSourceExcludes:The comma separated list of tokens to exclude when copying the content of the warSourceDirectory.

解释:warSourceDirectory是maven工程的src\main\webapp目录,warSourceExcludes参数决定不将哪些src\main\webapp目录下的文件copy到webappDirectory(一般是工程的target\${warName}目录)。

packagingExcludes:The comma separated list of tokens to exclude from the WAR before packaging. This option may be used to implement the skinny WAR use case. Note that you can use the Java Regular Expressions engine to include and exclude specific pattern using the expression %regex[]. Hint: read the about (?!Pattern).

解释:在生成webappDirectory(一般是工程的target\${warName}目录)后,要将该目录打包成.war后缀的压缩文件,packagingExcludes参数决定不将哪些webappDirectory目录中的文件打到war包中。

总结:两个参数是在不同阶段起作用的,需要注意的是warSourceExcludes只能排除src\main\webapp目录下的文件。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: