Standardizing buildscript with Corporate plugin


(Kyle Chamberlin) #1

I work for a large enterprise and we are beginning to use gradle, I am hoping to greatly reduce the amount of copy/paste for build.gradle files moving forward. After watching the video on standardizing gradle for enterprise

It seemed that the best thing to do was to create a corporate binary plugin. The goals of this plugin are threefold:

  1. apply the company standard plugins
    a. spring-boot
    b. artifactory
    c. maven-publish
    d. jacoco
    e. sonarqube

  2. apply the company standard configurations for these plugins as default
    a. use spring dependency management with the appropriate version of the spring-cloud BOM
    b. define out artifactory urls, authentication schemes, etc
    c. set up our jacoco reporting settings
    d. ensure that the default setup for sonarqube includes everything we would expect.

  3. remove as much boilerplate as possible to make using the company standard tooling as simple as:

      plugins {
        id "companyname" version "1.0.0"

it would seem as though the two pass approach will make this difficult, as I cannot apply spring-boot or artifactory plugins without adding them to the classpath in the buildscript closure, which defeats the entire purpose of applying them with the plugin in the first place.

So I guess, before I spend too much more time investigating, testing, and failing, I want to know is this something that we can do with gradle? would using the milestone 2 of gradle 3 aid in accomplishing any of these tasks?

Any and all help is appreciated.

(Mark Vieira) #2

You can do this by simply making those plugins dependencies of your plugin. They will then be put on the build script classpath as transitive dependencies.

(Kyle Chamberlin) #3

If I understand correctly, you are saying that in my plugin project I would have a build.gradle like this:

dependencies {
  compile localGroovy()
  compile gradleApi()
  compile( group: "org.springframework.boot", name: "spring-boot-gradle-plugin", version: "1.4.0")

then in my CustomPlugin.groovy

void apply(Project project) {

And this would allow me to apply my custom plugin and have access to all of the spring-boot plugin features?

apply plugin: "custom"

bootRun {
  addResources = true

(Mark Vieira) #4

Yep. That is exactly correct.