Skip to content

if-git-diff #30

@nedtwigg

Description

@nedtwigg

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
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions