Skip to content

Commit 641dec4

Browse files
authored
Merge pull request #1 from jimisola/main
feat: initial commit of Gradle plugin for reqstool
2 parents 646e94a + 59143d8 commit 641dec4

27 files changed

Lines changed: 1497 additions & 1 deletion

.github/workflows/build.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
on:
2+
workflow_call:
3+
workflow_dispatch:
4+
push:
5+
pull_request:
6+
types:
7+
- opened
8+
- reopened
9+
- synchronize
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Set up Java
17+
uses: actions/setup-java@v5
18+
with:
19+
java-version: "21"
20+
distribution: "temurin"
21+
- name: Build
22+
run: ./gradlew clean build
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Check rules for release
2+
on:
3+
workflow_call:
4+
5+
jobs:
6+
check-release:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Check branch and tag
10+
if: github.event_name == 'push' && !(github.ref == 'refs/heads/main' && startsWith(github.ref, 'refs/tags/'))
11+
run: exit 1
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Publish to GitHub Pages
2+
on:
3+
workflow_dispatch:
4+
release:
5+
types: [created]
6+
push:
7+
branches:
8+
- main
9+
10+
concurrency:
11+
group: github-pages
12+
cancel-in-progress: false
13+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
14+
permissions:
15+
contents: read
16+
pages: write
17+
id-token: write
18+
jobs:
19+
publish_gh_pages:
20+
runs-on: ubuntu-latest
21+
environment:
22+
name: github-pages
23+
url: ${{ steps.deployment.outputs.page_url }}
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
- name: Configure Pages
28+
uses: actions/configure-pages@v5
29+
- name: Install Node.js
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: "22"
33+
- name: Install Antora
34+
run: npm i antora
35+
- name: Install Asciidoctor Kroki extension
36+
run: npm i asciidoctor asciidoctor-kroki
37+
- name: Generate Site
38+
run: npx antora docs/antora-playbook.yml
39+
- name: Create site folders
40+
run: mkdir -p docs/build/site
41+
- name: Upload Artifacts
42+
uses: actions/upload-pages-artifact@v3
43+
with:
44+
path: docs/build/site
45+
- name: Deploy to GitHub Pages
46+
id: deployment
47+
uses: actions/deploy-pages@v4
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
name: Publish Gradle Plugin to Plugin Portal
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
check-release:
9+
name: Reuse check release
10+
uses: ./.github/workflows/check_release.yml
11+
build:
12+
name: Reuse build
13+
uses: ./.github/workflows/build.yml
14+
publish:
15+
needs:
16+
- build
17+
- check-release
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Set up Java for publishing to Gradle Plugin Portal
22+
uses: actions/setup-java@v5
23+
with:
24+
java-version: "21"
25+
distribution: "temurin"
26+
- name: Publish plugin to Gradle Plugin Portal
27+
run: ./gradlew publishPlugins
28+
env:
29+
GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }}
30+
GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }}

.gitignore

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
.gradle
2+
build/
3+
!gradle/wrapper/gradle-wrapper.jar
4+
!**/src/main/**/build/
5+
!**/src/test/**/build/
6+
7+
### IntelliJ IDEA ###
8+
.idea
9+
*.iws
10+
*.iml
11+
*.ipr
12+
out/
13+
!**/src/main/**/out/
14+
!**/src/test/**/out/
15+
16+
### Eclipse ###
17+
.apt_generated
18+
.classpath
19+
.factorypath
20+
.project
21+
.settings
22+
.springBeans
23+
.sts4-cache
24+
bin/
25+
!**/src/main/**/bin/
26+
!**/src/test/**/bin/
27+
28+
### NetBeans ###
29+
/nbproject/private/
30+
/nbbuild/
31+
/dist/
32+
/nbdist/
33+
/.nb-gradle/
34+
35+
### VS Code ###
36+
.vscode/
37+
38+
### Mac OS ###
39+
.DS_Store

