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
345 stars 13 forks source link

Feat multiple graph export #46

Closed LukeNeedham closed 6 months ago

LukeNeedham commented 6 months ago

πŸš€ Description

Adds support for multiple graphs

πŸ“„ Motivation and Context

The current setup allows for a single graph to be generated in each project. But sometimes you want multiple graphs, where each graph has a completely independent config. This plays in nicely with the new rootModulesRegex configuration - you might decide to export a separate graph for each feature.

πŸ§ͺ How Has This Been Tested?

πŸ“¦ Types of changes

I went to great effort to not break backwards compatibility - the existing configuration setup is now the 'Primary Graph' config, and works fine with or without additional graphs.

βœ… Checklist

iurysza commented 6 months ago

Generating multiple graphs was something on my wish-list too, thanks for the PR! I couldnt check it over the weekend but I'll take a look soon.

iurysza commented 6 months ago

Hey, I've tested it on TIVI, and it failed with this error msg:

Configuration cache problems found in this build.

1 problem was found storing the configuration cache.
- Task `:createModuleGraph` of type `dev.iurysouza.modulegraph.gradle.CreateModuleGraphTask`: invocation of 'Task.project' at execution time is unsupported.
  See https://docs.gradle.org/8.7/userguide/configuration_cache.html#config_cache:requirements:use_project_during_execution

See the complete report at file:///tivi/build/reports/configuration-cache/3lvifbv02nwz2s91i1swjoca5/8td6klwv4ixu1ovsmfu3g48hy/configuration-cache-report.html
> Invocation of 'Task.project' by task ':createModuleGraph' at execution time is unsupported.

It seems to work on the sample project, but not on other projects. That's new to me. We might need the help from a Gradle expert to figure out exactly why it works on the sample, but the error msg is kinda self explanatory. I think it's related to this.

LukeNeedham commented 6 months ago

Hey, I've tested it on TIVI, and it failed with this error msg:

Configuration cache problems found in this build.

1 problem was found storing the configuration cache.
- Task `:createModuleGraph` of type `dev.iurysouza.modulegraph.gradle.CreateModuleGraphTask`: invocation of 'Task.project' at execution time is unsupported.
  See https://docs.gradle.org/8.7/userguide/configuration_cache.html#config_cache:requirements:use_project_during_execution

See the complete report at file:///tivi/build/reports/configuration-cache/3lvifbv02nwz2s91i1swjoca5/8td6klwv4ixu1ovsmfu3g48hy/configuration-cache-report.html
> Invocation of 'Task.project' by task ':createModuleGraph' at execution time is unsupported.

It seems to work on the sample project, but not on other projects. That's new to me. We might need the help from a Gradle expert to figure out exactly why it works on the sample, but the error msg is kinda self explanatory. I think it's related to this.

Hmm, it's strange that it failed for you - when I try this on my machine, it succeeds for Tivi and the graphs are correctly generated. I do get the same error message, but only as a warning. In any case, I will see what I can do to make the plugin compatible with the configuration cache - it seems quite easy: https://docs.gradle.org/8.7/userguide/configuration_cache.html#config_cache:requirements:use_project_during_execution

LukeNeedham commented 6 months ago

I've fixed the issue with the configuration cache, on my machine it now works perfectly on Tivi without any errors or warnings. Thanks for testing it!

iurysza commented 6 months ago

Great work on this one, @LukeNeedham! I've pushed a few minor tweaks, and I think we're ready to merge. Cheers!