From 8aed2ede99bf0e7f3faf5f38a34d543ff45f20b6 Mon Sep 17 00:00:00 2001 From: Savvas Dalkitsis Date: Sat, 1 Aug 2020 15:35:06 +0100 Subject: [PATCH] Adding option to disable auto opening of output file. Also printing out the location of both the dot file and output file. Version 0.9 --- README.md | 19 +++++++++++++++++-- build.gradle | 2 +- .../graph/ModuleDependencyGraphPlugin.groovy | 17 +++++++++++++---- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 3d48724..ff33107 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Apply the gradle plugin on your root `build.gradle` file: ``` plugins { - id 'com.savvasdalkitsis.module-dependency-graph' version '0.8' + id 'com.savvasdalkitsis.module-dependency-graph' version '0.9' } ``` @@ -23,7 +23,7 @@ buildscript { maven { url "https://plugins.gradle.org/m2/" } } dependencies { - classpath "com.savvasdalkitsis:module-dependency-graph:0.8" + classpath "com.savvasdalkitsis:module-dependency-graph:0.9" } } @@ -70,6 +70,21 @@ or in the `gradle.properties` file: graphOutputFormat=svg ``` +### Auto open output file + +By default, the generated graph will be opened using the system's default app for handling +the specified format. If you don't want this to happen, you can specify the following parameter: + +```bash +./gradlew graphModules -PautoOpenGraph=false +``` + +or in the `gradle.properties` file: + +``` +autoOpenGraph=false +``` + ## Requirements You must have graphviz installed on your system in order to use this plugin. For more information on how to install it visit http://www.graphviz.org/ diff --git a/build.gradle b/build.gradle index cbd499a..1e205b1 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ plugins { } group 'com.savvasdalkitsis' -version '0.8' +version '0.9' pluginBundle { website = 'https://github.com/savvasdalkitsis/' diff --git a/src/main/groovy/com/savvasdalkitsis/module/deps/graph/ModuleDependencyGraphPlugin.groovy b/src/main/groovy/com/savvasdalkitsis/module/deps/graph/ModuleDependencyGraphPlugin.groovy index 17fe995..42ec66a 100644 --- a/src/main/groovy/com/savvasdalkitsis/module/deps/graph/ModuleDependencyGraphPlugin.groovy +++ b/src/main/groovy/com/savvasdalkitsis/module/deps/graph/ModuleDependencyGraphPlugin.groovy @@ -69,15 +69,24 @@ class ModuleDependencyGraphPlugin implements Plugin { graphOutputFile = new File(project.property('graphOutputFilePath')) graphOutputFile.createNewFile() } + def autoOpenGraph = true + if (project.hasProperty('autoOpenGraph')) { + autoOpenGraph = Boolean.parseBoolean(project.property('autoOpenGraph')) + } dotFile.write(dot) project.exec { executable = "dot" args("-o", graphOutputFile.absolutePath, "-T$graphOutputFormat", dotFile.absolutePath) } - def exec = System.properties['os.name'].toLowerCase().contains("mac") ? "open" : "xdg-open" - project.exec { - executable = exec - args(graphOutputFile.absolutePath) + println("Generaged dot file at: ${dotFile.absolutePath}") + println("Generaged output file at: ${graphOutputFile.absolutePath}") + + if (autoOpenGraph) { + def exec = System.properties['os.name'].toLowerCase().contains("mac") ? "open" : "xdg-open" + project.exec { + executable = exec + args(graphOutputFile.absolutePath) + } } } }