Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package org.hjug.mavenreport;

import java.io.File;
import lombok.extern.slf4j.Slf4j;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
import org.hjug.refactorfirst.report.JsonGenerator;

@Slf4j
@Mojo(
name = "jsonReport",
defaultPhase = LifecyclePhase.SITE,
requiresDependencyResolution = ResolutionScope.RUNTIME,
requiresProject = true,
threadSafe = true,
inheritByDefault = false)
public class RefactorFirstMavenJsonGenerator extends AbstractMojo {

@Parameter(property = "showDetails")
private boolean showDetails;

@Parameter(property = "backEdgeAnalysisCount")
protected int backEdgeAnalysisCount = 50;

@Parameter(property = "analyzeCycles")
private boolean analyzeCycles = true;

@Parameter(property = "excludeTests")
private boolean excludeTests = true;

@Parameter(property = "testSourceDirectory")
private String testSourceDirectory;

@Parameter(defaultValue = "${project.name}")
private String projectName;

@Parameter(defaultValue = "${project.version}")
private String projectVersion;

@Parameter(readonly = true, defaultValue = "${project}")
private MavenProject project;

@Parameter(property = "project.build.directory")
protected File outputDirectory;

/** Generates the RefactorFirst JSON report for the current Maven project. */
@Override
public void execute() {
JsonGenerator generator = new JsonGenerator();
generator.execute(
backEdgeAnalysisCount,
analyzeCycles,
showDetails,
excludeTests,
testSourceDirectory,
projectName,
projectVersion,
project.getBasedir(),
outputDirectory);
}
}
7 changes: 7 additions & 0 deletions report/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
<groupId>in.wilsonl.minifyhtml</groupId>
<artifactId>minify-html</artifactId>
</dependency>

<dependency>
<groupId>com.github.spullara.mustache.java</groupId>
<artifactId>compiler</artifactId>
<version>0.9.10</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
36 changes: 30 additions & 6 deletions report/src/main/java/org/hjug/refactorfirst/report/HtmlReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,8 @@ private static String generateDotImage(String graphName) {
+ " }\n" + "</script>\n";
}

String buildClassGraphDot(
/** Builds raw DOT source for the complete class relationship graph. */
String buildRawClassGraphDot(
Graph<String, DefaultWeightedEdge> classGraph, String repoUrl, CodebaseGraphDTO codebaseGraphDTO) {
StringBuilder dot = new StringBuilder();
dot.append("strict digraph G {\n");
Expand All @@ -583,7 +584,13 @@ String buildClassGraphDot(
renderClassVertices(classGraph, repoUrl, codebaseGraphDTO, vertexesToRender, dot);

dot.append("}");
return toJavaScriptTemplateLiteral(dot.toString());
return dot.toString();
}

/** Builds escaped class-graph DOT suitable for a JavaScript template literal. */
String buildClassGraphDot(
Graph<String, DefaultWeightedEdge> classGraph, String repoUrl, CodebaseGraphDTO codebaseGraphDTO) {
return toJavaScriptTemplateLiteral(buildRawClassGraphDot(classGraph, repoUrl, codebaseGraphDTO));
}

private void renderClassVertices(
Expand Down Expand Up @@ -942,7 +949,8 @@ public String renderClassCycleVisuals(RankedCycle cycle, String repoUrl, Codebas
return stringBuilder.toString();
}

String buildClassCycleDot(
/** Builds raw DOT source for a ranked class cycle. */
String buildRawClassCycleDot(
Graph<String, DefaultWeightedEdge> classGraph,
RankedCycle cycle,
String repoUrl,
Expand All @@ -959,7 +967,16 @@ String buildClassCycleDot(
renderClassVertices(classGraph, repoUrl, codebaseGraphDTO, vertexSet, dot);

dot.append("}");
return toJavaScriptTemplateLiteral(dot.toString());
return dot.toString();
}

/** Builds escaped class-cycle DOT suitable for a JavaScript template literal. */
String buildClassCycleDot(
Graph<String, DefaultWeightedEdge> classGraph,
RankedCycle cycle,
String repoUrl,
CodebaseGraphDTO codebaseGraphDTO) {
return toJavaScriptTemplateLiteral(buildRawClassCycleDot(classGraph, cycle, repoUrl, codebaseGraphDTO));
}

@Override
Expand Down Expand Up @@ -996,7 +1013,8 @@ public String renderPackageGraphVisuals(String repoUrl, CodebaseGraphDTO codebas
return stringBuilder.toString();
}

String buildPackageGraphDot(
/** Builds raw DOT source for the package relationship graph. */
String buildRawPackageGraphDot(
Graph<String, DefaultWeightedEdge> packageGraph, String repoUrl, CodebaseGraphDTO codebaseGraphDTO) {
StringBuilder dot = new StringBuilder();
dot.append("strict digraph G {\n");
Expand All @@ -1017,7 +1035,13 @@ String buildPackageGraphDot(
renderPackageVertices(packageGraph, repoUrl, codebaseGraphDTO, vertexesToRender, dot);

dot.append("}");
return toJavaScriptTemplateLiteral(dot.toString());
return dot.toString();
}

/** Builds escaped package-graph DOT suitable for a JavaScript template literal. */
String buildPackageGraphDot(
Graph<String, DefaultWeightedEdge> packageGraph, String repoUrl, CodebaseGraphDTO codebaseGraphDTO) {
return toJavaScriptTemplateLiteral(buildRawPackageGraphDot(packageGraph, repoUrl, codebaseGraphDTO));
}

private void renderPackageGraphEdge(
Expand Down
Loading
Loading