iurysza / module-graph

A Gradle Plugin for visualizing your project's structure, powered by mermaidjs
https://plugins.gradle.org/plugin/dev.iurysouza.modulegraph
MIT License
346 stars 13 forks source link

Empty generated graph #15

Closed ferinagy closed 8 months ago

ferinagy commented 1 year ago

After applying the plugin (version 0.4.0) to our project, the createModuleGraph task runs successfully, but the created graph is empty. I have seen https://github.com/iurysza/module-graph/issues/10 and in our case ./gradlew projects gives output of 100+ projects.

This is currently created graph:

### Dependency Diagram

```mermaid
%%{
  init: {
    'theme': 'dark'
  }
}%%

graph TB


I tried looking into the issue a bit and it seems that the `parseProjectStructure()` method is called before the projects are configured, so `sourceProject.configurations` is empty at the time. 
iurysza commented 1 year ago

Interesting! The parseProjectStructure() call happens only when the apply method is called, but by this time the project configuration has already happened.

Can you maybe describe what your project looks like? For reference, I'm using this plugin on a multimodule project setup here. Perhaps it's useful for you to take a look and see what might be causing this.

ferinagy commented 1 year ago

I managed to track this down to this block in our root project:

allprojects {
    project.tasks.all {

    }
}

If I add it to the sample module, it also creates an empty graph. It appears to affect the order in which the projects are configured. Same seems to happen with the --configure-on-demand option.

raamcosta commented 1 year ago

I also had this issue and I tried commenting out all allprojects blocks from root build.gradle.kts file since these are only used to configure ktlint, detekt and other similar tools for all modules.

Once I did that, the plugin worked :) Hope that helps!