Skip to content

Apply some sbt task/commands on only the modules/sub-modules (and their reverse dependencies) based on git changes

License

Notifications You must be signed in to change notification settings

elarib/partial-sbt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Maven Central

Partial-sbt

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:

Requirements

  • SBT
  • Git managed repository.

Setup

Using Published Plugin

Maven Central

Add sbt-assembly as a dependency in project/plugins.sbt:

addSbtPlugin("com.elarib" % "partial-sbt" % "0.1")

Usage

Applying the plugin in your build.sbt

enablePlugins(com.elarib.PartialSbtPlugin)

changedProjects task

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

metaBuildChangedFiles task

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

How it works

1. Get changed files

jgit is used to list the diff between two branches or two commits.

2. Check if there is some main metabuild file changed

If yes, the whole project was changed, and they will be a need to reload (or build/test ...) If no, continue to next step.

3. List all modules impacted

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).

TODO

  • Apply commands to changed modules.
  • Deploy to some maven repo manager.

License

Copyright (c) 2019 Abdelhamide EL ARIB

Published under The MIT License.

About

Apply some sbt task/commands on only the modules/sub-modules (and their reverse dependencies) based on git changes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages