forked from jraska/modules-graph-assert
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from mtrakal/feature/mermaid
Feature/mermaid
- Loading branch information
Showing
27 changed files
with
633 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
plugin/src/main/kotlin/com/jraska/module/graph/assertion/GenerateModulesGraph.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package com.jraska.module.graph.assertion | ||
|
||
import com.jraska.module.graph.DependencyGraph | ||
import org.gradle.api.Project | ||
import java.io.File | ||
|
||
class GenerateModulesGraph( | ||
var aliases: Map<String, String>, | ||
var onlyModuleToPrint: String? = null, | ||
var dependencyGraph: DependencyGraph.SerializableGraph, | ||
var outputFilePath: String? = null, | ||
var outputFile: File? = null, | ||
var outputFormat: OutputFormat = OutputFormat.GRAPHVIZ, | ||
) { | ||
fun run(path: String) { | ||
val dependencyGraph = | ||
DependencyGraph.create(dependencyGraph).let { | ||
if (onlyModuleToPrint == null) { | ||
it | ||
} else { | ||
it.subTree(onlyModuleToPrint!!) | ||
} | ||
} | ||
|
||
val writer = outputFormat.writer.objectInstance | ||
if (writer == null) { | ||
print("No writer found for $outputFormat") | ||
return | ||
} | ||
|
||
val graph = writer.toGraph(dependencyGraph, aliases) | ||
|
||
if (outputFilePath != null) { | ||
val file = File(outputFilePath!!) | ||
file.writeText(graph) | ||
outputFile = file | ||
println("Graph saved to $path") | ||
} else { | ||
println(graph) | ||
} | ||
} | ||
|
||
companion object { | ||
internal fun outputFilePath( | ||
project: Project, | ||
outputFormat: OutputFormat, | ||
): String? { | ||
return when { | ||
project.hasProperty(Api.Parameters.OUTPUT_PATH) && outputFormat.isGraphviz -> { | ||
project.property(Api.Parameters.OUTPUT_PATH).toString() | ||
} | ||
|
||
project.hasProperty(Api.Parameters.OUTPUT_PATH_MERMAID) && outputFormat.isMermaid -> { | ||
project.property(Api.Parameters.OUTPUT_PATH_MERMAID).toString() | ||
} | ||
|
||
else -> null | ||
} | ||
} | ||
|
||
internal fun onlyModule(project: Project): String? { | ||
if (project.hasProperty(Api.Parameters.PRINT_ONLY_MODULE)) { | ||
return project.property(Api.Parameters.PRINT_ONLY_MODULE) as String? | ||
} else { | ||
return null | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.