Skip to content

Commit

Permalink
Merge pull request #143 from ferstl/feature/#139-additional-arguments…
Browse files Browse the repository at this point in the history
…-for-dot

Feature/#139 additional arguments for dot
  • Loading branch information
ferstl authored Mar 5, 2022
2 parents 07a609b + 0bc2370 commit 56f8930
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/main/java/com/github/ferstl/depgraph/AbstractGraphMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.regex.Pattern;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
Expand Down Expand Up @@ -137,14 +138,24 @@ abstract class AbstractGraphMojo extends AbstractMojo {
private String imageFormat;

/**
* Only relevant when {@code graphFormat=dot}: Path to the dot executable. Use this option in case
* {@link #createImage} is set to {@code true} and the dot executable is not on the system {@code PATH}.
* Only relevant when {@code graphFormat=dot} and {@code createImage=true}: Path to the dot executable. Use this
* option in case {@link #createImage} is set to {@code true} and the dot executable is not on the system
* {@code PATH}.
*
* @since 1.0.0
*/
@Parameter(property = "dotExecutable")
private File dotExecutable;

/**
* Only relevant when {@code graphFormat=dot} and {@code createImage=true}: Additional arguments for the {@code dot}
* executable (besides {@code -T} and {@code -o}).
*
* @since 4.0.0
*/
@Parameter(property = "dotArguments", defaultValue = "")
private String dotArguments;

/**
* Only relevant when {@code graphFormat=dot}: Path to a custom style configuration in JSON format.
*
Expand Down Expand Up @@ -344,6 +355,11 @@ private void createDotGraphImage(Path graphFilePath) throws IOException {
"-o", graphFile.toAbsolutePath().toString(),
graphFilePath.toAbsolutePath().toString()};

if (StringUtils.isNotBlank(this.dotArguments)) {
String[] dotArguments = this.dotArguments.split(" +");
arguments = ArrayUtils.addAll(arguments, dotArguments);
}

Commandline cmd = new Commandline();
cmd.setExecutable(dotExecutable);
cmd.addArguments(arguments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,18 @@ public void aggregated() throws Exception {
collectFile("target/dependency-graph.png", "aggregated.png");
}

@Test
public void aggregatedWithDotArguments() throws Exception {
runTest("aggregate",
"-DincludeParentProjects",
"-DdotArguments=-Kneato -Nfontcolor=red",
"-Dexcludes=com.github.ferstl:sub-parent,com.github.ferstl:module-3");

assertFilesPresent(this.basedir, "target/dependency-graph.png");

collectFile("target/dependency-graph.png", "dot-arguments.png");
}

@Test
public void aggregatedJson() throws Exception {
runTest("aggregate",
Expand Down

0 comments on commit 56f8930

Please sign in to comment.