mirzak
mirzak

Reputation: 1047

How to list all usages of a gradle module

I have a project with multiple modules (gradle modules) and some are depend on some others, for example :modules:backend:core has a project dependency on :modules:libraries:util:core and some others.

In my gitlab CI job I am able to tell when there are changes within some module (e.g. :modules:libraries:util:core) by listening to something like modules/libraries/util/core/**/*, and then triggering a build of that changed module.

Now the issue I have is how to figure out where this module is used, so that I can build the other side also (in this example I would need to build :modules:backend:core once :modules:libraries:util:core is changed).

Is there some way to list all usages of given module ?

Upvotes: 0

Views: 875

Answers (2)

Sergey
Sergey

Reputation: 3721

Gradle performs incremental builds, so telling it to build everything will actually build only the changed parts.

Upvotes: 0

Stanley Ko
Stanley Ko

Reputation: 3497

https://github.com/vanniktech/gradle-dependency-graph-generator-plugin

You can use this plugin to create "your project module dependency graph"

./gradlew generateProjectDependencyGraph

app module dependency graph

or "whole dependency graph".

./gradlew generateDependencyGraph

You can find this file from app/build/reports/dependency-graph and app/build/reports/project-dependency-graph directory.

The folder includes three files: png, svg and dot. In the dot file, you can get the module dependency.

":app" -> ":base" ["style"="dotted"]    
":app" -> ":moduleA" ["style"="dotted"]
":moduleA" -> ":base" ["style"="dotted"]

Upvotes: 2

Related Questions