Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude resources from dependency jar

I have a maven projects let's call it A which has dependency on two maven projects B, C. Both B and C has a file in resources with same name let say x.xml. I want to exclude this x.xml from B(I don't want to write exclude it from B's jar in M2) jar when building A's War. means it should be present in B's jar but when this jar is copied to A's war should not available. Is it possible?

like image 315
Gajendra Kumar Avatar asked Mar 07 '16 10:03

Gajendra Kumar


1 Answers

Delete file from dependency jar using truezip-maven-plugin for example

<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/mywar-webapp.war/WEB-INF/lib/dependency.jar/dirName/</directory>
                <includes>
                    <include>fileName.xml</include>
                </includes>
            </fileset>
        </configuration>
    </execution>
</executions>

like image 87
Narendra Mathuriya Avatar answered Nov 16 '22 04:11

Narendra Mathuriya