Demo project showing how to use the reqstool-maven-plugin or reqstool-gradle-plugin to create requirements traceability artifacts.
This project demonstrates:
-
Using
@Requirementsand@SVCsannotations in Java code -
Automatic generation of annotations from source code
-
Assembly of a ZIP artifact containing requirements, test results, and traceability data
-
Integration with the reqstool Python client for requirements analysis
-
Support for both Maven and Gradle build systems
-
Java 21+
-
Maven 3.9+ or Gradle 9.3+
-
Python 3.8+ (for reqstool client)
-
libgit2 (for reqstool client):
-
macOS:
brew install libgit2 -
Linux:
apt-get install libgit2-devoryum install libgit2-devel
-
mvn clean verifyThis will:
-
Compile source code and generate requirements annotations
-
Run tests and generate Software Verification Cases (SVCs) annotations
-
Combine annotations into a single file
-
Assemble a ZIP artifact
reqstool-demo-0.0.4-reqstool.zipintarget/reqstool/containing:-
requirements.yml- Requirements definitions -
software_verification_cases.yml- Test case definitions -
annotations.yml- Combined traceability annotations -
test_results/- JUnit XML test results -
reqstool_config.yml- Configuration manifest
-
gradle clean buildThis will:
-
Compile source code and generate requirements annotations
-
Run tests and generate Software Verification Cases (SVCs) annotations
-
Combine annotations into a single file
-
Assemble a ZIP artifact
reqstool-demo-0.0.4-reqstool.zipinbuild/reqstool/containing:-
requirements.yml- Requirements definitions -
software_verification_cases.yml- Test case definitions -
annotations.yml- Combined traceability annotations -
test_results/- JUnit XML test results -
reqstool_config.yml- Configuration manifest
-
# Install libgit2 dependency
# Ubuntu/Debian:
sudo apt-get install libgit2-dev
# RHEL/CentOS/Fedora:
sudo yum install libgit2-devel
# Create virtual environment (recommended)
python3 -m venv venv
source venv/bin/activate
# Install reqstool (libgit2 is typically in system paths)
pip install reqstool# Install libgit2 dependency
brew install libgit2
# Create virtual environment (recommended)
python3 -m venv venv
source venv/bin/activate
# Install reqstool with compiler flags (required to find libgit2 headers)
CFLAGS="-I/opt/homebrew/include" LDFLAGS="-L/opt/homebrew/lib" pip install reqstool|
Note
|
The CFLAGS and LDFLAGS are required because Homebrew installs libraries in /opt/homebrew (Apple Silicon) or /usr/local (Intel), and the Python package build process needs explicit paths to find the libgit2 headers and libraries for compiling the pygit2 native extension.
|
You can analyze requirements directly from the project directory or from the extracted ZIP artifact.
# Run reqstool status report
reqstool status local -p ./docs/reqstool
# Generate detailed reports
reqstool report status -p ./docs/reqstool# For Maven build:
cd target/reqstool
unzip reqstool-demo-*-reqstool.zip
cd reqstool-demo-*-reqstool
# For Gradle build:
cd build/reqstool
unzip reqstool-demo-0.0.4-reqstool.zip
cd reqstool-demo-0.0.4-reqstool
# Run analysis from extracted artifact
reqstool status local -p .The reqstool status local command generates a comprehensive report showing:
-
Requirements implementation status
-
Automated test coverage and results (passed/failed/skipped)
-
Manual verification results
-
Software Verification Cases (SVCs) status
-
Missing tests and manual verification results
|
Tip
|
For color-coded output in your terminal, ensure your terminal supports ANSI colors. |
reqstool-demo/
├── pom.xml # Maven configuration with reqstool plugin
├── docs/reqstool/ # Requirements data directory
│ ├── requirements.yml # Requirements definitions (mandatory)
│ ├── software_verification_cases.yml # Test case definitions (optional)
│ └── manual_verification_results.yml # Manual test results (optional)
├── src/
│ ├── main/java/ # Implementation code with @Requirements
│ └── test/java/ # Test code with @SVCs
└── target/
├── generated-sources/ # Generated requirements annotations
├── generated-test-sources/ # Generated SVCS annotations
└── reqstool/ # Output directory with ZIP artifact
reqstool-demo/
├── build.gradle # Gradle configuration with reqstool plugin
├── docs/reqstool/ # Requirements data directory
│ ├── requirements.yml # Requirements definitions (mandatory)
│ ├── software_verification_cases.yml # Test case definitions (optional)
│ └── manual_verification_results.yml # Manual test results (optional)
├── src/
│ ├── main/java/ # Implementation code with @Requirements
│ └── test/java/ # Test code with @SVCs
└── build/
├── generated/sources/annotationProcessor/ # Generated annotations
└── reqstool/ # Output directory with ZIP artifact
Used in implementation code to link code to requirements:
import se.lfv.reqstool.annotations.Requirements;
@Requirements({"REQ-001", "REQ-002"})
public class MyClass {
// Implementation
}The reqstool-maven-plugin is configured in pom.xml:
<plugin>
<groupId>se.lfv.reqstool</groupId>
<artifactId>reqstool-maven-plugin</artifactId>
<version>1.0.3</version>
<executions>
<execution>
<goals>
<goal>assemble-and-attach-zip-artifact</goal>
</goals>
</execution>
</executions>
<configuration>
<datasetPath>${project.basedir}/docs/reqstool</datasetPath>
</configuration>
</plugin>Default configuration values:
-
requirementsAnnotationsFile:
target/generated-sources/annotations/resources/annotations.yml -
svcsAnnotationsFile:
target/generated-test-sources/test-annotations/resources/annotations.yml -
outputDirectory:
target/reqstool -
datasetPath:
reqstool/ -
testResults:
target/surefire-reports//.xml,target/failsafe-reports//.xml
The reqstool-gradle-plugin is configured in build.gradle:
buildscript {
repositories {
mavenLocal() // For local development
mavenCentral()
}
dependencies {
classpath 'se.lfv.reqstool:reqstool-gradle-plugin:0.1.0'
}
}
apply plugin: 'se.lfv.reqstool'
requirementsTool {
datasetPath = file('docs/reqstool')
}
// Wire the task into the build lifecycle
tasks.named('build') {
finalizedBy tasks.named('assembleRequirements')
}
tasks.named('assembleRequirements') {
dependsOn tasks.named('test')
}Default configuration values:
-
requirementsAnnotationsFile:
build/generated/sources/annotationProcessor/java/main/resources/annotations.yml -
svcsAnnotationsFile:
build/generated/sources/annotationProcessor/java/test/resources/annotations.yml -
outputDirectory:
build/reqstool/ -
datasetPath:
reqstool/ -
testResults:
build/test-results/*/.xml
The plugin generates:
-
Combined annotations (
target/reqstool/annotations.yml):requirement_annotations: implementations: com.reqstool.example.demo.DemoApplication: - REQ-001 tests: com.reqstool.example.demo.SVCsTest.testMethod1: - SVC_010
-
ZIP artifact (
target/reqstool/reqstool-demo-*-reqstool.zipfor Maven orbuild/reqstool/reqstool-demo-reqstool.zipfor Gradle):-
Contains all requirements data, annotations, and test results
-
Created with classifier
reqstooland extensionzip -
Published to Maven repositories alongside other project artifacts (JAR, sources, javadoc)
-
Can be processed by reqstool Python client
-
When you publish your project to a Maven repository (using mvn deploy or Gradle’s publish task), the reqstool ZIP artifact is automatically attached and published alongside your main artifacts:
-
reqstool-demo-0.0.4.jar- Main application JAR -
reqstool-demo-0.0.4-sources.jar- Source code (if configured) -
reqstool-demo-0.0.4-javadoc.jar- JavaDoc documentation (if configured) -
reqstool-demo-0.0.4-reqstool.zip- Requirements traceability artifact
The ZIP artifact uses the reqstool classifier, making it easy to identify and retrieve from Maven repositories. This allows teams to:
-
Track requirements traceability across releases
-
Automate compliance reporting in CI/CD pipelines
-
Share requirements data with stakeholders
-
Integrate with requirements management tools
# Deploy to Maven repository
mvn deploy
# Or with Gradle
gradle publishMIT License - see LICENSE file for details
