Project Dependency with SourceSet Dependencies


(Lars Kaulen) #1

Let’s say I have two projects, project(’:a’) and project(’:b’). In project(’:a’) there are two source sets main and extended, extended needs the classes from main, so I did something like

configurations {
    extendedCompile.extendsFrom main
    extended.extendsFrom extendedCompile
}
dependencies {
    extendedCompile sourceSets.main.output
}
task extendedJar(type: Jar) {
    baseName = 'extended'
    from sourceSets.extended.output
}
artifacts {
    extended extendedJar
}

Now I want to use all of these classes (aswell from main as from extended) in project(’:b’) so I configured this like

dependencies {
    compile project(':a')
    compile project(path: ':a', configuration: 'extended')
}

On project(’:b’) I’m using the application plugin and my problem is, when building the distZip, besides the main.jar and extended.jar the classes from sourceSet-main are also directly placed in the ‘lib’-folder, probably as extended got a dependency on ‘sourceSets.main.output’. Is there a way to just have the both jars in the zip?
Thanks in advance.