I have a project generating many (>100) small Java tools.
For years I've used a GNU Makefile (see here) to manage the compilation of my tools (much more compact + simplier than an ant/Maven file). Basically I declared a Makefile macro that creates an executable jar using small set of parameters:
define compile-htsjdk-cmd
$(1) : ${htsjdk.jars}
$(addsuffix .java,$(addprefix ${src.dir}/,$(subst .,/,$(2))))
$(3)
(...)
${JAVAC}
-d ${tmp.dir}
-g -classpath "$$(subst $$(SPACE),:,$$(filter %.jar,$$^))"
-sourcepath ${src.dir}:${generated.dir}/java $$(filter %.java,$$^)
(...)
${JAR} cfm ${dist.dir}/$(1)$(if ${standalone},-fat).jar ${tmp.mft} -C ${tmp.dir} .
(...)
endef
$(eval $(call compile-htsjdk-cmd,referencetovcf,${jvarkit.package}.tools.misc.ReferenceToVCF,${jcommander.jar}))
$(eval $(call compile-htsjdk-cmd,sam2json,${jvarkit.package}.tools.misc.SamToJson,${jcommander.jar} ${gson.jar} ))
$(eval $(call compile-htsjdk-cmd,sam2psl,${jvarkit.package}.tools.misc.SamToPsl,${jcommander.jar} ))
$(eval $(call compile-htsjdk-cmd,sam2tsv,${jvarkit.package}.tools.sam2tsv.Sam2Tsv,${jcommander.jar} ))
(...)
The system worked for years without any problem.
Now, I'd like to handle more configurations (using more than one jdk, adding special things in some Manifest files ets...) And as far as I understand, gradle would be the best tool to achieve this.
I saw some examples with only one target but it's not clear to me how I could easily transform my Makefile into a gradle file. Can I put all my targets in the same build.gradle file? How can I (and should I?) mimic what I did with my makefile macro?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…