How to configure gradle to build a source jar?


(Paul Jimenez) #1

This seems simple, but I can’t find a pointer on how to do it anywhere. I’ve got a large multimodule project, and I’ve got it building class-only jars(the default), but I also need it to build source-including jars. How do I do this? Just copy the java source over to the build dir? or is there some other way?


(René Groeschke) #2

You can achieve this by adding

task jarSources(type:Jar){
    from sourceSets.main.allSource
    classifier = 'source'
}

to your sub projects