Skip to content

Commit

Permalink
#413: Load plugins from JAR files (#416)
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastian Bär <[email protected]>
  • Loading branch information
kaklakariada and redcatbear authored Aug 11, 2024
1 parent bf0b66d commit 159a20e
Show file tree
Hide file tree
Showing 54 changed files with 1,832 additions and 257 deletions.
13 changes: 13 additions & 0 deletions .github/ISSUE_TEMPLATE/New_plugin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
name: Add a new third-party plugin
about: Update OFT documentation to include a new third-party plugin

---

## Plugin Details

* Name:
* Description:
* Web page:
* Source code repository:
* Plugin type (importer, exporter or reporter):
8 changes: 4 additions & 4 deletions .github/workflows/broken_links_checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Broken Links Checker

on:
push:
branches: [ main ]
branches: [main]
pull_request:

jobs:
Expand All @@ -18,6 +18,6 @@ jobs:
echo '{ "aliveStatusCodes": [429, 200] }' > ./target/broken_links_checker.json
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
use-quiet-mode: 'yes'
use-verbose-mode: 'yes'
config-file: ./target/broken_links_checker.json
use-quiet-mode: "yes"
use-verbose-mode: "yes"
config-file: ./target/broken_links_checker.json
157 changes: 77 additions & 80 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ name: Build

on:
push:
branches: [ main ]
branches: [main]
pull_request:

jobs:
matrix-build:

permissions:
contents: read

strategy:
fail-fast: true
fail-fast: false
matrix:
java: [17]
os: [ubuntu-latest, macos-latest, windows-latest]
Expand All @@ -34,83 +33,81 @@ jobs:
DEFAULT_OS: ubuntu-latest

steps:

- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: |
17
21
cache: 'maven'

- name: Cache SonarQube packages
if: ${{ env.DEFAULT_OS == matrix.os && env.DEFAULT_JAVA == matrix.java }}
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Build with Java ${{ matrix.java }}
run: |
mvn --batch-mode -T 1C clean org.jacoco:jacoco-maven-plugin:prepare-agent install \
-Djava.version=${{ matrix.java }}
- name: Sonar analysis
if: ${{ env.DEFAULT_OS == matrix.os && env.DEFAULT_JAVA == matrix.java && env.SONAR_TOKEN != null }}
run: |
mvn --batch-mode org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
-Dsonar.token=$SONAR_TOKEN
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

- name: Verify reproducible build
# Build fails on Windows with error "Failed to execute goal org.apache.maven.plugins:maven-artifact-plugin:3.5.0:compare (default-cli) on project openfasttrace-reporter-plaintext: Could not copy D:\a\openfasttrace\openfasttrace\reporter\plaintext\target\openfasttrace-reporter-plaintext-3.8.0.buildcompareto D:\a\openfasttrace\openfasttrace\target\openfasttrace-root-0.0.0.buildcompare"
if: ${{ matrix.os != 'windows-latest' }}
run: |
mvn --batch-mode -T 1C clean verify artifact:compare -DskipTests \
-Djava.version=${{ matrix.java }}
- name: Archive aggregated reproducible build report
uses: actions/upload-artifact@v4
if: ${{ matrix.os != 'windows-latest' }}
with:
name: reproducible-build-report-${{ matrix.os }}-java-${{ matrix.java }}
path: |
target/openfasttrace-root-0.0.0.buildcompare
target/openfasttrace-root-0.0.0.buildinfo
if-no-files-found: error

- name: Archive oft binary
uses: actions/upload-artifact@v4
if: ${{ env.DEFAULT_OS == matrix.os && env.DEFAULT_JAVA == matrix.java }}
with:
name: openfasttrace-binaries
path: |
product/target/openfasttrace-*.jar
!product/target/openfasttrace-*-javadoc.jar
!product/target/openfasttrace-*-sources.jar
if-no-files-found: error

- name: Run self-trace
run: ./oft-self-trace.sh

