Hi, I am trying to migrate a Maven build to Gradle, and have a question to do with inheritance of the parent pom.xml definitions from several unrelated projects. So the parent pom.xml defines some very basic things like:
- The java version - The location of global nexus repos - The check style definitions - The code formatter definitions - The code coverage tool
The parent pom is been reused in the several because it is pulled from Nexus by the several projects. What is the best way to implement the same thing in Gradle, do I have to create a custom plugin with a separate project that gets pushed into the nexus ? Or can I just use a simple build.gradle file that gets called from the several projects ?
Thank Oscar
Hi Oscar,
you can either write a binary plugin (i.e. a plugin class implementing ‘org.gradle.api.Plugin’) and publish it to Nexus, or write a script plugin (same syntax as ‘build.gradle’) and publish it to an HTTP server. In th e former case, client builds will declare the plugin (dependency) in a ‘buildscript’ block, and apply the plugin with ‘apply plugin:’. In the latter case, client builds will apply the plugin with ‘apply from: “http://…”’.
Compared to binary plugins, script plugins currently have a few limitations. In particular, they aren’t currently cached. (This will likely change at some point.) As a consequence, builds applying script plugins will only work if they can connect to the HTTP server hosting the scripts.