Skip to content
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

if-git-diff #30

Closed
nedtwigg opened this issue Jan 5, 2022 · 1 comment
Closed

if-git-diff #30

nedtwigg opened this issue Jan 5, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@nedtwigg
Copy link
Member

nedtwigg commented Jan 5, 2022

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 nedtwigg changed the title Include gradle subprojects based on whether they have changes in git if-git-diff Jan 5, 2022
@nedtwigg nedtwigg added the enhancement New feature or request label Jan 5, 2022
@nedtwigg
Copy link
Member Author

nedtwigg commented Jan 13, 2022

Released in 2.4.0, docs at IF_GIT_DIFF.md.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant