Gradle - Create multiple JARs


(Jatin Pabari) #1

Hi,

My project structure is:

parent
–child1
–child2
–child3

My requirement is to create multiple JARs such as child1.jar, child2.jar etc.) While java plugin takes care of this, I would like to create couple of JARs which would contain mix and match of source files from child projects (such as customized1.jar comprising of classes from child1 and child3).

When I execute multiple JAR tasks in my build.gradle, the build directory contains only the jar coming from the last jar task overwriting the others.

For example ,

task custom1 (type:Jar) {
archiveBaseName: ‘custom1’
}

task custom2 (type:Jar) {
archiveBaseName: ‘custom2’
}

the build directory always shows custom2.jar. Is there a way to retain all the produced jars?