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

Can't generate module graph #39

Closed sureshg closed 7 months ago

sureshg commented 7 months ago

Using the latest version of plugin in a kotlin multiplatform multi module project and createModuleGraph task fails with the following error.

> Task :createModuleGraph FAILED
List contains no element matching the predicate.
java.util.NoSuchElementException: List contains no element matching the predicate.
        at dev.iurysouza.modulegraph.graph.ExtKt.getProjectName(Ext.kt:16)
        at dev.iurysouza.modulegraph.graph.DigraphBuilder.buildModel(DigraphBuilder.kt:46)
        at dev.iurysouza.modulegraph.graph.DigraphBuilder.build(DigraphBuilder.kt:19)
        at dev.iurysouza.modulegraph.Mermaid.generateGraph(Mermaid.kt:13)
        at dev.iurysouza.modulegraph.gradle.CreateModuleGraphTask.execute(CreateModuleGraphTask.kt:91)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
iurysza commented 7 months ago

Hey, @sureshg could you check if you're using any filters? For example:

excludedConfigurationsRegex.set(".*test.*")
excludedModulesRegex.set(".*moduleName.*")
focusedModulesRegex.set(".*(projectName).*")

These might be triggering the issue. I think in this case it's specifically the excludedModuleRegex. I'll work on adding more explicit error messages for such scenarios too.

sureshg commented 7 months ago

Thanks for looking into it. No, i haven't used any filters. Here is the only config that get added to the root project.

moduleGraphConfig {
  readmePath = "./README.md"
  heading = "### Module Dependency"
}
iurysza commented 7 months ago

Interesting. Can please share the output of running

$ ./gradlew projects

from the root of your project?

sureshg commented 7 months ago
> Task :projects

------------------------------------------------------------
Root project 'kotlin-mpp-app' 
------------------------------------------------------------

Root project 'kotlin-mpp-app' 
+--- Project ':backend'
|    +--- Project ':backend:data' - Kotlin Data Science!
|    +--- Project ':backend:jvm' - Ktor backend jvm application
|    +--- Project ':backend:native' - Ktor native application
|    +--- Project ':backend:profiling' - JVM Profiling and Monitoring!
|    \--- Project ':backend:security' - Certificate and Security!
+--- Project ':benchmark' - Kotlin benchmarking tests
+--- Project ':dep-mgmt'
|    +--- Project ':dep-mgmt:bom' - A platform (BOM) used to align all module versions
|    \--- Project ':dep-mgmt:catalog' - Publish gradle version catalog!
+--- Project ':meta'
|    +--- Project ':meta:compiler'
|    |    \--- Project ':meta:compiler:plugin' - Kotlin Compiler Plugin
|    \--- Project ':meta:ksp'
|         \--- Project ':meta:ksp:processor' - Kotlin KSP Processor
+--- Project ':shared' - Shared common module for all projects
\--- Project ':web'
     +--- Project ':web:js' - Kotlin/JS Web application
     \--- Project ':web:wasm' - WasmJS Web application

Included builds
\--- Included build ':build-logic'
FreedomChuks commented 7 months ago

i have the exact same problem in a multi-module android project

FreedomChuks commented 7 months ago

works fine if it included in a singular module, but when added in the project level gradle file this error happens

iurysza commented 7 months ago

Hey @FreedomChuks & @sureshg , do you mind trying again on the latest version? 0.8.1 Cheers

FreedomChuks commented 7 months ago

Certainly

FreedomChuks commented 7 months ago

@iurysza it works now thanks

sureshg commented 7 months ago

@iurysza same..working now. Thanks for the quick fix.