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

How to use this to generate a Module dependency graph? #71

Closed
ScottCooper92 opened this issue Sep 5, 2018 · 6 comments
Closed

How to use this to generate a Module dependency graph? #71

ScottCooper92 opened this issue Sep 5, 2018 · 6 comments

Comments

@ScottCooper92
Copy link

This is more of a question than an issue.

I have a multi module project and I'd like to generate a graph of the dependencies between modules only. I've created my own Generator and I'm trying to filter the dependencies and the dependencies of those dependencies but I'm not getting the desired result.

def moduleGenerator = new Generator(
        "modules",
        { dependency -> dependency.getName().startsWith("Android:") },
        { dependency ->
            dependency.getChildren().forEach {
                println("Dependency: " + dependency.getName() + " child: " + it)
            }

            true
        })

It correctly generates a graph with my main module at the top and each of the other library modules connected to it, but some of these library modules depend on each other which isn't being displayed in the graph.

It seems like dependency.getChildren() can only see dependencies marked as "api" and not "implementation" which my modules are, implementation project(':network-provider') for example.

Any ideas?

@vanniktech
Copy link
Owner

I have a multi module project and I'd like to generate a graph of the dependencies between modules only.

I also want this. Started with it here - https://github.com/vanniktech/gradle-dependency-graph-generator-plugin/tree/projectdotgenerator - but didn't get that far.

I don't think you can use the Generator API to achieve this. I tried this but could not get it to work.

Also, I'm not sure how to model the new API. Let me know what you'd want.

@ScottCooper92
Copy link
Author

I basically just want a way to show the iOS team the way we've modularised our code base so that we can align ourselves, the output of this plugin would have been perfect had I been able to show modules only.

I haven't got much experience with gradle so I'm probably not going to be much help, that being said if I find some time I may take a look and see if I can figure something out.

@vanniktech
Copy link
Owner

vanniktech commented Sep 11, 2018

Getting closer. Hopefully, I have something by the end of this week.

@egor-n
Copy link

egor-n commented Sep 16, 2018

Take a look at the projectDependencyGraph task which generates a dependency tree of all Gradle modules in a project. You need the dot program, though, so run brew install graphviz first.

@vanniktech
Copy link
Owner

Yeah my solution is based on the one from Jake.

@AlexTrotsenko
Copy link

I had similar issue, I was able to achieve by simply checking the name of the dependency.
I have all my modules in the top level folder called "main_android".

So I have updated code from example to following and it works just fine:

def firebaseGenerator = new Generator(
        "allModules", // Suffix for our Gradle task.
            // ! THE CHANGE IS HERE !
        { dependency -> dependency.getName().startsWith("main_android") }, // Only want Firebase.
        { dependency -> true }, // Include transitive dependencies.
        { node, dependency -> node.add(Style.FILLED, Color.rgb("#ffcb2b")) }, // Give them some color.
)

It works because when you print the names of all dependencies they are as following:

...
main_android:preferences-service:unspecified
main_android:persistence-service:unspecified
org.easytesting:fest-assert-core:2.0M10
com.squareup.retrofit2:retrofit:2.6.2
com.squareup.retrofit2:converter-scalars:2.1.0
...

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

No branches or pull requests

4 participants