Custom Gradle Plugin Understanding


(Gale Hood) #1

Hi- I’m new to building custom gradle plugins; I’ve followed several examples online and have built a custom plugin that can carry out tasks that do various things, and can accept command line arguments. However, it was proof of concept, and I built the plugin, globalPlugin, within a folder, custom-plugin , in the root of my project, projectA.

I want to be able to have this plugin work for several different projects, projectB, projectC, etc, not just projectA. What is the best way to go about creating this plugin? Should it have it’s own build.gradle file (as in, projectA would have a
build.gradle, with the following line:
apply plugin: globalPlugin
and within the custom-plugin directory, I would have another build.gradle with the following:
uploadArchives…
)?

Also, currently I am using the task uploadArchives to publish to a local repository (again, POC). But when I publish the jar’s to a proper repo, should I still be using uploadArchives?

I am trying to orient myself in the best way possible to write this plugin, any help is much appreciated.