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
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>
                        (With last version of maven-assembly-plugin at this time : 3.0.0)
I had the same problem with an assembly build.
I had tow dependencies with the same properties file but with a different content (one good and the other overwritting the first with missing declarations).
The problem was that i finally had the bad configuration file replacing the other in my assembly jar.
The only cleanest solution i found to overwrite the file was to :
1 - Add the good file that i wanted to keep for the build in my project :
ex: src/main/resources/META-INF/services/myfileWhichOverwriteTheBadDependenciesRessources.xml
2 - Add a fileset with 'filtered' setted to 'true' in my assembly descriptor :
    <fileSet>
        <directory>${project.main.resources}/META-INF</directory>
        <outputDirectory>META-INF</outputDirectory>
        <filtered>true</filtered>
    </fileSet>
(the 'project.main.resource' property is setted to 'src/main/resources' in my case)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With