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

Grouped submodules 4 - Show only subgraphs in root graph #37

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ classDef andNode fill:#baffc9,color:#333333;
classDef javaNode fill:#ffb3ba,color:#333333;

%% Modules
subgraph
subgraph
direction LR;
:example:feature{{<a href='https://github.com/adityabhaskar/Gradle-dependency-graphs/blob/main/example/feature/dependencyGraph.md' style='text-decoration:auto'>:example:feature</a>}}:::javaNode;
:example:models{{<a href='https://github.com/adityabhaskar/Gradle-dependency-graphs/blob/main/example/models/dependencyGraph.md' style='text-decoration:auto'>:example:models</a>}}:::javaNode;
Expand Down Expand Up @@ -132,7 +132,7 @@ classDef andNode fill:#baffc9,color:#333333;
classDef javaNode fill:#ffb3ba,color:#333333;

%% Modules
subgraph
subgraph
direction LR;
:example:data{{<a href='https://github.com/adityabhaskar/Gradle-dependency-graphs/blob/main/example/data/dependencyGraph.md' style='text-decoration:auto'>:example:data</a>}}:::javaNode;
:example:domain[<a href='https://github.com/adityabhaskar/Gradle-dependency-graphs/blob/main/example/domain/dependencyGraph.md' style='text-decoration:auto'>:example:domain</a>]:::javaNode;
Expand Down Expand Up @@ -173,4 +173,4 @@ Feel free to open a issue or submit a pull request for any bugs/improvements.

## License 📄

This template is licensed under the MIT License - see the [License](License) file for details.
This template is licensed under the MIT License - see the [License](License) file for details.
2 changes: 1 addition & 1 deletion plugin-build/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ID=io.github.adityabhaskar.dependencygraph
VERSION=0.1.6
VERSION=0.2.0
GROUP=io.github.adityabhaskar
DISPLAY_NAME=Gradle module dependency graphs
DESCRIPTION=A plugin to automatically produce Github/mermaid compatible dependency graphs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,24 @@ internal fun drawDependencyGraph(

var fileText = """
```mermaid
%%{ init: { 'theme': 'base' } }%%
%%{
init: {
"theme": "base",
"themeVariables": {
"nodeTextColor": "#333333",
"clusterBorder": "#a0a0a0",
"nodeBorder": "#767676"
}
}
}%%

graph LR;

%% Styling for module nodes by type
classDef rootNode stroke-width:4px;
classDef mppNode fill:#ffd2b3,color:#333333;
classDef andNode fill:#baffc9,color:#333333;
classDef javaNode fill:#ffb3ba,color:#333333;
classDef mppNode fill:#ffd2b3;
classDef andNode fill:#baffc9;
classDef javaNode fill:#ffb3ba;
$legendText
%% Modules

Expand All @@ -78,7 +88,7 @@ internal fun drawDependencyGraph(
var rootMap = mutableMapOf<String, ProjectOrSubMap>()

for (project in relevantProjects) {
rootMap = mapProjectListToGroups(
rootMap = groupSubModules(
currentPath = "",
project = project,
remainingPath = project.path,
Expand Down Expand Up @@ -122,10 +132,10 @@ internal fun drawDependencyGraph(
val isDirectDependency = origin == currentProject

val arrow = when {
isApi && isDirectDependency -> ConnecterType.DirectApi
isApi -> ConnecterType.IndirectApi
isDirectDependency -> ConnecterType.Direct
else -> ConnecterType.Indirect
isApi && isDirectDependency -> ConnectorType.DirectApi
isApi -> ConnectorType.IndirectApi
isDirectDependency -> ConnectorType.Direct
else -> ConnectorType.Indirect
}
fileText += "${origin.path}${arrow}${target.path}\n"
}
Expand Down Expand Up @@ -290,7 +300,7 @@ private data class ProjectOrSubMap(
}
}

private fun mapProjectListToGroups(
private fun groupSubModules(
currentPath: String,
project: ModuleProject,
remainingPath: String,
Expand Down Expand Up @@ -319,7 +329,7 @@ private fun mapProjectListToGroups(
} else {
"$currentPath:${nextPath[0]}"
}
val subMap = mapProjectListToGroups(
val subMap = groupSubModules(
currentPath = key,
project = project,
remainingPath = nowRemainingPath,
Expand All @@ -330,6 +340,13 @@ private fun mapProjectListToGroups(
}
}

@Suppress("UnusedPrivateMember")
private fun mapProjectListToGroups() {
// TODO: 04/08/2023 When encountering a sub project, add it to a list but only record parent
// folder name Then when drawing dependencies, check the list and draw it to parent folder
// when sub project falls under it
}

/**
* Returns a list of all modules that are direct or indirect dependencies of the provided module.
* @param currentProjectAndDependencies the module(s) whose dependencies we need
Expand Down Expand Up @@ -403,7 +420,7 @@ private object NodeClass {
const val Java = ":::javaNode"
}

private object ConnecterType {
private object ConnectorType {
const val DirectApi = "==API===>"
const val IndirectApi = "--API--->"
const val Direct = "===>"
Expand Down