- name: Upload self-tracing report
uses: actions/upload-artifact@v4
if: ${{ env.DEFAULT_OS == matrix.os && env.DEFAULT_JAVA == matrix.java }}
with:
name: self-tracing-report
path: target/self-trace-report.html
if-no-files-found: error

- name: Check shell scripts
if: ${{ env.DEFAULT_OS == matrix.os && env.DEFAULT_JAVA == matrix.java }}
run: .github/workflows/run_shellcheck.sh
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-java@v4
name: Set up Java ${{ matrix.java }}
with:
distribution: "temurin"
java-version: ${{ matrix.java }}
cache: "maven"

- name: Cache SonarQube packages
if: ${{ env.DEFAULT_OS == matrix.os && env.DEFAULT_JAVA == matrix.java }}
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Build with Java ${{ matrix.java }}
run: |
mvn --batch-mode -T 1C clean org.jacoco:jacoco-maven-plugin:prepare-agent install \
-Djava.version=${{ matrix.java }}
- name: Sonar analysis
if: ${{ env.DEFAULT_OS == matrix.os && env.DEFAULT_JAVA == matrix.java && env.SONAR_TOKEN != null }}
run: |
mvn --batch-mode org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
-Dsonar.token=$SONAR_TOKEN
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

- name: Verify reproducible build
# Build fails on Windows with error "Failed to execute goal org.apache.maven.plugins:maven-artifact-plugin:3.5.0:compare (default-cli) on project openfasttrace-reporter-plaintext: Could not copy D:\a\openfasttrace\openfasttrace\reporter\plaintext\target\openfasttrace-reporter-plaintext-3.8.0.buildcompareto D:\a\openfasttrace\openfasttrace\target\openfasttrace-root-0.0.0.buildcompare"
if: ${{ matrix.os != 'windows-latest' }}
run: |
mvn --batch-mode -T 1C clean verify artifact:compare -DskipTests \
-Djava.version=${{ matrix.java }}
- name: Archive aggregated reproducible build report
uses: actions/upload-artifact@v4
if: ${{ matrix.os != 'windows-latest' }}
with:
name: reproducible-build-report-${{ matrix.os }}-java-${{ matrix.java }}
path: |
target/openfasttrace-root-0.0.0.buildcompare
target/openfasttrace-root-0.0.0.buildinfo
if-no-files-found: error

- name: Archive oft binary
uses: actions/upload-artifact@v4
if: ${{ env.DEFAULT_OS == matrix.os && env.DEFAULT_JAVA == matrix.java }}
with:
name: openfasttrace-binaries
path: |
product/target/openfasttrace-*.jar
!product/target/openfasttrace-*-javadoc.jar
!product/target/openfasttrace-*-sources.jar
if-no-files-found: error

- name: Run self-trace
run: ./oft-self-trace.sh

- name: Upload self-tracing report
uses: actions/upload-artifact@v4
if: ${{ env.DEFAULT_OS == matrix.os && env.DEFAULT_JAVA == matrix.java }}
with:
name: self-tracing-report
path: target/self-trace-report.html
if-no-files-found: error

- name: Check shell scripts
if: ${{ env.DEFAULT_OS == matrix.os && env.DEFAULT_JAVA == matrix.java }}
run: .github/workflows/run_shellcheck.sh

build:
needs: matrix-build
Expand Down
36 changes: 18 additions & 18 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: "CodeQL"

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]
schedule:
- cron: '0 4 * * 3'
- cron: "0 4 * * 3"

jobs:
analyze:
Expand All @@ -21,22 +21,22 @@ jobs:
cancel-in-progress: true

steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4

- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
cache: 'maven'
- uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: 17
cache: "maven"

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: java
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: java

- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Autobuild
uses: github/codeql-action/autobuild@v3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
3 changes: 0 additions & 3 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ on:
push:
branches: ["main"]
workflow_dispatch:
# Temporarily also run on pull requests
pull_request:
branches: ["main"]

