This is a fork of the partial-sbt project. While it includes new features not present in the original project, it has been published to a private Maven repository. Feel free to fork the project and modify it per the license.
The goal is simple: Apply some sbt tasks/commands on only the modules/sub-modules changed between two git commits or two git branches, including their reverse dependencies.
The main purpose behind, is to reduce build, test & integration test times.
For example:
- Test and deploy only modules (and their reverse dependencies) that have been changed between develop branch and feature x branch
- Package only modules (and their reverse dependencies) that have been changed between two git commits.
Project example:
- Check out : https://github.com/elarib/partial-sbt/blob/master/src/sbt-test/test-projects/multi-module-project/build.sbt
- Change scenarios : https://github.com/elarib/partial-sbt/tree/master/src/sbt-test/test-projects/multi-module-project/changes
- Expected output of each change : https://github.com/elarib/partial-sbt/tree/master/src/sbt-test/test-projects/multi-module-project/expected
- SBT
- Git managed repository.
Add sbt-assembly as a dependency in project/plugins.sbt
:
addSbtPlugin("com.whisk" % "partial-sbt" % "version")
enablePlugins(com.elarib.PartialSbtPlugin)
Now you have the changedProjects
task, that list you all the modules (and their reverse dependencies) changed.
You have the possibility to get the changed projects :
- Between two git branches using:
> changedProjects gitBranch sourceLocalBranch targetLocalBranch
- Between two git commits using:
> changedProjects gitCommit oldCommitId newCommitId
List you all the changed meta build files :
- Between two git branches using:
> metaBuildChangedFiles gitBranch sourceLocalBranch targetLocalBranch
- Between two git commits using:
> metaBuildChangedFiles gitCommit oldCommitId newCommitId
jgit
is used to list the diff between two branches or two commits.
If yes, the whole project was changed, and they will be a need to reload (or build/test ...) If no, continue to next step.
List all modules impacted based on the changed files (step1) with all their reverse dependencies.
And finally list them, or apply the command or task need (not implemented yet).
- Apply commands to changed modules.
- Deploy to some maven repo manager.
Copyright (c) 2019 Abdelhamide EL ARIB
Published under The MIT License.