From 55dd8ce7a84806dad11324b7bf81dcaf4eb13e47 Mon Sep 17 00:00:00 2001 From: kaklakariada Date: Sat, 27 Jan 2024 16:02:18 +0100 Subject: [PATCH 1/6] Update dependencies --- .github/workflows/build.yml | 29 +++++------ .github/workflows/codeql-analysis.yml | 30 +++++------ .settings/org.eclipse.jdt.core.prefs | 1 + .vscode/settings.json | 13 +++++ README.md | 69 -------------------------- doc/developer_guide/developer_guide.md | 66 ++++++++++++++++++------ pom.xml | 51 +++++++++++++------ 7 files changed, 125 insertions(+), 134 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0f32df0..d6d655b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,9 +2,9 @@ name: Build on: push: - branches: [ master, develop ] + branches: [ main ] pull_request: - branches: [ master, develop ] + branches: [ main ] jobs: build: @@ -12,30 +12,25 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Fetch all history for all tags and branches - run: git fetch --prune --unshallow - - uses: actions/setup-java@v1 + - uses: actions/checkout@v4 with: - java-version: 11 - - name: Cache local Maven repository - uses: actions/cache@v2 + fetch-depth: 0 + - uses: actions/setup-java@v4 with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- + cache: maven + distribution: temurin + java-version: | + 11 + 17 + 21 - name: Build with Maven run: mvn --errors --batch-mode clean org.jacoco:jacoco-maven-plugin:prepare-agent install - env: - MAVEN_OPTS: "-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn" - name: Sonar if: ${{ env.SONAR_TOKEN != null }} - run: mvn --errors --batch-mode "-Dsonar.host.url=https://sonarcloud.io" -Dsonar.organization=itsallcode -Dsonar.login=$SONAR_TOKEN sonar:sonar + run: mvn --errors --batch-mode -Dsonar.token=$SONAR_TOKEN sonar:sonar env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - MAVEN_OPTS: "-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn" - name: Publish Test Report uses: scacap/action-surefire-report@v1 if: always() diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index a385c7c..2ab060c 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -2,11 +2,9 @@ name: "CodeQL" on: push: - branches: [develop, master] + branches: [main] pull_request: - branches: [develop, master] - schedule: - - cron: '0 4 * * 3' + branches: [main] jobs: analyze: @@ -18,27 +16,23 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - uses: actions/setup-java@v1 + - uses: actions/setup-java@v4 with: - java-version: 11 - - - name: Cache local Maven repository - uses: actions/cache@v2 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- + cache: maven + distribution: temurin + java-version: | + 11 + 17 - name: Initialize CodeQL - uses: github/codeql-action/init@v1 + uses: github/codeql-action/init@v3 with: languages: java - name: Autobuild - uses: github/codeql-action/autobuild@v1 + uses: github/codeql-action/autobuild@v3 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + uses: github/codeql-action/analyze@v3 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index b3c482a..fcbcd7a 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -22,6 +22,7 @@ org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.processAnnotations=disabled org.eclipse.jdt.core.compiler.release=disabled org.eclipse.jdt.core.compiler.source=11 org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..3800052 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,13 @@ +{ + "editor.formatOnSave": true, + "editor.formatOnSaveMode": "modifications", + "editor.codeActionsOnSave": { + "source.organizeImports": "explicit", + "source.generate.finalModifiers": "explicit", + "source.fixAll": "explicit" + }, + "java.saveActions.organizeImports": true, + "java.sources.organizeImports.starThreshold": 3, + "java.sources.organizeImports.staticStarThreshold": 3, + "java.configuration.updateBuildConfiguration": "automatic", +} \ No newline at end of file diff --git a/README.md b/README.md index 35e6303..e6cb066 100644 --- a/README.md +++ b/README.md @@ -62,72 +62,3 @@ The Hamcrest Multiline Text Matcher requires Java 11 to run. | [Maven Surefire Plugin](https://maven.apache.org/surefire/maven-surefire-plugin/) | Unit testing | Apache License 2.0 | | [OSS Index Maven Plugin](https://sonatype.github.io/ossindex-maven/maven-plugin/) | Checking Dependencies Vulnerability | ASL2 | | [Versions Maven Plugin](https://www.mojohaus.org/versions-maven-plugin/) | Checking if dependencies updates are available | Apache License 2.0 | - -## Development - - -### Generate / update license file header - -```bash -mvn license:update-file-header -``` - -## Run local sonar analysis - -```bash -mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar \ - -Dsonar.host.url=https://sonarcloud.io \ - -Dsonar.organization=itsallcode \ - -Dsonar.login=[token] -``` - -See analysis results at https://sonarcloud.io/dashboard?id=org.itsallcode%3Ahamcrest-mutliline-text-matcher - -## Check for updated dependencies / plugins - -```bash -mvn versions:display-dependency-updates -``` - -```bash -mvn versions:display-plugin-updates -``` - -### Publishing to JCenter - -1. Add the following to your `~/.m2/settings.xml`: - - ```xml - - - - ossrh - your-jira-id - your-jira-pwd - - - - - ossrh - - true - - - gpg - the_pass_phrase - - - - - ``` - -1. Checkout the `master` branch. -1. Update version in `pom.xml`, commit and push. -1. Run command - - ```bash - mvn -DskipSigningArtifacts=false clean deploy - ``` - -1. Create a [release](https://github.com/itsallcode/hamcrest-mutliline-text-matcher/releases) of the `master` branch on GitHub. -1. After some time the release will be available at [Maven Central](https://repo1.maven.org/maven2/org/itsallcode/hamcrest-mutliline-text-matcher/). diff --git a/doc/developer_guide/developer_guide.md b/doc/developer_guide/developer_guide.md index 018a906..f4e4fa0 100644 --- a/doc/developer_guide/developer_guide.md +++ b/doc/developer_guide/developer_guide.md @@ -1,29 +1,65 @@ # Developer Guide -## Publishing to JCenter +## Generate / update license file header + +```bash +mvn license:update-file-header +``` + +## Run local sonar analysis + +```bash +mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar \ + -Dsonar.token=[token] +``` + +See analysis results at https://sonarcloud.io/dashboard?id=org.itsallcode%3Ahamcrest-mutliline-text-matcher + +## Check for updated dependencies / plugins + +```bash +mvn versions:display-dependency-updates +``` + +```bash +mvn versions:display-plugin-updates +``` + +## Publishing to Maven Central 1. Add the following to your `~/.m2/settings.xml`: ```xml - - - bintray-maven-repo - [bintray-username] - [bintray-api-key] - - + + + + ossrh + your-jira-id + your-jira-pwd + + + + + ossrh + + true + + + gpg + the_pass_phrase + + + + ``` -1. Checkout the `master` branch. +1. Checkout the `main` branch. 1. Update version in `pom.xml`, commit and push. 1. Run command ```bash - mvn deploy + mvn -DskipSigningArtifacts=false clean deploy ``` -1. Create a [release](https://github.com/itsallcode/hamcrest-mutliline-text-matcher/releases) on GitHub. -1. Sign in at [bintray.com](https://bintray.com/login?forwardedFrom=%2Fitsallcode%2Fitsallcode%2Fhamcrest-mutliline-text-matcher) -1. Go to the [bintray project page](https://bintray.com/itsallcode/itsallcode/hamcrest-mutliline-text-matcher) -1. There should be a notice saying "You have 16 unpublished item(s) for this package". Click the "Publish" link. Binaries will be available for download at [jcenter](https://jcenter.bintray.com/org/itsallcode/hamcrest-mutliline-text-matcher/) -1. Publish to Maven Central by clicking the "Sync" button at [the project page](https://bintray.com/itsallcode/itsallcode/hamcrest-mutliline-text-matcher#central). After some time the new version will appear at [Maven Central](https://repo1.maven.org/maven2/org/itsallcode/hamcrest-mutliline-text-matcher/). +1. Create a [release](https://github.com/itsallcode/hamcrest-mutliline-text-matcher/releases) of the `main` branch on GitHub. +1. After some time the release will be available at [Maven Central](https://repo1.maven.org/maven2/org/itsallcode/hamcrest-mutliline-text-matcher/). diff --git a/pom.xml b/pom.xml index bd1cb98..275c0d2 100644 --- a/pom.xml +++ b/pom.xml @@ -10,12 +10,14 @@ UTF-8 11 true + https://sonarcloud.io + itsallcode org.junit.jupiter junit-jupiter - 5.7.0 + 5.10.1 test @@ -26,10 +28,29 @@ + + org.apache.maven.plugins + maven-toolchains-plugin + 3.1.0 + + + + toolchain + + + + + + + ${java.version} + + + + org.apache.maven.plugins maven-compiler-plugin - 3.8.1 + 3.12.1 ${java.version} ${java.version} @@ -38,7 +59,7 @@ org.codehaus.mojo license-maven-plugin - 2.0.0 + 2.4.0 false true @@ -73,17 +94,17 @@ org.apache.maven.plugins maven-jar-plugin - 3.2.0 + 3.3.0 org.apache.maven.plugins maven-surefire-plugin - 3.0.0-M5 + 3.2.5 org.apache.maven.plugins maven-source-plugin - 3.2.1 + 3.3.0 attach-sources @@ -96,7 +117,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.2.0 + 3.6.3 attach-javadocs @@ -117,7 +138,7 @@ org.jacoco jacoco-maven-plugin - 0.8.6 + 0.8.11 @@ -136,7 +157,7 @@ org.apache.maven.plugins maven-enforcer-plugin - 3.0.0-M3 + 3.4.1 enforce-maven @@ -146,7 +167,7 @@ - 3.5.4 + 3.6.3 @@ -156,7 +177,7 @@ org.codehaus.mojo versions-maven-plugin - 2.8.1 + 2.16.2 package @@ -170,7 +191,7 @@ org.sonatype.ossindex.maven ossindex-maven-plugin - 3.1.0 + 3.2.0 package @@ -183,7 +204,7 @@ org.apache.maven.plugins maven-gpg-plugin - 1.6 + 3.1.0 sign-artifacts @@ -200,12 +221,12 @@ org.apache.maven.plugins maven-deploy-plugin - 2.8.2 + 3.1.1 org.sonatype.plugins nexus-staging-maven-plugin - 1.6.8 + 1.6.13 true ossrh From 29788151f22ee6ac823385654939cbd5ed563ae5 Mon Sep 17 00:00:00 2001 From: kaklakariada Date: Sat, 27 Jan 2024 16:06:25 +0100 Subject: [PATCH 2/6] Configure build with other Java versions --- .github/workflows/build.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d6d655b..debd7be 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,9 +7,15 @@ on: branches: [ main ] jobs: - build: - + matrix-build: runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + java: [11, 17, 21] + concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-java-${{ matrix.java }} + cancel-in-progress: true steps: - uses: actions/checkout@v4 @@ -24,9 +30,9 @@ jobs: 17 21 - name: Build with Maven - run: mvn --errors --batch-mode clean org.jacoco:jacoco-maven-plugin:prepare-agent install + run: mvn --errors --batch-mode clean org.jacoco:jacoco-maven-plugin:prepare-agent install -Djava.version=${{ matrix.java }} - name: Sonar - if: ${{ env.SONAR_TOKEN != null }} + if: ${{ env.DEFAULT_JAVA == matrix.java && env.SONAR_TOKEN != null }} run: mvn --errors --batch-mode -Dsonar.token=$SONAR_TOKEN sonar:sonar env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 5193e769be8fb45775e821dce5a9f1eee2b932fc Mon Sep 17 00:00:00 2001 From: kaklakariada Date: Sat, 27 Jan 2024 16:08:46 +0100 Subject: [PATCH 3/6] Add default java version --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index debd7be..3dc9e71 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,6 +16,8 @@ jobs: concurrency: group: ${{ github.workflow }}-${{ github.ref }}-java-${{ matrix.java }} cancel-in-progress: true + env: + DEFAULT_JAVA: 11 steps: - uses: actions/checkout@v4 From 2c5cbb7af7e71181820d572436dc295f697d10af Mon Sep 17 00:00:00 2001 From: kaklakariada Date: Sat, 27 Jan 2024 16:13:15 +0100 Subject: [PATCH 4/6] Fix javadoc for Java 21 --- .github/workflows/build.yml | 2 +- pom.xml | 6 +++++- .../java/org/itsallcode/matcher/MultilineTextMatcher.java | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3dc9e71..081d507 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,7 +31,7 @@ jobs: 11 17 21 - - name: Build with Maven + - name: Build with Java ${{ matrix.java }} run: mvn --errors --batch-mode clean org.jacoco:jacoco-maven-plugin:prepare-agent install -Djava.version=${{ matrix.java }} - name: Sonar if: ${{ env.DEFAULT_JAVA == matrix.java && env.SONAR_TOKEN != null }} diff --git a/pom.xml b/pom.xml index 275c0d2..4dedae0 100644 --- a/pom.xml +++ b/pom.xml @@ -131,7 +131,11 @@ true true - false + true + false + + -html5 + ${java.version} diff --git a/src/main/java/org/itsallcode/matcher/MultilineTextMatcher.java b/src/main/java/org/itsallcode/matcher/MultilineTextMatcher.java index 6745ec2..f5e3f40 100644 --- a/src/main/java/org/itsallcode/matcher/MultilineTextMatcher.java +++ b/src/main/java/org/itsallcode/matcher/MultilineTextMatcher.java @@ -41,6 +41,11 @@ public class MultilineTextMatcher extends TypeSafeMatcher private static final String LINE_ENDING = "\\r\\n|\\r|\\n"; private final String originalText; + /** + * Create a new instance. + * + * @param originalText the original text + */ public MultilineTextMatcher(final String originalText) { this.originalText = originalText; From a2000dee47bb8f4eff70bcabdb522286a07c4a00 Mon Sep 17 00:00:00 2001 From: kaklakariada Date: Sat, 27 Jan 2024 16:14:10 +0100 Subject: [PATCH 5/6] Add default build --- .github/workflows/build.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 081d507..488b84c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -45,3 +45,10 @@ jobs: with: report_paths: '**/target/surefire-reports/TEST-*.xml' github_token: ${{ secrets.GITHUB_TOKEN }} + + + build: + needs: matrix-build + runs-on: ubuntu-latest + steps: + - run: echo "Build successful" From eda8ae81575d847927c05d2429fcab4c5948f234 Mon Sep 17 00:00:00 2001 From: kaklakariada Date: Sat, 27 Jan 2024 16:39:20 +0100 Subject: [PATCH 6/6] Add sonar binding --- .vscode/settings.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.vscode/settings.json b/.vscode/settings.json index 3800052..1c5a1c6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -10,4 +10,8 @@ "java.sources.organizeImports.starThreshold": 3, "java.sources.organizeImports.staticStarThreshold": 3, "java.configuration.updateBuildConfiguration": "automatic", + "sonarlint.connectedMode.project": { + "connectionId": "itsallcode", + "projectKey": "org.itsallcode:hamcrest-mutliline-text-matcher" + } } \ No newline at end of file