How to include src java files, classes, resources in separate directories in jar?


I am trying to generate a jar using gradle/groovy code. However, my jar structure needs to be following:


However, when I add following code, all classes and src files and res get included under ‘src’ folder in jar

My code:

jar {
baseName = “new”
//from ‘sourceSets.resources.srcDirs’
//exclude ‘’
//from ‘sourceSets.main.output.classesDir’
//into ‘com’
//from ‘’
//into ‘src’
from ‘src/main/java’
into ‘src’
manifest {
from ‘src/main/resources/’

please let me know how to generate jar with required str?