Skip to content

NEW PROJECT ANNOUNCEMENT: blowdryer #513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nedtwigg opened this issue Jan 15, 2020 · 0 comments
Closed

NEW PROJECT ANNOUNCEMENT: blowdryer #513

nedtwigg opened this issue Jan 15, 2020 · 0 comments

Comments

@nedtwigg
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant