Exclude default contents of Distribution Plugin


(Lars Kaulen) #1

Probably a pretty easy to answer question, but I can’t find the correct approach neither in the documentation nor in the forum.
When using the Distribution Plugin, the (by the ‘distZip’-task) generated Zip contains all runtime dependencies in the ‘lib’ folder. I want to use this feature but exclude specific jars, as they depend on the java version the costumer is using and need to be placed there manually. I tried to use the following code:

distributions.main.contents {
    into('lib') {
        from(configurations.runtime).exclude('**/patternToExclude*')
    }
}

Problem is afterwards every jar (except the ones excludes) are included twice in the zip, as they got already included by the default behavior.
What would be the common way to resolve this? Do I need to perform an explicit delete operation on the zip after it has been created?