Skip to content

orangain/monodiff-example-multi-project

Repository files navigation

monodiff-example-multi-project

This is an example project to use monodiff with Gradle multi-project build. It is worth mentioning that monodiff itself does not depends on Gradle.

Description

In this example, there are four subprojects:

They have the following dependency:

Both apps/account-app and apps/inventory-app depend on libs/profile and only apps/account-app depends on libs/greeter

By using monodiff, only changed apps can be built as follows:

  • When the apps/inventory-app is changed, only the apps/inventory-app will be built. CI result
  • When the libs/greeter is changed, only the apps/account-app will be built. CI result
  • When the libs/profile is changed, both the apps/account-app and the apps/inventory-app will be built. CI result

Details

This dependency is declared in build.gradle.kts of each app.

dependencies {
    implementation(project(":libs:greeter"))
    implementation(project(":libs:profile"))
    // ...
}

Aside from this, monodiff.json declares dependency for monodiff.

{
  "apps/account-app": {
    "deps": ["build.gradle.kts", "settings.gradle.kts", "libs/greeter", "libs/profile"]
  },
  "apps/inventory-app": {
    "deps": ["build.gradle.kts", "settings.gradle.kts", "libs/profile"]
  }
}

Each key, e.g. apps/account-app, represents a directory to be rebuilt when its dependencies are changed. For example, apps/account-app will be rebuilt when build.gradle.kts, settings.gradle.kts or files under apps/account-app, libs/greeter or libs/profile are changed.

In this monodiff.json, only apps are listed and libs are not listed. This is because what we want to detect here is affected roots of dependency. When the affected app is built, depending libs will be automatically built by the Gradle's dependency management system.

By default, monodiff command outputs affected sub-projects as follows:

$ git diff --name-only origin/master | monodiff
apps/account-app
apps/inventory-app

When you use Gradle multi-project build, there are some useful options. The output of the following command can be used as an argument of gradle command to build only affected sub-projects.

$ git diff --name-only origin/master | monodiff --prefix ":" --separator ":" --suffix :build
:apps:account-app:build
:apps:inventory-app:build

About

Example project to use monodiff with Gradle multi-project build

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages