Multiple jar in a single project with application plugin


I’m facing some trouble with application/distribution plugin. I need to isolate some sources files of one project into a dedicated jar file. Theses sources are “patch sources” waiting for official publication of a new release of librairies that we used.
Thus my project folder looks like this :

- src / foo package
- libA_vX_patch/ foo2 package
- libB_vY_patch/ foo3 package

I’m successfully able to build a jar file with only foo2 & foo3 and another main jar file with foo. Here is how

def sourceDir = "src"

 def libA_Dir= " libA_vX_patch"
 def libB_Dir= " libB_vX_patch"

sourceSets {

	patchs {
		java {
			srcDirs = [libA_Dir, libB_Dir]
	main {
		java {
			srcDirs = [sourceDir _Dir]

task patchsJar(type: Jar) {
	baseName "patchs"
	version "1.0.0"

artifacts {
	archives patchsJar

dependencies {
	patchsCompile jogamp, log4j2
	compile sourceSets.patchs.output

	compile jogamp,log4j2

But when I’m using the distZip task, in the zip file I get the main jar file and other dependencies but not the ‘patch’ jar file. Instead I get the class files directly (ie foo2/foo3) in a directory.

I’d like to get the patch jar in my lib directory of distribution and I do not understand How I can do that.

I need help.

Many thanks.