README.adoc

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
= Reqstool Gradle Plugin
2+
:toc:
3+
:toc-placement!:
4+
5+
image:https://img.shields.io/badge/License-MIT-blue.svg[License,link=LICENSE]
6+
7+
Gradle plugin for assembling and attaching reqstool ZIP artifacts. This plugin mimics the behavior of the link:https://github.com/Luftfartsverket/reqstool-java-maven-plugin[reqstool-java-maven-plugin].
8+
9+
toc::[]
10+
11+
== Features
12+
13+
* *Zero-configuration*: Works out of the box with sensible defaults
14+
* *Automatic lifecycle integration*: Runs as part of the standard `build` task
15+
* *Maven publishing support*: Automatically registers ZIP artifact for publication
16+
* *Combines annotations*: Merges requirements annotations from implementation and test code
17+
* *Assembles ZIP artifact*: Creates structured ZIP containing requirements, test results, and configuration
18+
19+
== Quick Start
20+
21+
=== Apply the Plugin
22+
23+
[source,gradle]
24+
----
25+
plugins {
26+
id 'se.lfv.reqstool' version '1.0.0'
27+
}
28+
----
29+
30+
=== Default Behavior
31+
32+
The plugin automatically:
33+
34+
1. Runs after the `check` task (when tests complete)
35+
2. Combines annotation files from `build/generated-sources/` and `build/generated-test-sources/`
36+
3. Creates a ZIP artifact in `build/reqstool/` containing:
37+
* `requirements.yml` (from `./reqstool/` directory)
38+
* `software_verification_cases.yml` (optional)
39+
* `manual_verification_results.yml` (optional)
40+
* `annotations.yml` (combined/merged annotations)
41+
* `test_results/` (XML test results from `build/test-results/`)
42+
* `reqstool_config.yml` (configuration manifest)
43+
4. Registers the ZIP for Maven publication (if `maven-publish` plugin is applied)
44+
45+
=== Minimal Setup
46+
47+
Create a `reqstool/` directory in your project root with a `requirements.yml` file:
48+
49+
----
50+
my-project/
51+
├── build.gradle
52+
├── reqstool/
53+
│ └── requirements.yml (mandatory)
54+
└── src/
55+
----
56+
57+
Run `gradle build` and the ZIP artifact will be created automatically.
58+
59+
== Configuration
60+
61+
The plugin provides zero-configuration defaults, but you can customize if needed:
62+
63+
[source,gradle]
64+
----
65+
requirementsTool {
66+
// Path to requirements annotations YAML
67+
// Default: build/generated-sources/annotations/resources/annotations.yml
68+
requirementsAnnotationsFile = file('build/custom-path/annotations.yml')
69+
70+
// Path to SVCS annotations YAML
71+
// Default: build/generated-test-sources/test-annotations/resources/annotations.yml
72+
svcsAnnotationsFile = file('build/custom-path/test-annotations.yml')
73+
74+
// Output directory for ZIP and combined annotations
75+
// Default: build/reqstool
76+
outputDirectory = file('build/custom-output')
77+
78+
// Dataset directory containing requirements.yml and optional files
79+
// Default: ./reqstool
80+
datasetPath = file('custom-reqstool-data')
81+
82+
// Test result file patterns
83+
// Default: ['build/test-results/**/*.xml']
84+
testResults = ['build/test-results/**/*.xml', 'build/custom-tests/**/*.xml']
85+
86+
// Skip entire plugin execution
87+
// Default: false
88+
skip = false
89+
90+
// Skip ZIP assembly but keep annotation combining
91+
// Default: false
92+
skipAssembleZipArtifact = false
93+
94+
// Skip artifact attachment for publishing
95+
// Default: false
96+
skipAttachZipArtifact = false
97+
}
98+
----
99+
100+
== Publishing
101+
102+
When the `maven-publish` plugin is applied, the reqstool ZIP is automatically registered for publication:
103+
104+
[source,gradle]
105+
----
106+
plugins {
107+
id 'se.lfv.reqstool' version '1.0.0'
108+
id 'maven-publish'
109+
}
110+
111+
publishing {
112+
repositories {
113+
maven {
114+
url = "https://your-repo.example.com/maven"
115+
}
116+
}
117+
}
118+
----
119+
120+
The ZIP artifact will be published with classifier `reqstool` (e.g., `my-app-1.0.0-reqstool.zip`).
121+
122+
== Tasks
123+
124+
=== `assembleRequirements`
125+
126+
Main task that:
127+
128+
* Depends on `check` task (ensures tests have run)
129+
* Combines annotation files
130+
* Assembles ZIP artifact
131+
* Runs automatically as part of `build` task
132+
133+
Run manually:
134+
135+
[source,bash]
136+
----
137+
gradle assembleRequirements
138+
----
139+
140+
== Requirements
141+
142+
* Gradle 6.0+ (tested with Gradle 9.3)
143+
* Java 8+
144+
* A `requirements.yml` file in the dataset directory (default: `./reqstool/`)
145+
146+
== License
147+
148+
MIT License - see link:LICENSE[LICENSE] file for details
149+
150+
== Credits
151+
152+
Based on link:https://github.com/Luftfartsverket/reqstool-java-maven-plugin[reqstool-java-maven-plugin] by Luftfartsverket (LFV).

README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

build.gradle

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
plugins {
2+
id 'java-gradle-plugin'
3+
id 'java-library'
4+
id 'maven-publish'
5+
id 'io.spring.javaformat' version '0.0.47'
6+
}
7+
8+
group = 'se.lfv.reqstool'
9+
version = '0.1.0'
10+
11+
java {
12+
sourceCompatibility = JavaVersion.VERSION_1_8
13+
targetCompatibility = JavaVersion.VERSION_1_8
14+
}
15+
16+
repositories {
17+
mavenCentral()
18+
}
19+
20+
gradlePlugin {
21+
plugins {
22+
reqstoolPlugin {
23+
id = 'se.lfv.reqstool'
24+
implementationClass = 'se.lfv.reqstool.gradle.RequirementsToolPlugin'
25+
displayName = 'Reqstool Gradle Plugin'
26+
description = 'Gradle plugin for assembling and attaching reqstool ZIP artifacts'
27+
tags.set(['reqstool', 'requirements', 'verification', 'testing'] )
28+
}
29+
}
30+
}
31+
32+
dependencies {
33+
// Jackson for YAML processing
34+
implementation 'com.fasterxml.jackson.core:jackson-databind:2.18.3'
35+
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.18.3'
36+
37+
// SnakeYAML for reqstool_config.yml generation
38+
implementation 'org.yaml:snakeyaml:2.3'
39+
40+
// Testing - JUnit BOM for version management
41+
testImplementation platform('org.junit:junit-bom:5.11.4')
42+
testImplementation 'org.junit.jupiter:junit-jupiter-api'
43+
testImplementation 'org.junit.jupiter:junit-jupiter-params'
44+
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
45+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
46+
}
47+
48+
test {
49+
useJUnitPlatform()
50+
}

gradle/wrapper/gradle-wrapper.jar

44.6 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)