Skip to content

Commit

Permalink
Prepare for Doxia 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-o committed Dec 24, 2023
1 parent 83c4666 commit 64b1922
Show file tree
Hide file tree
Showing 34 changed files with 444 additions and 205 deletions.
7 changes: 2 additions & 5 deletions maven-surefire-report-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</prerequisites>

<properties>
<doxiaVersion>1.12.0</doxiaVersion>
<doxiaVersion>2.0.0-M8</doxiaVersion>
<aetherVersion>1.0.0.v20140518</aetherVersion>
</properties>

Expand Down Expand Up @@ -86,13 +86,10 @@
<artifactId>doxia-core</artifactId>
<version>${doxiaVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-impl</artifactId>
<version>4.0.0-M13</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.reporting.AbstractMavenReport;
import org.apache.maven.reporting.MavenReportException;
import org.apache.maven.settings.Settings;
import org.apache.maven.shared.utils.PathTool;
import org.codehaus.plexus.i18n.I18N;
Expand All @@ -55,7 +54,7 @@
*
* @author Stephen Connolly
*/
public abstract class AbstractSurefireReportMojo extends AbstractMavenReport {
public abstract class AbstractSurefireReport extends AbstractMavenReport {

/**
* If set to false, only failures are shown.
Expand All @@ -77,12 +76,6 @@ public abstract class AbstractSurefireReportMojo extends AbstractMavenReport {
@Parameter
private File reportsDirectory;

/**
* The projects in the reactor for aggregation report.
*/
@Parameter(defaultValue = "${reactorProjects}", readonly = true)
private List<MavenProject> reactorProjects;

/**
* Location of the Xrefs to link.
*/
Expand Down Expand Up @@ -148,16 +141,16 @@ protected boolean isGeneratedWhenNoResults() {
* {@inheritDoc}
*/
@Override
public void executeReport(Locale locale) throws MavenReportException {
public void executeReport(Locale locale) {
SurefireReportRenderer r = new SurefireReportRenderer(
getSink(),
getI18N(locale),
getI18Nsection(),
locale,
getConsoleLogger(),
showSuccess,
getReportsDirectories(),
determineXrefLocation());
determineXrefLocation(),
showSuccess);
r.render();
}

Expand Down Expand Up @@ -262,7 +255,8 @@ private String determineXrefLocation() {
String location = null;

if (linkXRef) {
String relativePath = PathTool.getRelativePath(getOutputDirectory(), xrefLocation.getAbsolutePath());
String relativePath = PathTool.getRelativePath(
getReportOutputDirectory().getAbsolutePath(), xrefLocation.getAbsolutePath());
if (relativePath == null || relativePath.isEmpty()) {
relativePath = ".";
}
Expand Down Expand Up @@ -345,6 +339,10 @@ protected MavenProject getProject() {
return project;
}

protected List<MavenProject> getReactorProjects() {
return reactorProjects;
}

// TODO Review, especially Locale.getDefault()
private static class CustomI18N implements I18N {
private final MavenProject project;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
*/
@Mojo(name = "failsafe-report-only")
@SuppressWarnings("unused")
public class FailsafeReportMojo extends AbstractSurefireReportMojo {
public class FailsafeOnlyReport extends AbstractSurefireReport {

/**
* The filename to use for the report.
*/
@Parameter(defaultValue = "failsafe-report", property = "outputName", required = true)
@Parameter(defaultValue = "failsafe", property = "outputName", required = true)
private String outputName;

/**
Expand All @@ -61,7 +61,7 @@ public class FailsafeReportMojo extends AbstractSurefireReportMojo {
@Override
protected File getSurefireReportsDirectory(MavenProject subProject) {
String buildDir = subProject.getBuild().getDirectory();
return new File(buildDir + "/failsafe-reports");
return new File(buildDir, "failsafe-reports");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
@Mojo(name = "report-only")
@Execute(phase = LifecyclePhase.NONE)
@SuppressWarnings("unused")
public class SurefireReportOnlyMojo extends SurefireReportMojo {}
public class SurefireOnlyReport extends SurefireReport {}
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
@Mojo(name = "report", inheritByDefault = false)
@Execute(lifecycle = "surefire", phase = LifecyclePhase.TEST)
@SuppressWarnings("unused")
public class SurefireReportMojo extends AbstractSurefireReportMojo {
public class SurefireReport extends AbstractSurefireReport {

/**
* The filename to use for the report.
*/
@Parameter(defaultValue = "surefire-report", property = "outputName", required = true)
@Parameter(defaultValue = "surefire", property = "outputName", required = true)
private String outputName;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ public class SurefireReportRenderer extends AbstractMavenReportRenderer {
private final Locale locale;

private final SurefireReportParser parser;
private final boolean showSuccess;
private final String xrefLocation;
private final List<ReportTestSuite> testSuites;
private final String xrefLocation;
private final boolean showSuccess;

public SurefireReportRenderer(
Sink sink,
I18N i18n,
String i18nSection,
Locale locale,
ConsoleLogger consoleLogger,
boolean showSuccess,
List<File> reportsDirectories,
String xrefLocation) {
String xrefLocation,
boolean showSuccess) {
super(sink);
this.i18n = i18n;
this.i18nSection = i18nSection;
Expand Down Expand Up @@ -112,11 +112,7 @@ private String formatI18nString(String section, String key, Object... args) {
public void renderBody() {
javaScript(javascriptToggleDisplayCode());

sink.section1();
sink.sectionTitle1();
sink.text(getTitle());
sink.sectionTitle1_();
sink.section1_();
startSection(getTitle());

renderSectionSummary();

Expand All @@ -125,16 +121,14 @@ public void renderBody() {
renderSectionTestCases();

renderSectionFailureDetails();

endSection();
}

private void renderSectionSummary() {
Map<String, Object> summary = parser.getSummary(testSuites);

sink.section1();
sinkAnchor("Summary");
sink.sectionTitle1();
sink.text(getI18nString("surefire", "label.summary"));
sink.sectionTitle1_();
startSection(getI18nString("surefire", "label.summary"), "Summary");

constructHotLinks();

Expand Down Expand Up @@ -168,7 +162,7 @@ private void renderSectionSummary() {

sink.lineBreak();

sink.section1_();
endSection();
}

private void renderSectionPackages() {
Expand All @@ -177,11 +171,7 @@ private void renderSectionPackages() {
return;
}

sink.section1();
sinkAnchor("Package_List");
sink.sectionTitle1();
sink.text(getI18nString("surefire", "label.packagelist"));
sink.sectionTitle1_();
startSection(getI18nString("surefire", "label.packagelist"), "Package_List");

constructHotLinks();

Expand Down Expand Up @@ -227,11 +217,7 @@ private void renderSectionPackages() {

List<ReportTestSuite> testSuiteList = entry.getValue();

sink.section2();
sinkAnchor(packageName);
sink.sectionTitle2();
sink.text(packageName);
sink.sectionTitle2_();
startSection(packageName);

boolean showTable = false;

Expand Down Expand Up @@ -266,12 +252,12 @@ private void renderSectionPackages() {
endTable();
}

sink.section2_();
endSection();
}

sink.lineBreak();

sink.section1_();
endSection();
}

private void renderSectionTestSuite(ReportTestSuite suite) {
Expand Down Expand Up @@ -320,23 +306,15 @@ private void renderSectionTestCases() {
return;
}

sink.section1();
sinkAnchor("Test_Cases");
sink.sectionTitle1();
sink.text(getI18nString("surefire", "label.testcases"));
sink.sectionTitle1_();
startSection(getI18nString("surefire", "label.testcases"), "Test_Cases");

constructHotLinks();

for (ReportTestSuite suite : testSuites) {
List<ReportTestCase> testCases = suite.getTestCases();

if (!testCases.isEmpty()) {
sink.section2();
sinkAnchor(suite.getPackageName() + '.' + suite.getName());
sink.sectionTitle2();
sink.text(suite.getName());
sink.sectionTitle2_();
startSection(suite.getName(), suite.getPackageName() + '.' + suite.getName());

boolean showTable = false;

Expand All @@ -360,13 +338,13 @@ private void renderSectionTestCases() {
endTable();
}

sink.section2_();
endSection();
}
}

sink.lineBreak();

sink.section1_();
endSection();
}

private void constructTestCaseSection(ReportTestCase testCase) {
Expand Down Expand Up @@ -469,7 +447,7 @@ private void constructTestCaseSection(ReportTestCase testCase) {
}

private String toHtmlId(String id) {
return DoxiaUtils.isValidId(id) ? id : DoxiaUtils.encodeId(id, true);
return DoxiaUtils.isValidId(id) ? id : DoxiaUtils.encodeId(id);
}

private void renderSectionFailureDetails() {
Expand All @@ -478,11 +456,7 @@ private void renderSectionFailureDetails() {
return;
}

sink.section1();
sinkAnchor("Failure_Details");
sink.sectionTitle1();
sink.text(getI18nString("surefire", "label.failuredetails"));
sink.sectionTitle1_();
startSection(getI18nString("surefire", "label.failuredetails"), "Failure_Details");

constructHotLinks();

Expand Down Expand Up @@ -554,7 +528,7 @@ private void renderSectionFailureDetails() {

sink.lineBreak();

sink.section1_();
endSection();
}

private void constructHotLinks() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(new JUnit4TestAdapter(Surefire597Test.class));
suite.addTest(new JUnit4TestAdapter(SurefireSchemaValidationTest.class));
suite.addTestSuite(SurefireReportMojoTest.class);
suite.addTestSuite(SurefireReportTest.class);
return suite;
}
}
Loading

0 comments on commit 64b1922

Please sign in to comment.