Gajendra Kumar
Gajendra Kumar

Reputation: 918

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?

Upvotes: 9

Views: 3886

Answers (1)

Narendra Mathuriya
Narendra Mathuriya

Reputation: 90

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>

Upvotes: 8

Related Questions