使用Maven从依赖项jar中删除文件 [英] Remove file from dependency jar using maven
问题描述
我正在尝试从包含在Maven的war文件中的依赖项jar中删除文件.我正在将战争部署到JBoss 5.1,有问题的jar中包含一个我不需要的persistence.xml文件.
I am trying to remove a file from a dependency jar that I am including in my war file in maven. I am deploying the war to JBoss 5.1 and the jar in question contains a persistence.xml file that I don't want.
这是怎么回事:
my-webapp.war
|
`-- WEB-INF
|
`-- lib
|
`-- dependency.jar
|
`-- META-INF
|
`-- persistence.xml
在发动战争时,我想删除persistence.xml,任何人都知道是否可以轻松做到这一点?
When I am building my war, I want to remove persistence.xml Any one have any idea if this can be done easily?
推荐答案
无法立即使用AFAIK,您必须在package
之后使用Maven AntRun插件来做一些肮脏的事情:
Not available out of the box AFAIK, you'll have to use the Maven AntRun plugin after package
to do a few dirty things:
- 将战争解压缩到临时目录中
- 将依赖项解压缩到另一个临时目录中
- 从依赖项中删除文件
- 将依赖项的临时目录重新压缩到jar中
- 将依赖关系移回战争的temp目录
- 将Web应用程序的临时目录压缩回一战
- 删除依赖项的临时目录
- 删除Web应用程序的临时目录
- ant task to remove files from a jar
- RE: Removing a file from .jar file
现在,如果问题在于JBoss正在部署persistence.xml
中定义的持久性单元(并且您不希望这样做),那么可能会有更好的解决方案.看来您可以在jboss-ignore.txt
文件中声明要忽略的文件,例如:
Now, if the problem is that JBoss is deploying the persistence unit defined in the persistence.xml
(and you don't want that), there might be a better solution. It seems that you can declare files to ignore in a jboss-ignore.txt
file, for example:
WEB-INF/lib/dependency.jar/META-INF/persistence.xml
该功能已经存在,但我从未使用过.
The feature is there, but I've never used it.
- Excluding persistence.xml from deployment
- JBoss5 custom metadata files
这篇关于使用Maven从依赖项jar中删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!