Duplicated Classes Output jar with Gradle


(Sacha "iSach" Lewin.) #1

Hello!
I’m using Gradle with IntelliJ. When I build my jar, it creates a jar with duplicated classe for the submodule “core”. 3 classes. Here’s my build.gradle of the whole project.

allprojects {
    apply plugin: 'java'
    apply plugin: 'eclipse'
    apply plugin: 'idea'

    group = 'be.isach'
    version = '1.2-RELEASE'

    compileJava.options.encoding = 'UTF-8'

    configurations {
        shaded
        compile.extendsFrom shaded
    }

    afterEvaluate{
        jar {
            dependsOn configurations.shaded
            from configurations.shaded.collect {
                it.isDirectory() ?
                        it :
                        zipTree(it)
            }
        }
    }
}

dependencies{
    subprojects.each{ p ->
        shaded(p) {
            transitive false
        }
    }
}

subprojects {
    repositories {
        mavenLocal()
        mavenCentral()
        ivy {
            url 'http://www.tcpr.ca/files/'
            layout 'pattern', {
                artifact '[module]/[module]-[revision].[ext]'
            }
        }
        maven {
            url 'https://hub.spigotmc.org/nexus/content/groups/public/'
        }
        maven {
            url 'https://oss.sonatype.org/content/groups/public/'
        }
        maven {
            url 'http://nexus.theyeticave.net/content/repositories/pub_releases'
        }
        maven {
            url 'http://repo.md-5.net/content/repositories/releases'
        }
        maven {
            url 'http://repo.howaner.de'
        }
        maven {
            url 'http://repo.dmulloy2.net/content/groups/public/'
        }
    }
}

Here’s a screenshot of the output:

I searched a lot on Google, but found nothing about this. I don’t see what could be wrong with it.
Thanks in advance!


(Thomas Newman) #2

Try:

//     ensure you're excluding duplicates
jar {
    duplicatesStrategy = 'exclude'
}