我在项目中有一个jar文件,我需要从
中删除persistence.xml我发现了这个问题
Remove file from dependency jar using maven
但它似乎并不适合我。
我将以下内容添加到我的pom.xml
中<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/app/WEB-INF/lib/jarname/META-INF</directory>
<includes>
<include>persistence.xml</include>
</includes>
</fileset>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
如果jar被称为jarname.jar,我应该在路径中提到.jar。我想象不到。如果值得一提的话,我使用的是Maven 2.2.1。
答案 0 :(得分:4)
您可以使用maven antrun插件
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>environment.replace.configuration</id>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<delete
file="${project.build.outputDirectory}/WEB-INF/lib/jarname/META-INF/persistence.xml" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>