3
\$\begingroup\$

I have two local maven projects A, and B. B is dependent on A.

A
|- resources/log4j2.xml

B
|- resources/META-INF/log4j.xml
|- Maven Dependencies
    |- A
    |- And other dependencies...

Both A, and B exports the log4j xmls to jar. However, as I only need the B/resources/META-INF/log4j.xml to my final B.jar, I tried to delete the log4j2.xml from A while packing B.jar.

To do the same, I used truezip:remove in B/pom.xml as follows:

<build>
...
<plugins>
    <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>verify</phase>
                <configuration>
                    <fileset>
                        <directory>B-jar-with-dependencies.jar</directory>
                        <includes>
                            <include>log4j2.xml</include>
                        </includes>
                    </fileset>
                </configuration>
            </execution>
        </executions>
    </plugin>
</plugins>
...
</build>

Note that this is executed verify state (post packaging) of lifecycle.

Though it is working as expected, I am wondering whether there is any side-effect of this or not. Any light in this regard would be great.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.