I use the Gradle Java plugin and have the following source structure:
src/main/java/package1/
src/main/java/package2/
I want to create two source jars for each package directory, i.e.,
myproject-package1-sources-1.0.jar
myproject-package2-sources-1.0.jar
I can create the source jar for the whole project with:
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives sourcesJar
}
How can I create source jar for two projects with the appropriate names?
Edit: It could be that package1 and package2 are somewhere deeper like
src/main/java/a/b/e/package1/
src/main/java/x/y/z/package2/
It could also be possible that there are multiple packages1 and 2 like:
src/main/java/a/b/e/package1/
src/main/java/qwer/package1/
src/main/java/x/y/z/package2/
I want that that all files and subsequent files which are in folders named packages1
are includes it the first source jar and the same for the other package.