From 84369131ebe7629db9b234e8997c48ea447ee32f Mon Sep 17 00:00:00 2001 From: Florent CHAMFROY Date: Wed, 6 Apr 2022 23:12:52 +0200 Subject: [PATCH] feat(mermaid): add a new output format Add the possibility to use mermaid syntax. See https://mermaid-js.github.io/mermaid/#/flowchart?id=flowcharts-basic-syntax #150 --- README.md | 43 ++++++ .../ferstl/depgraph/AbstractGraphMojo.java | 6 +- .../github/ferstl/depgraph/GraphFormat.java | 6 + .../MermaidDependencyEdgeRenderer.java | 47 +++++++ .../MermaidDependencyNodeNameRenderer.java | 119 +++++++++++++++++ .../mermaid/MermaidGraphStyleConfigurer.java | 34 +++++ .../graph/mermaid/MermaidEdgeStyle.java | 46 +++++++ .../graph/mermaid/MermaidGraphFormatter.java | 85 ++++++++++++ .../DocumentationIntegrationTest.java | 31 +++++ .../ferstl/depgraph/GraphFormatTest.java | 19 +++ .../ferstl/depgraph/GraphIntegrationTest.java | 61 +++++++++ .../MermaidDependencyEdgeRendererTest.java | 53 ++++++++ ...MermaidDependencyNodeNameRendererTest.java | 124 ++++++++++++++++++ .../MermaidGraphStyleConfigurerTest.java | 62 +++++++++ .../mermaid/MermaidGraphFormatterTest.java | 56 ++++++++ .../expectations/by-groupid_module-1.mmd | 13 ++ .../expectations/by-groupid_module-2.mmd | 17 +++ .../expectations/by-groupid_module-3.mmd | 19 +++ .../expectations/by-groupid_parent.mmd | 5 + .../expectations/by-groupid_sub-parent.mmd | 11 ++ .../expectations/graph_module-1.mmd | 13 ++ .../expectations/graph_module-2.mmd | 19 +++ .../expectations/graph_module-3.mmd | 23 ++++ .../expectations/graph_parent.mmd | 5 + .../expectations/graph_sub-parent.mmd | 15 +++ .../no-dependencies/expectations/example.mmd | 26 ++++ 26 files changed, 957 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/github/ferstl/depgraph/dependency/mermaid/MermaidDependencyEdgeRenderer.java create mode 100644 src/main/java/com/github/ferstl/depgraph/dependency/mermaid/MermaidDependencyNodeNameRenderer.java create mode 100644 src/main/java/com/github/ferstl/depgraph/dependency/mermaid/MermaidGraphStyleConfigurer.java create mode 100644 src/main/java/com/github/ferstl/depgraph/graph/mermaid/MermaidEdgeStyle.java create mode 100644 src/main/java/com/github/ferstl/depgraph/graph/mermaid/MermaidGraphFormatter.java create mode 100644 src/test/java/com/github/ferstl/depgraph/dependency/mermaid/MermaidDependencyEdgeRendererTest.java create mode 100644 src/test/java/com/github/ferstl/depgraph/dependency/mermaid/MermaidDependencyNodeNameRendererTest.java create mode 100644 src/test/java/com/github/ferstl/depgraph/dependency/mermaid/MermaidGraphStyleConfigurerTest.java create mode 100644 src/test/java/com/github/ferstl/depgraph/graph/mermaid/MermaidGraphFormatterTest.java create mode 100644 src/test/projects/depgraph-maven-plugin-test/expectations/by-groupid_module-1.mmd create mode 100644 src/test/projects/depgraph-maven-plugin-test/expectations/by-groupid_module-2.mmd create mode 100644 src/test/projects/depgraph-maven-plugin-test/expectations/by-groupid_module-3.mmd create mode 100644 src/test/projects/depgraph-maven-plugin-test/expectations/by-groupid_parent.mmd create mode 100644 src/test/projects/depgraph-maven-plugin-test/expectations/by-groupid_sub-parent.mmd create mode 100644 src/test/projects/depgraph-maven-plugin-test/expectations/graph_module-1.mmd create mode 100644 src/test/projects/depgraph-maven-plugin-test/expectations/graph_module-2.mmd create mode 100644 src/test/projects/depgraph-maven-plugin-test/expectations/graph_module-3.mmd create mode 100644 src/test/projects/depgraph-maven-plugin-test/expectations/graph_parent.mmd create mode 100644 src/test/projects/depgraph-maven-plugin-test/expectations/graph_sub-parent.mmd create mode 100644 src/test/projects/no-dependencies/expectations/example.mmd diff --git a/README.md b/README.md index 711600f3..8387ef93 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,8 @@ This Maven plugin generates dependency graphs on single modules or in an aggrega DOT files can be visualized with [Graphviz](http://www.graphviz.org/). When [Graphviz](http://www.graphviz.org/) is installed, the generated `.dot` files can be directly rendered into all supported image formats. - `.gml` (Graph Markup Language)
GML files can be visualized with the [yEd Graph Editor](https://www.yworks.com/products/yed) which allows further processing and layouting of the dependency graph. +- `.mmd` (Mermaid)
+ Mermaid graphes can be easily embedded in application and in markdown files. See [here](https://mermaid-js.github.io/mermaid/#/). - `.puml` (PlantUML)
PlantUML files can be visualized by various tools like [planttext.com](https://www.planttext.com/) or in IntelliJ with the [PlantUML Plugin](https://plugins.jetbrains.com/plugin/7017-plantuml-integration). - `.json`
@@ -154,6 +156,47 @@ Since the generated dependency graph does not store any layout information, you - Choose *Tools -> Fit Node To Label* and press *OK* in the upcoming dialog - Choose your layout algorithm in the *Layout* menu to layout the graph + +#### Mermaid + +Mermaid graphes can be easily embedded in application and in markdown files. See [here](https://mermaid-js.github.io/mermaid/#/). + +```mermaid +flowchart TD + %% Node Definitions: + com.github.ferstl:module-1:jar["module-1
1.0.0-SNAPSHOT"] + commons-codec:commons-codec:jar["commons-codec
1.10"] + org.apache.commons:commons-lang3:jar["commons-lang3
3.1"] + com.github.ferstl:module-3:jar["module-3
1.0.0-SNAPSHOT"] + com.github.ferstl:module-2:jar["module-2
1.0.0-SNAPSHOT"] + com.google.guava:guava:jar["guava
30.1.1-jre"] + com.mysema.querydsl:querydsl-core:jar["querydsl-core
3.7.4"] + com.google.code.findbugs:jsr305:jar["jsr305
1.3.9"] + com.mysema.commons:mysema-commons-lang:jar["mysema-commons-lang
0.2.4"] + com.infradna.tool:bridge-method-annotation:jar["bridge-method-annotation
1.13"] + + %% Edge Definitions: + com.github.ferstl:module-1:jar --> commons-codec:commons-codec:jar + com.github.ferstl:module-1:jar --> org.apache.commons:commons-lang3:jar + com.github.ferstl:module-3:jar --> com.github.ferstl:module-1:jar + com.github.ferstl:module-2:jar --> com.github.ferstl:module-1:jar + com.github.ferstl:module-2:jar --> com.google.guava:guava:jar + com.github.ferstl:module-2:jar --> commons-codec:commons-codec:jar + com.github.ferstl:module-2:jar --3.0--> org.apache.commons:commons-lang3:jar + com.github.ferstl:module-3:jar --> com.github.ferstl:module-2:jar + com.mysema.querydsl:querydsl-core:jar --> com.google.guava:guava:jar + com.mysema.querydsl:querydsl-core:jar --> com.google.code.findbugs:jsr305:jar + com.mysema.querydsl:querydsl-core:jar --> com.mysema.commons:mysema-commons-lang:jar + com.mysema.querydsl:querydsl-core:jar --> com.infradna.tool:bridge-method-annotation:jar + com.github.ferstl:module-3:jar --> com.mysema.querydsl:querydsl-core:jar + + %% Edge Styles: + linkStyle 3 color:#000000, stroke:#000000, stroke-dasharray:3px + linkStyle 5 color:#000000, stroke:#000000, stroke-dasharray:3px + linkStyle 6 color:#FF0000, stroke:#FF0000, stroke-dasharray:10px + linkStyle 8 color:#000000, stroke:#000000, stroke-dasharray:3px +``` + #### PlantUML PlantUML graphs can be visualized with various tools, e.g. [planttext.com](https://www.planttext.com/) or the [PlantUML Integration](https://plugins.jetbrains.com/plugin/7017-plantuml-integration) for IntelliJ (requires [Graphviz](http://www.graphviz.org/) for rendering). diff --git a/src/main/java/com/github/ferstl/depgraph/AbstractGraphMojo.java b/src/main/java/com/github/ferstl/depgraph/AbstractGraphMojo.java index d6830725..0522176b 100644 --- a/src/main/java/com/github/ferstl/depgraph/AbstractGraphMojo.java +++ b/src/main/java/com/github/ferstl/depgraph/AbstractGraphMojo.java @@ -26,6 +26,8 @@ import java.util.LinkedHashSet; import java.util.Set; import java.util.regex.Pattern; + +import com.github.ferstl.depgraph.dependency.mermaid.MermaidGraphStyleConfigurer; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugin.AbstractMojo; @@ -69,7 +71,7 @@ abstract class AbstractGraphMojo extends AbstractMojo { private static final String OUTPUT_FILE_NAME = "dependency-graph"; /** - * Format of the graph, either "dot" (default), "gml", "puml", "json" or "text". + * Format of the graph, either "dot" (default), "gml", "puml", "mermaid", "json" or "text". * * @since 2.1.0 */ @@ -260,6 +262,8 @@ private GraphStyleConfigurer createGraphStyleConfigurer(GraphFormat graphFormat) return new PumlGraphStyleConfigurer(); case JSON: return new JsonGraphStyleConfigurer(); + case MERMAID: + return new MermaidGraphStyleConfigurer(); case TEXT: return new TextGraphStyleConfigurer(); default: diff --git a/src/main/java/com/github/ferstl/depgraph/GraphFormat.java b/src/main/java/com/github/ferstl/depgraph/GraphFormat.java index f25b0b18..7edb5832 100644 --- a/src/main/java/com/github/ferstl/depgraph/GraphFormat.java +++ b/src/main/java/com/github/ferstl/depgraph/GraphFormat.java @@ -20,6 +20,12 @@ public enum GraphFormat { GML, PUML, JSON, + MERMAID { + @Override + public String getFileExtension() { + return ".mmd"; + } + }, TEXT { @Override public String getFileExtension() { diff --git a/src/main/java/com/github/ferstl/depgraph/dependency/mermaid/MermaidDependencyEdgeRenderer.java b/src/main/java/com/github/ferstl/depgraph/dependency/mermaid/MermaidDependencyEdgeRenderer.java new file mode 100644 index 00000000..a37935df --- /dev/null +++ b/src/main/java/com/github/ferstl/depgraph/dependency/mermaid/MermaidDependencyEdgeRenderer.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2014 - 2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.github.ferstl.depgraph.dependency.mermaid; + +import com.github.ferstl.depgraph.dependency.DependencyNode; +import com.github.ferstl.depgraph.dependency.NodeResolution; +import com.github.ferstl.depgraph.graph.EdgeRenderer; + +import static com.github.ferstl.depgraph.dependency.VersionAbbreviator.abbreviateVersion; + + +public class MermaidDependencyEdgeRenderer implements EdgeRenderer { + + public static final String DUPLICATE_PREFIX = "+"; + public static final String CONFLICT_PREFIX = "*"; + private final boolean renderVersions; + + public MermaidDependencyEdgeRenderer(boolean renderVersions) { + this.renderVersions = renderVersions; + } + + @Override + public String render(DependencyNode from, DependencyNode to) { + NodeResolution toResolution = to.getResolution(); + switch (toResolution) { + case OMITTED_FOR_CONFLICT: + return CONFLICT_PREFIX + (this.renderVersions ? abbreviateVersion(to.getArtifact().getVersion()) : ""); + case OMITTED_FOR_DUPLICATE: + return DUPLICATE_PREFIX; + } + return ""; + } + +} diff --git a/src/main/java/com/github/ferstl/depgraph/dependency/mermaid/MermaidDependencyNodeNameRenderer.java b/src/main/java/com/github/ferstl/depgraph/dependency/mermaid/MermaidDependencyNodeNameRenderer.java new file mode 100644 index 00000000..fa35168b --- /dev/null +++ b/src/main/java/com/github/ferstl/depgraph/dependency/mermaid/MermaidDependencyNodeNameRenderer.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2014 - 2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.github.ferstl.depgraph.dependency.mermaid; + +import com.github.ferstl.depgraph.dependency.DependencyNode; +import com.github.ferstl.depgraph.dependency.dot.style.StyleConfiguration; +import com.github.ferstl.depgraph.dependency.dot.style.StyleKey; +import com.github.ferstl.depgraph.graph.NodeRenderer; +import com.google.common.base.Joiner; +import org.apache.maven.artifact.Artifact; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.Set; +import java.util.stream.Collectors; + +import static org.apache.maven.artifact.Artifact.SCOPE_COMPILE; + + +public class MermaidDependencyNodeNameRenderer implements NodeRenderer { + + private static final Joiner SLASH_JOINER = Joiner.on("/").skipNulls(); + private static final Joiner NEWLINE_JOINER = Joiner.on("
").skipNulls(); + + private final boolean showGroupId; + private final boolean showArtifactId; + private final boolean showTypes; + private final boolean showClassifiers; + private final boolean showVersion; + private final boolean showOptional; + private final boolean showScope; + + public MermaidDependencyNodeNameRenderer(boolean showGroupId, boolean showArtifactId, boolean showTypes, boolean showClassifiers, boolean showVersion, boolean showOptional, boolean showScope) { + this.showGroupId = showGroupId; + this.showArtifactId = showArtifactId; + this.showTypes = showTypes; + this.showClassifiers = showClassifiers; + this.showVersion = showVersion; + this.showOptional = showOptional; + this.showScope = showScope; + } + + @Override + public String render(DependencyNode node) { + + Collection items = new ArrayList<>(); + if (node.getArtifact().isOptional() && showOptional) { + items.add(printWithSmallFont("#lt;optional#gt;")); + } + if (showGroupId) { + items.add(node.getArtifact().getGroupId()); + } + if (showArtifactId) { + items.add(node.getArtifact().getArtifactId()); + } + if (showVersion) { + items.add(node.getEffectiveVersion()); + } + if (showTypes) { + items.add(createTypeString(node.getTypes())); + } + if (showClassifiers) { + items.add(createClassifierString(node.getClassifiers())); + } + if (showScope) { + items.add(createScopeString(node.getScopes())); + } + if (items.isEmpty()) { + return "[\" \"]"; + } + + return "[\"" + NEWLINE_JOINER.join(items) + "\"]"; + } + + private static String createScopeString(Set scopes) { + if (!scopes.isEmpty() && (scopes.size() > 1 || !scopes.contains(SCOPE_COMPILE))) { + return printWithSmallFont("(" + SLASH_JOINER.join(scopes) + ")"); + } + + return null; + } + + private static String createTypeString(Set types) { + if (types.size() > 1 || !types.contains("jar")) { + types.forEach(type -> type = "." + type); + + return SLASH_JOINER.join(types.stream().map(type -> "." + type).collect(Collectors.toList())); + } + + return null; + } + + private static String createClassifierString(Set classifiers) { + if( classifiers.size() > 1 ) { + return SLASH_JOINER.join(classifiers); + } + + return null; + } + + private static String printWithSmallFont(String stringToPrint) { + return "" + stringToPrint + ""; + } +} + diff --git a/src/main/java/com/github/ferstl/depgraph/dependency/mermaid/MermaidGraphStyleConfigurer.java b/src/main/java/com/github/ferstl/depgraph/dependency/mermaid/MermaidGraphStyleConfigurer.java new file mode 100644 index 00000000..96e6e115 --- /dev/null +++ b/src/main/java/com/github/ferstl/depgraph/dependency/mermaid/MermaidGraphStyleConfigurer.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2014 - 2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.github.ferstl.depgraph.dependency.mermaid; + + +import com.github.ferstl.depgraph.dependency.AbstractGraphStyleConfigurer; +import com.github.ferstl.depgraph.dependency.DependencyNode; +import com.github.ferstl.depgraph.dependency.dot.style.StyleConfiguration; +import com.github.ferstl.depgraph.graph.GraphBuilder; +import com.github.ferstl.depgraph.graph.mermaid.MermaidGraphFormatter; + +public class MermaidGraphStyleConfigurer extends AbstractGraphStyleConfigurer { + + @Override + public GraphBuilder configure(GraphBuilder graphBuilder) { + return graphBuilder + .useNodeNameRenderer(new MermaidDependencyNodeNameRenderer(this.showGroupId, this.showArtifactId, this.showTypes, this.showClassifiers, this.showVersionsOnNodes, this.showOptional, this.showScope)) + .useEdgeRenderer(new MermaidDependencyEdgeRenderer(this.showVersionOnEdges)) + .graphFormatter(new MermaidGraphFormatter()); + } +} diff --git a/src/main/java/com/github/ferstl/depgraph/graph/mermaid/MermaidEdgeStyle.java b/src/main/java/com/github/ferstl/depgraph/graph/mermaid/MermaidEdgeStyle.java new file mode 100644 index 00000000..a9a1ea9e --- /dev/null +++ b/src/main/java/com/github/ferstl/depgraph/graph/mermaid/MermaidEdgeStyle.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2014 - 2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.github.ferstl.depgraph.graph.mermaid; + +public class MermaidEdgeStyle { + private static final String DUPLICATE_COLOR = "#000000"; // lightGray + private static final String CONFLICT_COLOR = "#FF0000"; // red + + private int index; + private String color; + private int strokeSize; + + private MermaidEdgeStyle() {} + + private MermaidEdgeStyle(int index, String color, int strokeSize) { + this.index = index; + this.color = color; + this.strokeSize = strokeSize; + } + + public static MermaidEdgeStyle createConflictStyle(int index) { + return new MermaidEdgeStyle(index, CONFLICT_COLOR, 10); + } + + public static MermaidEdgeStyle createDuplicateStyle(int index) { + return new MermaidEdgeStyle(index, DUPLICATE_COLOR, 3); + } + + @Override + public String toString() { + return "linkStyle " + index + " color:" + color + ", stroke:" + color + ", stroke-dasharray:" + strokeSize + "px"; + } +} diff --git a/src/main/java/com/github/ferstl/depgraph/graph/mermaid/MermaidGraphFormatter.java b/src/main/java/com/github/ferstl/depgraph/graph/mermaid/MermaidGraphFormatter.java new file mode 100644 index 00000000..d6ecc73b --- /dev/null +++ b/src/main/java/com/github/ferstl/depgraph/graph/mermaid/MermaidGraphFormatter.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2014 - 2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.github.ferstl.depgraph.graph.mermaid; + + +import com.github.ferstl.depgraph.dependency.mermaid.MermaidDependencyEdgeRenderer; +import com.github.ferstl.depgraph.graph.Edge; +import com.github.ferstl.depgraph.graph.GraphFormatter; +import com.github.ferstl.depgraph.graph.Node; + +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; + +public class MermaidGraphFormatter implements GraphFormatter { + + private Collection styles = new LinkedHashSet<>(); + + @Override + public String format(String graphName, Collection> nodes, Collection edges) { + StringBuilder sb = new StringBuilder("flowchart TD"); + + sb.append("\n %% Node Definitions:"); + for (Node node : nodes) { + String nodeId = node.getNodeId(); + String nodeName = node.getNodeName(); + sb.append("\n ") + .append(nodeId); + if( nodeName != null && !nodeName.isEmpty()) { + sb.append(nodeName); + } + } + + sb.append("\n\n %% Edge Definitions:"); + int row = 0; + for (Edge edge : edges) { + String edgeName = edge.getName(); + /* + Edge style can't be defined on the same line. It has to be added after (See https://mermaid-js.github.io/mermaid/#/flowchart?id=styling-links) + So the right style, on the right index is added to the styles list. + */ + if(MermaidDependencyEdgeRenderer.DUPLICATE_PREFIX.equals(edgeName)) { + styles.add(MermaidEdgeStyle.createDuplicateStyle(row)); + edgeName = ""; + } else if (edgeName.startsWith(MermaidDependencyEdgeRenderer.CONFLICT_PREFIX)) { + styles.add(MermaidEdgeStyle.createConflictStyle(row)); + edgeName = edgeName.substring(1); + } + + if (!edgeName.isEmpty()) { + edgeName = "-" + edgeName + "-"; + } + + String edgeDefinition = edge.getFromNodeId() + " -" + edgeName + "-> " + edge.getToNodeId(); + sb.append("\n ").append(edgeDefinition); + + row++; + } + + /* + Add styles to the end of the graph definition. + */ + if (!styles.isEmpty()) { + sb.append("\n\n %% Edge Styles:"); + for(MermaidEdgeStyle style : styles) { + sb.append("\n ").append(style.toString()); + } + } + + return sb.toString(); + } +} diff --git a/src/test/java/com/github/ferstl/depgraph/DocumentationIntegrationTest.java b/src/test/java/com/github/ferstl/depgraph/DocumentationIntegrationTest.java index 84d175ce..b45dbfc7 100644 --- a/src/test/java/com/github/ferstl/depgraph/DocumentationIntegrationTest.java +++ b/src/test/java/com/github/ferstl/depgraph/DocumentationIntegrationTest.java @@ -167,6 +167,18 @@ public void aggregatedJson() throws Exception { collectFile("target/dependency-graph.json", "aggregated.json"); } + @Test + public void aggregatedMermaid() throws Exception { + runTest("aggregate", + "-DgraphFormat=mermaid", + "-DincludeParentProjects", + "-Dexcludes=com.github.ferstl:sub-parent,com.github.ferstl:module-3"); + + assertFilesPresent(this.basedir, "target/dependency-graph.mmd"); + + collectFile("target/dependency-graph.mmd", "aggregated.mmd"); + } + @Test public void aggregatedText() throws Exception { runTest("aggregate", @@ -223,6 +235,25 @@ public void gmlWithConflicts() throws Exception { collectFile("sub-parent/module-3/target/dependency-graph.gml", "with-conflicts.gml"); } + @Test + public void mermaidWithConflicts() throws Exception { + runTest("graph", + "-DgraphFormat=mermaid", + "-DshowVersions", + "-DshowDuplicates", + "-DshowConflicts"); + + assertFilesPresent( + this.basedir, + "module-1/target/dependency-graph.mmd", + "module-2/target/dependency-graph.mmd", + "sub-parent/module-3/target/dependency-graph.mmd", + "target/dependency-graph.mmd", + "sub-parent/target/dependency-graph.mmd"); + + collectFile("sub-parent/module-3/target/dependency-graph.mmd", "with-conflicts.mmd"); + } + @Test public void pumlWithConflicts() throws Exception { runTest("graph", diff --git a/src/test/java/com/github/ferstl/depgraph/GraphFormatTest.java b/src/test/java/com/github/ferstl/depgraph/GraphFormatTest.java index 524625e9..7b5112d2 100644 --- a/src/test/java/com/github/ferstl/depgraph/GraphFormatTest.java +++ b/src/test/java/com/github/ferstl/depgraph/GraphFormatTest.java @@ -113,6 +113,24 @@ void forNameText() { assertSame(GraphFormat.TEXT, result3); } + @Test + void forNameMermaid() { + // arrange + String name1 = "mermaid"; + String name2 = "Mermaid"; + String name3 = "MERMAID"; + + // act + GraphFormat result1 = GraphFormat.forName(name1); + GraphFormat result2 = GraphFormat.forName(name2); + GraphFormat result3 = GraphFormat.forName(name3); + + // assert + assertSame(GraphFormat.MERMAID, result2); + assertSame(GraphFormat.MERMAID, result1); + assertSame(GraphFormat.MERMAID, result3); + } + @Test void forNameWithUnknownFormat() { // act/assert @@ -126,5 +144,6 @@ void getFileExtension() { assertEquals(".puml", GraphFormat.PUML.getFileExtension()); assertEquals(".json", GraphFormat.JSON.getFileExtension()); assertEquals(".txt", GraphFormat.TEXT.getFileExtension()); + assertEquals(".mmd", GraphFormat.MERMAID.getFileExtension()); } } diff --git a/src/test/java/com/github/ferstl/depgraph/GraphIntegrationTest.java b/src/test/java/com/github/ferstl/depgraph/GraphIntegrationTest.java index ce36e0aa..4426c852 100644 --- a/src/test/java/com/github/ferstl/depgraph/GraphIntegrationTest.java +++ b/src/test/java/com/github/ferstl/depgraph/GraphIntegrationTest.java @@ -112,6 +112,67 @@ public void exampleInDot() throws Exception { assertFileContents(basedir, "expectations/example.dot", "target/dependency-graph.dot"); } + @Test + public void graphInMermaid() throws Exception { + File basedir = this.resources.getBasedir("depgraph-maven-plugin-test"); + MavenExecutionResult result = this.mavenRuntime + .forProject(basedir) + .withCliOption("-DgraphFormat=mermaid") + .execute("depgraph:graph"); + + result.assertErrorFreeLog(); + assertFilesPresent( + basedir, + "module-1/target/dependency-graph.mmd", + "module-2/target/dependency-graph.mmd", + "sub-parent/module-3/target/dependency-graph.mmd", + "target/dependency-graph.mmd", + "sub-parent/target/dependency-graph.mmd"); + + assertFileContents(basedir, "expectations/graph_parent.mmd", "target/dependency-graph.mmd"); + assertFileContents(basedir, "expectations/graph_module-1.mmd", "module-1/target/dependency-graph.mmd"); + assertFileContents(basedir, "expectations/graph_module-2.mmd", "module-2/target/dependency-graph.mmd"); + assertFileContents(basedir, "expectations/graph_sub-parent.mmd", "sub-parent/target/dependency-graph.mmd"); + assertFileContents(basedir, "expectations/graph_module-3.mmd", "sub-parent/module-3/target/dependency-graph.mmd"); + } + + @Test + public void byGroupIdInMermaid() throws Exception { + File basedir = this.resources.getBasedir("depgraph-maven-plugin-test"); + MavenExecutionResult result = this.mavenRuntime + .forProject(basedir) + .withCliOption("-DgraphFormat=mermaid") + .execute("clean", "depgraph:by-groupid"); + + result.assertErrorFreeLog(); + assertFilesPresent( + basedir, + "module-1/target/dependency-graph.mmd", + "module-2/target/dependency-graph.mmd", + "sub-parent/module-3/target/dependency-graph.mmd", + "target/dependency-graph.mmd", + "sub-parent/target/dependency-graph.mmd"); + + assertFileContents(basedir, "expectations/by-groupid_parent.mmd", "target/dependency-graph.mmd"); + assertFileContents(basedir, "expectations/by-groupid_module-1.mmd", "module-1/target/dependency-graph.mmd"); + assertFileContents(basedir, "expectations/by-groupid_module-2.mmd", "module-2/target/dependency-graph.mmd"); + assertFileContents(basedir, "expectations/by-groupid_sub-parent.mmd", "sub-parent/target/dependency-graph.mmd"); + assertFileContents(basedir, "expectations/by-groupid_module-3.mmd", "sub-parent/module-3/target/dependency-graph.mmd"); + } + + @Test + public void exampleInMermaid() throws Exception { + File basedir = this.resources.getBasedir("no-dependencies"); + MavenExecutionResult result = this.mavenRuntime + .forProject(basedir) + .withCliOption("-DgraphFormat=mermaid") + .execute("clean", "depgraph:example"); + + result.assertErrorFreeLog(); + assertFilesPresent(basedir, "target/dependency-graph.mmd"); + assertFileContents(basedir, "expectations/example.mmd", "target/dependency-graph.mmd"); + } + @Test public void customGraphStyle() throws Exception { File basedir = this.resources.getBasedir("single-dependency"); diff --git a/src/test/java/com/github/ferstl/depgraph/dependency/mermaid/MermaidDependencyEdgeRendererTest.java b/src/test/java/com/github/ferstl/depgraph/dependency/mermaid/MermaidDependencyEdgeRendererTest.java new file mode 100644 index 00000000..0110542f --- /dev/null +++ b/src/test/java/com/github/ferstl/depgraph/dependency/mermaid/MermaidDependencyEdgeRendererTest.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2014 - 2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.github.ferstl.depgraph.dependency.mermaid; + +import com.github.ferstl.depgraph.dependency.AbstractDependencyEdgeRendererTest; +import com.github.ferstl.depgraph.dependency.DependencyNode; +import com.github.ferstl.depgraph.graph.EdgeRenderer; + +public class MermaidDependencyEdgeRendererTest extends AbstractDependencyEdgeRendererTest { + + @Override + protected EdgeRenderer createEdgeRenderer(boolean renderVersion) { + return new MermaidDependencyEdgeRenderer(renderVersion); + } + + @Override + protected String renderWithoutVersionResult() { + return ""; + } + + @Override + protected String renderWithNonConflictingVersionResult() { + return ""; + } + + @Override + protected String renderWithConflictShowingVersionResult() { + return MermaidDependencyEdgeRenderer.CONFLICT_PREFIX + "version2-alpha"; + } + + @Override + protected String renderWithConflictNotShowingVersionResult() { + return MermaidDependencyEdgeRenderer.CONFLICT_PREFIX; + } + + @Override + protected String renderWithDuplicateResult() { + return MermaidDependencyEdgeRenderer.DUPLICATE_PREFIX; + } +} diff --git a/src/test/java/com/github/ferstl/depgraph/dependency/mermaid/MermaidDependencyNodeNameRendererTest.java b/src/test/java/com/github/ferstl/depgraph/dependency/mermaid/MermaidDependencyNodeNameRendererTest.java new file mode 100644 index 00000000..74024d03 --- /dev/null +++ b/src/test/java/com/github/ferstl/depgraph/dependency/mermaid/MermaidDependencyNodeNameRendererTest.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2014 - 2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.github.ferstl.depgraph.dependency.mermaid; + +import com.github.ferstl.depgraph.dependency.AbstractDependencyNodeNameRendererTest; +import com.github.ferstl.depgraph.dependency.DependencyNode; +import com.github.ferstl.depgraph.graph.NodeRenderer; + +public class MermaidDependencyNodeNameRendererTest extends AbstractDependencyNodeNameRendererTest { + + @Override + protected NodeRenderer createNodeNameRenderer(boolean showGroupId, boolean showArtifactId, boolean showTypes, boolean showClassifiers, boolean showVersion, boolean showOptional, boolean showScope) { + return new MermaidDependencyNodeNameRenderer(showGroupId, showArtifactId, showTypes, showClassifiers, showVersion, showOptional, showScope); + } + + @Override + protected String renderNothingResult() { + return "[\" \"]"; + } + + @Override + protected String renderGroupIdResult() { + return "[\"groupId\"]"; + } + + @Override + protected String renderArtifactIdResult() { + return "[\"artifactId\"]"; + } + + @Override + protected String renderVersionResult() { + return "[\"version\"]"; + } + + @Override + protected String renderOptionalResult() { + return "[\"#lt;optional#gt;\"]"; + } + + @Override + protected String renderGroupIdArtifactIdVersionResult() { + return "[\"groupId
artifactId
version\"]"; + } + + @Override + protected String renderGroupIdArtifactIdVersionOptionalResult() { + return "[\"#lt;optional#gt;
groupId
artifactId
version\"]"; + } + + @Override + protected String renderGroupIdArtifactIdResult() { + return "[\"groupId
artifactId\"]"; + } + + @Override + protected String renderGroupIdArtifactIdOptionalResult() { + return "[\"#lt;optional#gt;
groupId
artifactId\"]"; + } + + @Override + protected String renderGroupIdVersionResult() { + return "[\"groupId
version\"]"; + } + + @Override + protected String renderGroupIdVersionOptionalResult() { + return "[\"#lt;optional#gt;
groupId
version\"]"; + } + + @Override + protected String renderArtifactIdVersionResult() { + return "[\"artifactId
version\"]"; + } + + @Override + protected String renderArtifactIdVersionOptionalResult() { + return "[\"#lt;optional#gt;
artifactId
version\"]"; + } + + @Override + protected String renderTypesResult() { + return "[\"artifactId
.jar/.zip\"]"; + } + + @Override + protected String renderJarTypeOnlyResult() { + return "[\"artifactId\"]"; + } + + @Override + protected String renderClassifiersResult() { + return "[\"artifactId
classifier1/classifier2\"]"; + } + + @Override + protected String renderEmptyClassifierResult() { + return "[\"artifactId\"]"; + } + + @Override + protected String renderAllResult() { + return "[\"groupId
artifactId
version
.jar/.tar.gz/.zip
classifier1/classifier2
(test)\"]"; + } + + @Override + protected String renderOmitScopeResult() { + return "[\"groupId
artifactId
version\"]"; + } + +} diff --git a/src/test/java/com/github/ferstl/depgraph/dependency/mermaid/MermaidGraphStyleConfigurerTest.java b/src/test/java/com/github/ferstl/depgraph/dependency/mermaid/MermaidGraphStyleConfigurerTest.java new file mode 100644 index 00000000..51c4eab7 --- /dev/null +++ b/src/test/java/com/github/ferstl/depgraph/dependency/mermaid/MermaidGraphStyleConfigurerTest.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2014 - 2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.github.ferstl.depgraph.dependency.mermaid; + +import com.github.ferstl.depgraph.dependency.AbstractGraphStyleConfigurerTest; +import com.github.ferstl.depgraph.dependency.GraphStyleConfigurer; + +public class MermaidGraphStyleConfigurerTest extends AbstractGraphStyleConfigurerTest { + + @Override + protected GraphStyleConfigurer createGraphStyleConfigurer() { + return new MermaidGraphStyleConfigurer(); + } + + @Override + protected String getNodeNameForGroupIdOnly(String groupId) { + return "[\"" + groupId + "\"]"; + } + + @Override + protected String getNodeNameForArtifactIdOnly(String artifactId) { + return "[\"" + artifactId + "\"]"; + } + + @Override + protected String getNodeNameForVersionOnly(String version) { + return "[\"" + version + "\"]"; + } + + @Override + protected String getEdgeNameForNonConflictingVersion(String version) { + return ""; + } + + @Override + protected String getEdgeNameForConflictingVersion(String conflictingVersion, boolean showVersion) { + return showVersion ? MermaidDependencyEdgeRenderer.CONFLICT_PREFIX + conflictingVersion : MermaidDependencyEdgeRenderer.CONFLICT_PREFIX; + } + + @Override + protected String getNodeNameForAllAttributes(String groupId, String artifactId, String version) { + return "[\"" + groupId + "
" + artifactId + "
" + version + "\"]"; + } + + @Override + protected String getEmptyNodeName() { + return "[\" \"]"; + } +} diff --git a/src/test/java/com/github/ferstl/depgraph/graph/mermaid/MermaidGraphFormatterTest.java b/src/test/java/com/github/ferstl/depgraph/graph/mermaid/MermaidGraphFormatterTest.java new file mode 100644 index 00000000..32230929 --- /dev/null +++ b/src/test/java/com/github/ferstl/depgraph/graph/mermaid/MermaidGraphFormatterTest.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2014 - 2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.github.ferstl.depgraph.graph.mermaid; + +import com.github.ferstl.depgraph.graph.Edge; +import com.github.ferstl.depgraph.graph.Node; +import org.junit.jupiter.api.Test; + +import static java.util.Arrays.asList; +import static org.junit.jupiter.api.Assertions.assertEquals; + +class MermaidGraphFormatterTest { + + private MermaidGraphFormatter formatter = new MermaidGraphFormatter(); + + @Test + void format() { + // arrange + Node node1 = new Node<>("id1", "[\"name1\"]", new Object()); + Node node2 = new Node<>("id2", "", new Object()); + Node node3 = new Node<>("id3", "[\"name3\"]", new Object()); + + Edge edge1 = new Edge("id1", "id2", "[\"edge1\"]"); + Edge edge2 = new Edge("id1", "id2", ""); + + // act + String result = this.formatter.format("graphName", asList(node1, node2, node3), asList(edge1, edge2)); + + // assert + String expected = "flowchart TD\n" + + " %% Node Definitions:\n" + + " id1[\"name1\"]\n" + + " id2\n" + + " id3[\"name3\"]\n" + + "\n" + + " %% Edge Definitions:\n" + + " id1 --[\"edge1\"]--> id2\n" + + " id1 --> id2" + ; + + assertEquals(expected, result); + } +} diff --git a/src/test/projects/depgraph-maven-plugin-test/expectations/by-groupid_module-1.mmd b/src/test/projects/depgraph-maven-plugin-test/expectations/by-groupid_module-1.mmd new file mode 100644 index 00000000..48d70b7b --- /dev/null +++ b/src/test/projects/depgraph-maven-plugin-test/expectations/by-groupid_module-1.mmd @@ -0,0 +1,13 @@ +flowchart TD + %% Node Definitions: + com.github.ferstl:compile["com.github.ferstl"] + commons-codec:compile["commons-codec"] + org.apache.commons:compile["org.apache.commons"] + junit:test["junit
(test)"] + org.hamcrest:test["org.hamcrest
(test)"] + + %% Edge Definitions: + com.github.ferstl:compile --> commons-codec:compile + com.github.ferstl:compile --> org.apache.commons:compile + junit:test --> org.hamcrest:test + com.github.ferstl:compile --> junit:test \ No newline at end of file diff --git a/src/test/projects/depgraph-maven-plugin-test/expectations/by-groupid_module-2.mmd b/src/test/projects/depgraph-maven-plugin-test/expectations/by-groupid_module-2.mmd new file mode 100644 index 00000000..0bda073b --- /dev/null +++ b/src/test/projects/depgraph-maven-plugin-test/expectations/by-groupid_module-2.mmd @@ -0,0 +1,17 @@ +flowchart TD + %% Node Definitions: + com.github.ferstl:compile["com.github.ferstl"] + com.google.guava:compile["com.google.guava"] + commons-codec:compile["commons-codec"] + org.apache.commons:compile["org.apache.commons"] + org.springframework:compile["org.springframework"] + junit:test["junit
(test)"] + org.hamcrest:test["org.hamcrest
(test)"] + + %% Edge Definitions: + com.github.ferstl:compile --> com.google.guava:compile + com.github.ferstl:compile --> commons-codec:compile + com.github.ferstl:compile --> org.apache.commons:compile + com.github.ferstl:compile --> org.springframework:compile + junit:test --> org.hamcrest:test + com.github.ferstl:compile --> junit:test \ No newline at end of file diff --git a/src/test/projects/depgraph-maven-plugin-test/expectations/by-groupid_module-3.mmd b/src/test/projects/depgraph-maven-plugin-test/expectations/by-groupid_module-3.mmd new file mode 100644 index 00000000..f2ab1067 --- /dev/null +++ b/src/test/projects/depgraph-maven-plugin-test/expectations/by-groupid_module-3.mmd @@ -0,0 +1,19 @@ +flowchart TD + %% Node Definitions: + com.github.ferstl:compile["com.github.ferstl"] + commons-codec:compile["commons-codec"] + org.apache.commons:compile["org.apache.commons"] + com.google.guava:compile["com.google.guava"] + com.mysema.querydsl:compile["com.mysema.querydsl"] + com.google.code.findbugs:compile["com.google.code.findbugs"] + com.mysema.commons:compile["com.mysema.commons"] + com.infradna.tool:compile["com.infradna.tool"] + + %% Edge Definitions: + com.github.ferstl:compile --> commons-codec:compile + com.github.ferstl:compile --> org.apache.commons:compile + com.github.ferstl:compile --> com.google.guava:compile + com.mysema.querydsl:compile --> com.google.code.findbugs:compile + com.mysema.querydsl:compile --> com.mysema.commons:compile + com.mysema.querydsl:compile --> com.infradna.tool:compile + com.github.ferstl:compile --> com.mysema.querydsl:compile \ No newline at end of file diff --git a/src/test/projects/depgraph-maven-plugin-test/expectations/by-groupid_parent.mmd b/src/test/projects/depgraph-maven-plugin-test/expectations/by-groupid_parent.mmd new file mode 100644 index 00000000..c2493429 --- /dev/null +++ b/src/test/projects/depgraph-maven-plugin-test/expectations/by-groupid_parent.mmd @@ -0,0 +1,5 @@ +flowchart TD + %% Node Definitions: + com.github.ferstl:compile["com.github.ferstl"] + + %% Edge Definitions: \ No newline at end of file diff --git a/src/test/projects/depgraph-maven-plugin-test/expectations/by-groupid_sub-parent.mmd b/src/test/projects/depgraph-maven-plugin-test/expectations/by-groupid_sub-parent.mmd new file mode 100644 index 00000000..9c67cabb --- /dev/null +++ b/src/test/projects/depgraph-maven-plugin-test/expectations/by-groupid_sub-parent.mmd @@ -0,0 +1,11 @@ +flowchart TD + %% Node Definitions: + com.github.ferstl:compile["com.github.ferstl"] + com.google.guava:compile["com.google.guava"] + commons-codec:compile["commons-codec"] + org.apache.commons:compile["org.apache.commons"] + + %% Edge Definitions: + com.github.ferstl:compile --> com.google.guava:compile + com.github.ferstl:compile --> commons-codec:compile + com.github.ferstl:compile --> org.apache.commons:compile \ No newline at end of file diff --git a/src/test/projects/depgraph-maven-plugin-test/expectations/graph_module-1.mmd b/src/test/projects/depgraph-maven-plugin-test/expectations/graph_module-1.mmd new file mode 100644 index 00000000..259c3afd --- /dev/null +++ b/src/test/projects/depgraph-maven-plugin-test/expectations/graph_module-1.mmd @@ -0,0 +1,13 @@ +flowchart TD + %% Node Definitions: + com.github.ferstl:module-1:jar["module-1"] + commons-codec:commons-codec:jar["commons-codec"] + org.apache.commons:commons-lang3:jar["commons-lang3"] + junit:junit:jar["junit
(test)"] + org.hamcrest:hamcrest-core:jar["hamcrest-core
(test)"] + + %% Edge Definitions: + com.github.ferstl:module-1:jar --> commons-codec:commons-codec:jar + com.github.ferstl:module-1:jar --> org.apache.commons:commons-lang3:jar + junit:junit:jar --> org.hamcrest:hamcrest-core:jar + com.github.ferstl:module-1:jar --> junit:junit:jar diff --git a/src/test/projects/depgraph-maven-plugin-test/expectations/graph_module-2.mmd b/src/test/projects/depgraph-maven-plugin-test/expectations/graph_module-2.mmd new file mode 100644 index 00000000..c4011a91 --- /dev/null +++ b/src/test/projects/depgraph-maven-plugin-test/expectations/graph_module-2.mmd @@ -0,0 +1,19 @@ +flowchart TD + %% Node Definitions: + com.github.ferstl:module-2:jar["module-2"] + com.github.ferstl:module-1:jar["module-1"] + com.google.guava:guava:jar["guava"] + commons-codec:commons-codec:jar["commons-codec"] + org.apache.commons:commons-lang3:jar["commons-lang3"] + org.springframework:spring-core:jar["#lt;optional#gt;
spring-core"] + junit:junit:jar["junit
(test)"] + org.hamcrest:hamcrest-core:jar["hamcrest-core
(test)"] + + %% Edge Definitions: + com.github.ferstl:module-2:jar --> com.github.ferstl:module-1:jar + com.github.ferstl:module-2:jar --> com.google.guava:guava:jar + com.github.ferstl:module-2:jar --> commons-codec:commons-codec:jar + com.github.ferstl:module-2:jar --> org.apache.commons:commons-lang3:jar + com.github.ferstl:module-2:jar --> org.springframework:spring-core:jar + junit:junit:jar --> org.hamcrest:hamcrest-core:jar + com.github.ferstl:module-2:jar --> junit:junit:jar diff --git a/src/test/projects/depgraph-maven-plugin-test/expectations/graph_module-3.mmd b/src/test/projects/depgraph-maven-plugin-test/expectations/graph_module-3.mmd new file mode 100644 index 00000000..3adb7ce0 --- /dev/null +++ b/src/test/projects/depgraph-maven-plugin-test/expectations/graph_module-3.mmd @@ -0,0 +1,23 @@ +flowchart TD + %% Node Definitions: + com.github.ferstl:module-1:jar["module-1"] + commons-codec:commons-codec:jar["commons-codec"] + org.apache.commons:commons-lang3:jar["commons-lang3"] + com.github.ferstl:module-3:jar["module-3"] + com.github.ferstl:module-2:jar["module-2"] + com.google.guava:guava:jar["guava"] + com.mysema.querydsl:querydsl-core:jar["querydsl-core"] + com.google.code.findbugs:jsr305:jar["jsr305"] + com.mysema.commons:mysema-commons-lang:jar["mysema-commons-lang"] + com.infradna.tool:bridge-method-annotation:jar["bridge-method-annotation"] + + %% Edge Definitions: + com.github.ferstl:module-1:jar --> commons-codec:commons-codec:jar + com.github.ferstl:module-1:jar --> org.apache.commons:commons-lang3:jar + com.github.ferstl:module-3:jar --> com.github.ferstl:module-1:jar + com.github.ferstl:module-2:jar --> com.google.guava:guava:jar + com.github.ferstl:module-3:jar --> com.github.ferstl:module-2:jar + com.mysema.querydsl:querydsl-core:jar --> com.google.code.findbugs:jsr305:jar + com.mysema.querydsl:querydsl-core:jar --> com.mysema.commons:mysema-commons-lang:jar + com.mysema.querydsl:querydsl-core:jar --> com.infradna.tool:bridge-method-annotation:jar + com.github.ferstl:module-3:jar --> com.mysema.querydsl:querydsl-core:jar diff --git a/src/test/projects/depgraph-maven-plugin-test/expectations/graph_parent.mmd b/src/test/projects/depgraph-maven-plugin-test/expectations/graph_parent.mmd new file mode 100644 index 00000000..73f441f5 --- /dev/null +++ b/src/test/projects/depgraph-maven-plugin-test/expectations/graph_parent.mmd @@ -0,0 +1,5 @@ +flowchart TD + %% Node Definitions: + com.github.ferstl:parent:pom["parent"] + + %% Edge Definitions: \ No newline at end of file diff --git a/src/test/projects/depgraph-maven-plugin-test/expectations/graph_sub-parent.mmd b/src/test/projects/depgraph-maven-plugin-test/expectations/graph_sub-parent.mmd new file mode 100644 index 00000000..2c9a3509 --- /dev/null +++ b/src/test/projects/depgraph-maven-plugin-test/expectations/graph_sub-parent.mmd @@ -0,0 +1,15 @@ +flowchart TD + %% Node Definitions: + com.github.ferstl:module-2:jar["module-2"] + com.github.ferstl:module-1:jar["module-1"] + com.google.guava:guava:jar["guava"] + commons-codec:commons-codec:jar["commons-codec"] + org.apache.commons:commons-lang3:jar["commons-lang3"] + com.github.ferstl:sub-parent:pom["sub-parent"] + + %% Edge Definitions: + com.github.ferstl:module-2:jar --> com.github.ferstl:module-1:jar + com.github.ferstl:module-2:jar --> com.google.guava:guava:jar + com.github.ferstl:module-2:jar --> commons-codec:commons-codec:jar + com.github.ferstl:module-2:jar --> org.apache.commons:commons-lang3:jar + com.github.ferstl:sub-parent:pom --> com.github.ferstl:module-2:jar diff --git a/src/test/projects/no-dependencies/expectations/example.mmd b/src/test/projects/no-dependencies/expectations/example.mmd new file mode 100644 index 00000000..710af8d8 --- /dev/null +++ b/src/test/projects/no-dependencies/expectations/example.mmd @@ -0,0 +1,26 @@ +flowchart TD + %% Node Definitions: + com.example:artifact-a:jar["artifact-a"] + com.example:artifact-b:jar["artifact-b"] + com.example:artifact-d:jar["artifact-d"] + com.example.sub:artifact-g:jar["artifact-g
(test)"] + com.example:artifact-c:jar["artifact-c"] + com.example.sub:artifact-zip:zip["artifact-zip"] + com.example.sub:artifact-e:jar["artifact-e
(provided)"] + com.example.sub:artifact-f:jar["artifact-f
(runtime)"] + + %% Edge Definitions: + com.example:artifact-a:jar --> com.example:artifact-b:jar + com.example:artifact-a:jar --> com.example:artifact-d:jar + com.example.sub:artifact-g:jar --> com.example:artifact-c:jar + com.example:artifact-b:jar --> com.example:artifact-c:jar + com.example:artifact-b:jar --> com.example:artifact-d:jar + com.example.sub:artifact-zip:zip --> com.example:artifact-c:jar + com.example:artifact-d:jar --> com.example.sub:artifact-e:jar + com.example:artifact-d:jar --> com.example.sub:artifact-f:jar + com.example:artifact-b:jar --> com.example.sub:artifact-g:jar + com.example:artifact-b:jar --> com.example.sub:artifact-zip:zip + + %% Edge Styles: + linkStyle 2 color:#FF0000, stroke:#FF0000, stroke-dasharray:10px + linkStyle 5 color:#000000, stroke:#000000, stroke-dasharray:3px