Basic tip request on how to implement a java build

What i have:
a source folder with java and resource files (nothing special here)
What i need as output:
6 jars, where each contains partly a subset of the compiled java sources and additionally generated
javadocs with a custom doclet; the infos which sources (and corresponding documentation files)
are contained in other resource files

I am new to gradle and “nativly” a java programmer. I see, that i have to change my mind to “think
gradle”. Therefor i am asking here.

Should i implement a custom task? Should i devide into 6 source sets. Do i have to make
6 times n different tasks? My idea of a solution is to have a “function” that i can feed for each
jar (Configuration, i think) with the source set and the option, whether to include class files or not…
Thx in advance