Create a highly customizable Gradle build

To get a highly customizable Gradle build script in conjunction with Dockerizor for example we wanted to use plausible defaults which can be easily overriden during testing or for special purposes like creating milestones/releases.

configure(virgoProjects) {
  apply plugin: 'com.eclipsesource.dockerizor'

  dockerizor {
    tag = System.getenv("dockerizor.tag") ?: 'latest'

    createLocalCopy = System.properties['dockerizor.createLocalCopy'] ?: false
    removeAdminConsole = System.properties['dockerizor.removeAdminConsole'] ?: true
    removeSplash = System.properties['dockerizor.removeSplash'] ?: true

    virgoVersion = System.getenv("dockerizor.virgoVersion") ?: 'latest'
  }
}

For testing purposes it's easy to create a local copy of the lates Virgo (including the admin console):

./gradlew -Ddockerizor.createLocalCopy=true -Ddockerizor.removeAdminConsole=false dockerize

And to create a milestone run:

./gradlew -Ddockerizor.tag=3.6.0.M03 -Ddockerizor.virgoVersion=3.6.0.M03 dockerize

Credits for the idea to use the elvis operator go to: Define a variable and set it to a default value if something goes wrong during definition