Overwrite resource file with maven assembly plugin

Loc Phan picture Loc Phan · May 17, 2011 · Viewed 8.6k times · Source

I use maven-assembly-plugin with "jar-with-dependencies" to package jar. There are 2 dependencies artifact having log-back.xml. The second artifact is depend on the first one. I want to have log-back.xml of the second artifact in final jar, but it always contain log-back.xml of the first one. So how can I control this?

Thanks

Answer

Raghuram picture Raghuram · May 17, 2011

You can use the unpackOptions to achieve this. Try something like the following:

<assembly>
...
    <dependencySets>
        <dependencySet>
            <outputDirectory>/</outputDirectory>
            <includes>
                <include>${groupId}:${artifact.whose.logback.is.to.be.excluded} </include>
            </includes>
            <unpack>true</unpack>
            <unpackOptions>
                <excludes>
                    <exclude>**/logback.xml</exclude>
                </excludes>
            </unpackOptions>
        </dependencySet>
        <dependencySet>
            <outputDirectory>/</outputDirectory>
            <excludes>
                <exclude>${groupId}:${artifact.whose.logback.is.to.be.excluded}</exclude>
            </excludes>
            <unpack>true</unpack>
        </dependencySet>
    </dependencySets>
</assembly>