Skip to content

Commit

Permalink
#56 Add support for option detailsSectionDisplay (#59)
Browse files Browse the repository at this point in the history
Co-authored-by: kaklakariada <christoph@users.sourceforge.net>
  • Loading branch information
kaklakariada and kaklakariada authored Feb 26, 2024
1 parent dc5b19a commit 965ea90
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 56 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.7.0] - 2024-02-26

- [PR #57](https://github.com/itsallcode/openfasttrace-maven-plugin/pull/57) Mark plugin as thread safe
- This suppresses a warning when running the Maven build in parallel with `-T 1C`
- This suppresses warnings about vulnerabilities in `provided` dependency `com.google.guava:guava:jar:25.1-android` via `org.apache.maven:maven-core`:
Expand All @@ -18,6 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- CVE-2012-2098 CWE-310 (5.0)
- CVE-2023-37460 CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (9.8)
- [Issue #55](https://github.com/itsallcode/openfasttrace-maven-plugin/issues/55) Allow skipping the execution of this plugin by adding option `-Dopenfasttrace.skip=true`
- [Issue #56](https://github.com/itsallcode/openfasttrace-maven-plugin/issues/56) Upgrade to [OpenFastTrace 3.8.0](https://github.com/itsallcode/openfasttrace/releases/tag/3.8.0)
- This adds support for the new option `detailsSectionDisplay`

## [1.6.2] - 2023-03-12

Expand Down
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Add the openfasttrace-maven-plugin to your `pom.xml`:
<plugin>
<groupId>org.itsallcode</groupId>
<artifactId>openfasttrace-maven-plugin</artifactId>
<version>1.6.2</version>
<version>1.7.0</version>
<executions>
<execution>
<id>trace-requirements</id>
Expand All @@ -48,6 +48,7 @@ Add the openfasttrace-maven-plugin to your `pom.xml`:
<reportOutputFormat>html</reportOutputFormat>
<reportVerbosity>ALL</reportVerbosity>
<reportShowOrigin>true</reportShowOrigin>
<detailsSectionDisplay>COLLAPSE</detailsSectionDisplay>
</configuration>
</plugin>
```
Expand All @@ -64,9 +65,19 @@ You can configure the plugin using the `<configuration>` element.

#### Report

The tracing report will be written to `target/tracing-report.txt` by default. You can configure the location with `<outputDirectory>${project.build.directory}/reports/</outputDirectory>`.
##### Report Format

#### Fail build
The tracing report is in HTML format by default. You can configure plain text format with `<reportOutputFormat>plain</reportOutputFormat>`.

##### Report Location

The tracing report will be written to `target/tracing-report.html` by default. You can configure the location with `<outputDirectory>${project.build.directory}/reports/</outputDirectory>`.

##### HTML Report Details Section Display

The HTML report will have its details sections collapsed (i.e. hidden) by default. You can render the HTML with expanded details sections with `<detailsSectionDisplay>EXPAND</detailsSectionDisplay>`.

#### Fail Build

By default the build will fail when there are errors found during tracing. To continue with the build when tracing fails, use configuration `<failBuild>false</failBuild>`.

Expand Down Expand Up @@ -148,7 +159,7 @@ mvn --update-snapshots versions:display-dependency-updates versions:display-plug
1. Run command

```sh
mvn -DskipSigningArtifacts=false clean deploy
mvn clean deploy -Possrh -DautoReleaseAfterClose=true
```

1. Create a [release](https://github.com/itsallcode/openfasttrace-maven-plugin/releases) of the `main` branch on GitHub.
Expand Down
77 changes: 42 additions & 35 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.itsallcode</groupId>
<artifactId>openfasttrace-maven-plugin</artifactId>
<version>1.6.2</version>
<version>1.7.0</version>
<packaging>maven-plugin</packaging>

<name>OpenFastTrace Maven Plugin</name>
Expand All @@ -15,7 +15,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>11</java.version>
<oft.version>3.7.1</oft.version>
<oft.version>3.8.0</oft.version>
<maven.core.version>3.8.7</maven.core.version>
<skipSigningArtifacts>true</skipSigningArtifacts>
<junit.version>5.10.2</junit.version>
Expand Down Expand Up @@ -184,6 +184,46 @@
</dependency>
</dependencies>

<profiles>
<profile>
<id>ossrh</id>
<build>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.13</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>false</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.1</version>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -411,39 +451,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
<configuration>
<skip>${skipSigningArtifacts}</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.1</version>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.13</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.ossindex.maven</groupId>
<artifactId>ossindex-maven-plugin</artifactId>
Expand Down
48 changes: 32 additions & 16 deletions src/main/java/org/itsallcode/openfasttrace/maven/TraceMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.*;
import org.apache.maven.project.*;
import org.itsallcode.openfasttrace.api.DetailsSectionDisplay;
import org.itsallcode.openfasttrace.api.ReportSettings;
import org.itsallcode.openfasttrace.api.core.*;
import org.itsallcode.openfasttrace.api.importer.ImportSettings;
Expand All @@ -20,7 +21,8 @@
import org.itsallcode.openfasttrace.core.OftRunner;

/**
* Trace requirements using OpenFastTrace
* Trace requirements using
* <a href="https://github.com/itsallcode/openfasttrace">OpenFastTrace</a>.
*/
@Mojo(name = "trace", defaultPhase = LifecyclePhase.VERIFY, threadSafe = true)
public class TraceMojo extends AbstractMojo
Expand All @@ -36,32 +38,32 @@ public class TraceMojo extends AbstractMojo
/**
* Let build fail when tracing fails.
* <p>
* Default: <code>true</code>
* Default: {@code true}
*/
@Parameter(property = "failBuild", defaultValue = "true", required = true)
private boolean failBuild;

/**
* The report output format, e.g. <code>plain</code> or <code>html</code>.
* <p>
* Default: <code>html</code>
* The report output format.
* <ul>
* <li>{@code html}: HTML format (default)</li>
* <li>{@code plain}: Plain text format</li>
* </ul>
*/
@Parameter(property = "reportOutputFormat", defaultValue = "html", required = true)
private String reportOutputFormat;

/**
* The report verbosity
* The report verbosity.
* <ul>
* <li><code>QUIET</code></li>
* <li><code>MINIMAL</code></li>
* <li><code>SUMMARY</code></li>
* <li><code>FAILURES</code></li>
* <li><code>FAILURE_SUMMARIES</code></li>
* <li><code>FAILURE_DETAILS</code></li>
* <li><code>ALL</code></li>
* <li>{@code QUIET}</li>
* <li>{@code MINIMAL}</li>
* <li>{@code SUMMARY}</li>
* <li>{@code FAILURES}</li>
* <li>{@code FAILURE_SUMMARIES}</li>
* <li>{@code FAILURE_DETAILS} (default)</li>
* <li>{@code ALL}</li>
* </ul>
* <p>
* Default: <code>FAILURE_DETAILS</code>
*/
@Parameter(property = "reportVerbosity", defaultValue = "FAILURE_DETAILS", required = true)
private ReportVerbosity reportVerbosity;
Expand All @@ -74,6 +76,17 @@ public class TraceMojo extends AbstractMojo
@Parameter(property = "reportShowOrigin", defaultValue = "false", required = true)
private boolean reportShowOrigin;

/**
* Determines if the details sections for specification items in the HTML
* report are hidden or visible.
* <ul>
* <li>{@code COLLAPSE}: hide details sections (default)</li>
* <li>{@code EXPAND}: show details section</li>
* </ul>
*/
@Parameter(property = "detailsSectionDisplay", defaultValue = "COLLAPSE", required = true)
private DetailsSectionDisplay detailsSectionDisplay;

/**
* Skip running OFT.
* <p>
Expand All @@ -91,6 +104,7 @@ public class TraceMojo extends AbstractMojo
@Parameter(defaultValue = "${session}", readonly = true)
private MavenSession session;


/**
* Create a new instance
*/
Expand Down Expand Up @@ -145,6 +159,7 @@ private void writeTracingReport(final Oft oft, final Trace trace)
.outputFormat(reportOutputFormat)
.verbosity(reportVerbosity)
.showOrigin(reportShowOrigin)
.detailsSectionDisplay(detailsSectionDisplay)
.build();
getLog().info("Writing tracing report to " + outputPath + " using settings " + formatSettings(reportSettings));
oft.reportToPath(trace, outputPath, reportSettings);
Expand All @@ -156,6 +171,7 @@ private static String formatSettings(final ReportSettings reportSettings)
+ ", verbosity: " + reportSettings.getReportVerbosity()
+ ", show origin: " + reportSettings.showOrigin()
+ ", newline: " + reportSettings.getNewline().name()
+ ", detailsSectionDisplay: " + reportSettings.getDetailsSectionDisplay().name()
+ "]";
}

Expand Down Expand Up @@ -185,7 +201,7 @@ private static void createDir(final Path path)

private ImportSettings createImportSettings()
{
final ImportSettings.Builder settings = ImportSettings.builder() //
final ImportSettings.Builder settings = ImportSettings.builder()
.addInputs(getSourcePaths());
final Optional<Path> docPath = getProjectSubPath("doc");
if (docPath.isPresent())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,20 @@ void testHtmlReport() throws Exception
runTracingMojo(HTML_REPORT_PROJECT);

assertThat(fileContent(HTML_REPORT_PROJECT.resolve("target/tracing-report.html")))
.contains("<span class=\"green\">&check;</span> 3 total");
.contains("<span class=\"green\">&check;</span> 3 total") //
.contains("<details>");
}

@Test
void testHtmlReportWithExpandedDetails() throws Exception
{
final Verifier verifier = mvnITEnv.getVerifier(HTML_REPORT_PROJECT);
verifier.addCliOption("-DdetailsSectionDisplay=EXPAND");
verifier.executeGoal(OFT_GOAL);
verifier.verifyErrorFreeLog();

assertThat(fileContent(HTML_REPORT_PROJECT.resolve("target/tracing-report.html")))
.contains("<details open>");
}

private static void runTracingMojo(final Path projectDir) throws Exception
Expand Down

0 comments on commit 965ea90

Please sign in to comment.