permissions:
contents: read
Expand Down
34 changes: 34 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Run Self-Trace",
"request": "launch",
"mainClass": "org.itsallcode.openfasttrace.core.cli.CliStarter",
"projectName": "openfasttrace",
"args": [
"trace",
"--log-level",
"INFO",
"${workspaceFolder}/doc/spec",
"${workspaceFolder}/importer/lightweightmarkup/src",
"${workspaceFolder}/importer/markdown/src",
"${workspaceFolder}/importer/restructuredtext/src",
"${workspaceFolder}/importer/specobject/src",
"${workspaceFolder}/importer/zip/src",
"${workspaceFolder}/importer/tag/src",
"${workspaceFolder}/core/src/main",
"${workspaceFolder}/core/src/test/java",
"${workspaceFolder}/reporter/plaintext/src",
"${workspaceFolder}/reporter/html/src",
"${workspaceFolder}/reporter/aspec/src",
"${workspaceFolder}/product/src/test/java",
"${workspaceFolder}/api/src",
"${workspaceFolder}/exporter/specobject/src",
"${workspaceFolder}/exporter/common/src",
"${workspaceFolder}/testutil/src"
]
}
]
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Sonarcloud status:
**User Guides**

* [📖 User Guide](doc/user_guide.md)
* [🔌 Extending OpenFastTrace With Plugins](doc/plugins.md)
* [💲 Command Line Usage](core/src/main/resources/usage.txt)

**News and Discussions**
Expand All @@ -47,6 +48,7 @@ Sonarcloud status:

* [🎟️ Project Board](https://github.com/orgs/itsallcode/projects/3/views/1)
* [🦮 Developer Guide](doc/developer_guide.md)
* [🔌 Plugin Developer Guide](doc/plugin_developer_guide.md)
* [🎁 Contributing Guide](CONTRIBUTING.md)
* [💡 System Requirements](doc/spec/system_requirements.md)
* [👜 Design](doc/spec/design.md)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public interface MultiFileImporter
MultiFileImporter importFile(InputFile file);

/**
* Import from the path, independently of whether it is represents a
* directory or a file.
* Import from the path, independently of whether it represents a directory
* or a file.
*
* @param paths
* lists of paths to files or directories
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
exports org.itsallcode.openfasttrace.core;
exports org.itsallcode.openfasttrace.core.cli;
exports org.itsallcode.openfasttrace.core.cli.commands;
exports org.itsallcode.openfasttrace.core.cli.logging;
exports org.itsallcode.openfasttrace.core.report;
exports org.itsallcode.openfasttrace.core.exporter;
exports org.itsallcode.openfasttrace.core.importer;
exports org.itsallcode.openfasttrace.core.serviceloader;

requires java.logging;
requires transitive java.logging;
requires transitive org.itsallcode.openfasttrace.api;

uses org.itsallcode.openfasttrace.api.exporter.ExporterFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.itsallcode.openfasttrace.core.importer.ImporterServiceImpl;
import org.itsallcode.openfasttrace.core.report.ReportService;
import org.itsallcode.openfasttrace.core.report.ReporterFactoryLoader;
import org.itsallcode.openfasttrace.core.serviceloader.InitializingServiceLoader;

class ServiceFactory
{
Expand All @@ -25,15 +24,12 @@ ExporterService createExporterService()
ImporterService createImporterService(final ImportSettings settings)
{
final ImporterContext context = new ImporterContext(settings);
final InitializingServiceLoader<ImporterFactory, ImporterContext> serviceLoader = InitializingServiceLoader
.load(ImporterFactory.class, context);
final ImporterService service = new ImporterServiceImpl(
new ImporterFactoryLoader(serviceLoader), settings);
final ImporterService service = new ImporterServiceImpl(new ImporterFactoryLoader(context), settings);
context.setImporterService(service);
return service;
}

Linker createLinker(List<SpecificationItem> items)
Linker createLinker(final List<SpecificationItem> items)
{
return new Linker(items);
}
Expand Down
Loading

0 comments on commit 159a20e

Please sign in to comment.