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 persis
I guess you would have to use the maven shade plugin (see link below)
Either build an Über-jar that includes your dependency minus the persistence-xml or just transform the dependency into something new that does not have the persistence.xml.
This should be the way to go:
http://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html
Sean
Not available out of the box AFAIK, you'll have to use the Maven AntRun plugin after package
to do a few dirty things:
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.
You can achieve this with the TrueZIP Maven Plugin.
This should work for your use case:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>truezip-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>remove-a-file-in-sub-archive</id>
<goals>
<goal>remove</goal>
</goals>
<phase>package</phase>
<configuration>
<fileset>
<directory>target/my-webapp.war/WEB-INF/lib/dependency.jar/META-INF</directory>
<includes>
<include>persistence.xml</include>
</includes>
</fileset>
</configuration>
</execution>
</executions>
</plugin>
Also see the examples.