Skip to content

NEW PROJECT ANNOUNCEMENT: blowdryer #513

Closed
@nedtwigg

Description

@nedtwigg

So you apply Spotless to a single-project build, and it looks like this:

// build.gradle
spotless { java {
  eclipse().configFile 'spotless.eclipseformat.xml'
}}

Then you have a multi-project build, so you factor out your spotless block into gradle/spotless.gradle:

// subproject/build.gradle
apply from: rootProject.file('gradle/spotless.gradle')

// gradle/spotless.gradle
spotless { java {
  // don't forget the 'rootProject.file()', or it won't work!
  eclipse().configFile rootProject.file('gradle/spotless.eclipseformat.xml')
}}

The chinese character for "dry" is 干. If you apply the blowdryer plugin, it lets you rewrite the above, but with fewer characters:

// subproject/build.gradle
apply from: 干.file('spotless.gradle')

// gradle/spotless.gradle
spotless { java {
  eclipse().configFile 干.file('gradle/spotless.eclipseformat.xml')
}}

But that's mostly a gimmick. The power is that - if you want - you can move spotless.gradle and spotless.eclipseformat.xml into a new git repository (a "script repository"), and you can point many different gradle builds to it. The convention is to name your script repository blowdryer-{orgname}. So if you put your gradle scripts and config files into diffplug/blowdryer-diffplug, then you can consume those scripts from other builds by doing this:

// settings.gradle
blowdryerSetup {
    github 'diffplug/blowdryer-diffplug', 'tag', '2.0.0' // can also use commit SHA
    //devLocal '../blowdryer-diffplug' // for local development
}

// subproject/build.gradle
apply from: 干.file('spotless.gradle')

// github.com/acme/blowdryer-acme/src/main/resources/spotless.gradle
spotless { java {
  eclipse().configFile 干.file('gradle/spotless.eclipseformat.xml')
}}

Performance-wise, because git commits and tags are immutable, it only needs to download the file once, ever, system-wide, so there's no measurable overhead in using it.

There's also a little more power you can tap into to help make apply from: scripts work better, and there are a ton of low hanging fruit which can make this a lot more powerful.

If you'd like to help signal boost this new effort, here is the release tweet.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions