After hours of researching and trying I hope that someone can explain how we can have Gradle including classes of one or more subproject into a specific jar.
Lets say we have just three modules
- Core
- App
- Web
Obviously the App
and Web
project artifacts (jars) should contain all classes from the Core
project.
Settings gradle:
rootProject.name = 'MyProject' include 'MyProjectCore' include 'MyProjectApp' include 'MyProjectWeb'
MyProjectApp / MyProjectWeb:
... dependencies { ... compile project(':MyProjectCore') }
The projects can be compiled but the output jars do not contain the core classes.
Advertisement
Answer
Okay finally I found a working solution even if it might not be the best.
For the App
and Web
projects I overwrite the jar
task like this to add the source sets of the Core
module.
jar { from project.sourceSets.main.allSource from project(":MyProjectCore").sourceSets.main.java.srcDirs }