diffplug / spotless-changelog

The changelog is cast, let the versions fall where they may.
Apache License 2.0
45 stars 2 forks source link

if-git-diff #30

Closed nedtwigg closed 2 years ago

nedtwigg commented 2 years ago

In Spotless, we have an _ext folder full of builds which are very expensive to run. As a result, we only run them if we have to, and we have an elaborate and difficult-to-maintain CI setup to handle that.

It would be a lot easier if we could include projects dynamically based on a git diff. e.g.

// settings.gradle
plugins {
  id 'com.diffplug.if-git-diff'
}

ifGitDiff {
  baseline 'origin/main' // default value
  folder 'some-subfolder', {
    include 'some-subfolder'
  }
}

For the CI setup described above, instead of having 5 jobs for each of the 5 cases, you could now have just one job, and that job would do the correct thing based on what has changed.

A more complex example:

// settings.gradle
file('_ext').eachDirMatch(~/^(?!(\.|gradle)).*/) { dir ->
  ifGitDiff {
    folder dir, {
      include dir.name
      project(":${dir.name}").projectDir = dir
    }
  }
}
nedtwigg commented 2 years ago

Released in 2.4.0, docs at IF_GIT_DIFF.md.