Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ jobs:
java-version: |
17
21
cache: 'gradle'

- uses: gradle/actions/wrapper-validation@v3
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Cache SonarQube packages
uses: actions/cache@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ jobs:
with:
distribution: 'temurin'
java-version: 17
cache: 'gradle'

- uses: gradle/actions/wrapper-validation@v3
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ jobs:
with:
distribution: "temurin"
java-version: 17
cache: "gradle"

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Build
run: ./gradlew build --warning-mode all
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "modifications",
"editor.formatOnSaveMode": "file",
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit",
"source.generate.finalModifiers": "explicit",
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [3.0.1] - 2024-09-07

- [PR #48](https://github.com/itsallcode/openfasttrace-gradle/pull/48)
- Fixed option `filteredArtifactTypes`
- Upgrade dependencies

## [3.0.0] - 2024-06-16

- [Issue #26](https://github.com/itsallcode/openfasttrace-gradle/issues/26)
- Added option `failBuild` that lets the build fail when it finds defects
- **Breaking Change:** `failBuild` is set to `true` by default. To keep the previous behaviour use `failBuild = false` in your build.
- **Breaking Change:** `failBuild` is set to `true` by default. To keep the previous behavior use `failBuild = false` in your build.

## [2.0.0] - 2024-06-13

Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Gradle plugin for the requirement tracing suite [OpenFastTrace](https://github.c
1. Preconditions: Java 17 and Gradle 8.6
1. Add plugin [`org.itsallcode.openfasttrace`](https://plugins.gradle.org/plugin/org.itsallcode.openfasttrace) to your project:

```gradle
```groovy
plugins {
id "org.itsallcode.openfasttrace" version "3.0.0"
id "org.itsallcode.openfasttrace" version "3.0.1"
}
```

Expand All @@ -34,14 +34,15 @@ Gradle plugin for the requirement tracing suite [OpenFastTrace](https://github.c

### General Configuration

```gradle
```groovy
requirementTracing {
failBuild = true
inputDirectories = files('custom-dir')
reportFile = file('build/custom-report.txt')
reportFormat = 'plain'
reportVerbosity = 'failure_details'
detailsSectionDisplay = 'collapse'
filteredArtifactTypes = ["req", "dsn"]
}
```

Expand All @@ -64,12 +65,13 @@ You can configure the following properties:
* `detailsSectionDisplay`: Initial display status of the details section in the HTML report
* `collapse` - hide details (default)
* `expand` - show details
* `filteredArtifactTypes`: Use only the listed artifact types during tracing

### Configuring the Short Tag Importer

The short tag importer allows omitting artifact type and the covered artifact type. Optionally you can add a prefix to the item name, e.g. a common module name.

```gradle
```groovy
requirementTracing {
tags {
tag {
Expand Down Expand Up @@ -110,7 +112,7 @@ Example: The Software Architecture Design project `swad` contains overall requir

If you want to publish requirements to a Maven repository you can use the following configuration in your `build.gradle`:

```gradle
```groovy
plugins {
id 'org.itsallcode.openfasttrace'
id 'maven-publish'
Expand Down Expand Up @@ -140,7 +142,7 @@ See [publish-config](https://github.com/itsallcode/openfasttrace-gradle/tree/mai

You can import requirements from another project using the `importedRequirements` configuration. The requirements must be published to a repository as a zip file and can be referenced using the usual gradle dependency syntax:

```gradle
```groovy
repositories {
maven {
url "http://repo.example.com/maven2"
Expand Down
19 changes: 9 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ plugins {
id 'java-gradle-plugin'
id 'jacoco'
id 'signing'
id 'com.gradle.plugin-publish' version '1.2.1'
id 'org.sonarqube' version '5.0.0.4638'
id 'com.gradle.plugin-publish' version '1.2.2'
id 'org.sonarqube' version '5.1.0.4882'
id 'pl.droidsonroids.jacoco.testkit' version '1.0.12'
id 'com.github.ben-manes.versions' version '0.51.0'
id 'org.sonatype.gradle.plugins.scan' version '2.8.2'
id 'org.sonatype.gradle.plugins.scan' version '2.8.3'
}

repositories {
Expand All @@ -15,13 +15,13 @@ repositories {

apply from: 'gradle/workAroundJacocoGradleTestKitIssueOnWindows.gradle'

version = '3.0.0'
version = '3.0.1'
group = 'org.itsallcode'

ext {
gradlePluginId = 'org.itsallcode.openfasttrace'
oftVersion = '4.0.0'
junitVersion = '5.10.2'
oftVersion = '4.1.0'
junitVersion = '5.11.0'
if (project.hasProperty('oftSourceDir')) {
oftSourceDir = file(project.oftSourceDir)
useOftSources = oftSourceDir.exists()
Expand Down Expand Up @@ -60,13 +60,12 @@ dependencies {
}

def getJavaVersion = {
return project.hasProperty('javaVersion') ? project.getProperty('javaVersion') : 17
return project.hasProperty('javaVersion') ? project.getProperty('javaVersion') : 17
}

java {
toolchain {
def javaVersion = getJavaVersion()
languageVersion = JavaLanguageVersion.of(javaVersion)
languageVersion = JavaLanguageVersion.of(getJavaVersion())
}
modularity.inferModulePath = false
}
Expand Down Expand Up @@ -126,7 +125,7 @@ testing {
useJUnitJupiter(junitVersion)
dependencies {
implementation "org.junit.jupiter:junit-jupiter-params:$junitVersion"
implementation "org.hamcrest:hamcrest-core:2.2"
implementation "org.hamcrest:hamcrest-core:3.0"
implementation "com.jparams:to-string-verifier:1.4.8"
}
}
Expand Down
3 changes: 3 additions & 0 deletions example-projects/custom-config/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ plugins {
id 'org.itsallcode.openfasttrace'
}

def artifactTypes = findProperty('filteredArtifactTypes')
artifactTypes = artifactTypes ? artifactTypes.split(',').toList() : null
requirementTracing {
failBuild = findProperty('failBuild') == 'true'
inputDirectories = files('custom-dir')
reportFile = file('build/custom-report.txt')
reportFormat = 'plain'
reportVerbosity = 'ALL'
filteredArtifactTypes = artifactTypes
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
5 changes: 4 additions & 1 deletion gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import org.gradle.api.file.ConfigurableFileCollection;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.plugins.ExtensionAware;
import org.gradle.api.provider.ListProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.provider.*;
import org.itsallcode.openfasttrace.api.DetailsSectionDisplay;
import org.itsallcode.openfasttrace.api.report.ReportVerbosity;

Expand All @@ -21,8 +20,8 @@ public class TracingConfig
private final ConfigurableFileCollection inputDirectories;
private final RegularFileProperty reportFile;
private final ListProperty<Object> importedRequirements;
private final ListProperty<String> filteredTags;
private final ListProperty<String> filteredArtifactTypes;
private final SetProperty<String> filteredTags;
private final SetProperty<String> filteredArtifactTypes;
private final Property<Boolean> filterAcceptsItemsWithoutTag;
private final Property<DetailsSectionDisplay> detailsSectionDisplay;
private final Property<Boolean> failBuild;
Expand All @@ -36,8 +35,8 @@ public TracingConfig(final Project project)
this.reportFormat = project.getObjects().property(String.class);
this.reportFormat.set(DEFAULT_REPORT_FORMAT);
this.importedRequirements = project.getObjects().listProperty(Object.class);
this.filteredTags = project.getObjects().listProperty(String.class);
this.filteredArtifactTypes = project.getObjects().listProperty(String.class);
this.filteredTags = project.getObjects().setProperty(String.class);
this.filteredArtifactTypes = project.getObjects().setProperty(String.class);
this.filterAcceptsItemsWithoutTag = project.getObjects().property(Boolean.class);
this.filterAcceptsItemsWithoutTag.set(true);
this.detailsSectionDisplay = project.getObjects().property(DetailsSectionDisplay.class);
Expand Down Expand Up @@ -71,12 +70,12 @@ public ListProperty<Object> getImportedRequirements()
return importedRequirements;
}

public ListProperty<String> getFilteredTags()
public SetProperty<String> getFilteredTags()
{
return filteredTags;
}

public ListProperty<String> getFilteredArtifactTypes()
public SetProperty<String> getFilteredArtifactTypes()
{
return filteredArtifactTypes;
}
Expand Down Expand Up @@ -161,6 +160,7 @@ public String toString()
{
return "TracingConfig [reportVerbosity=" + reportVerbosity + ", inputDirectories="
+ inputDirectories + ", reportFile=" + reportFile + ", pathConfig="
+ getTagPathConfig() + ", failBuild=" + failBuild + "]";
+ getTagPathConfig() + ", failBuild=" + failBuild + ", filteredArtifactTypes="
+ filteredArtifactTypes + "]";
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.itsallcode.openfasttrace.gradle.task;

import static java.util.Collections.emptySet;
import static java.util.stream.Collectors.toList;

import java.io.File;
Expand Down Expand Up @@ -70,6 +71,7 @@ public SetProperty<File> getImportedRequirements()
}

@Input
@Optional
public SetProperty<String> getFilteredArtifactTypes()
{
return filteredArtifactTypes;
Expand Down Expand Up @@ -119,15 +121,26 @@ public void trace()
getLogger().info("Tracing result: {} total items, {} defects. Writing report to {}",
trace.count(), trace.countDefects(), reportPath);
oft.reportToPath(trace, reportPath, getReportSettings());
if (trace.countDefects() > 0 && shouldFailBuild())
if (trace.countDefects() > 0)
{
throw new IllegalStateException("Requirement tracing found " + trace.countDefects()
+ " defects. See report at " + reportPath + " for details.");
final String message = "Requirement tracing found " + trace.countDefects()
+ " defects. See report at " + reportPath + " for details.";
if (shouldFailBuild())
{
throw new IllegalStateException(message);
}
getLogger().warn(message);
}
else
{
getLogger().info("Requirement tracing completed successfully.");
}
}

private ReportSettings getReportSettings()
{
getLogger().info("Report settings: verbosity={}, format={}, detailsSectionDisplay={}",
reportVerbosity.get(), reportFormat.get(), detailsSectionDisplay.get());
return ReportSettings.builder() //
.verbosity(reportVerbosity.get()) //
.outputFormat(reportFormat.get()) //
Expand All @@ -147,13 +160,14 @@ private ImportSettings getImportSettings()

private FilterSettings getFilterSettings()
{
getLogger().info("Filter: artifactTypes={}, tags={}, acceptItemsWithoutTag={}",
filteredArtifactTypes.get(), filteredTags.get(),
filterAcceptsItemsWithoutTag.get());
return FilterSettings.builder() //
.artifactTypes(filteredArtifactTypes.get()) //
final FilterSettings settings = FilterSettings.builder() //
.artifactTypes(filteredArtifactTypes.getOrElse(emptySet())) //
.tags(filteredTags.get()) //
.withoutTags(filterAcceptsItemsWithoutTag.get()).build();
getLogger().info("Filter settings: artifactTypes={}, tags={}, acceptItemsWithoutTag={}",
settings.getArtifactTypes(), settings.getTags(),
settings.isArtifactTypeCriteriaSet());
return settings;
}

private List<Path> getAllImportFiles()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public enum GradleTestConfig
/**
* We support the latest Gradle version and the previous two.
*/
EIGHT_SIX("8.6"), EIGHT_SEVEN("8.7"), EIGHT_EIGHT("8.8");
EIGHT_EIGHT("8.8"), EIGHT_NINE("8.9"), EIGHT_TEN("8.10");

public final String gradleVersion;

Expand Down
Loading