From 7d54a846967f9bc7986e1ed695fa48fd9c2d3f19 Mon Sep 17 00:00:00 2001 From: Andreas Hufler Date: Tue, 1 Oct 2024 11:14:55 +0200 Subject: [PATCH 1/2] move checkstyle config to maven package --- .github/workflows/maven-settings.xml | 33 ++++++++++++++ .github/workflows/publish.yml | 44 +++++++++++++++++++ .gitignore | 3 +- pom.xml | 19 ++++++++ .../resources/checkstyle-suppressions.xml | 0 .../main/resources/checkstyle.xml | 0 6 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/maven-settings.xml create mode 100644 .github/workflows/publish.yml create mode 100644 pom.xml rename checkstyle-suppressions.xml => src/main/resources/checkstyle-suppressions.xml (100%) rename checkstyle.xml => src/main/resources/checkstyle.xml (100%) diff --git a/.github/workflows/maven-settings.xml b/.github/workflows/maven-settings.xml new file mode 100644 index 0000000..df833df --- /dev/null +++ b/.github/workflows/maven-settings.xml @@ -0,0 +1,33 @@ + + + + github + + + + + github + + + central + https://repo1.maven.org/maven2 + + + github + https://maven.pkg.github.com/aboutbits/* + + + + + + + + github + ${env.GITHUB_USER_NAME} + ${env.GITHUB_ACCESS_TOKEN} + + + diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..ec9a169 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,44 @@ +name: Publish package to GitHub Packages +on: + workflow_dispatch: + inputs: + version: + description: "Version name to publish (eg: x.x.x)" + type: string + required: true + +jobs: + publish: + timeout-minutes: 15 + runs-on: ubuntu-22.04 + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v4 + + - uses: aboutbits/github-actions-java/setup@v3 + + - name: Set Version + run: sed -i 's|BUILD-SNAPSHOT|${{ github.event.inputs.version }}|g' pom.xml + + - name: Publish package + run: mvn -s $GITHUB_WORKSPACE/.github/workflows/maven-settings.xml --batch-mode deploy + env: + GITHUB_USER_NAME: ${{ github.actor }} + GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + tag: + timeout-minutes: 5 + runs-on: ubuntu-22.04 + needs: publish + steps: + - uses: actions/checkout@v4 + + - name: Tag Deployment + uses: aboutbits/github-actions-base/git-create-or-update-tag@v1 + with: + tag-name: ${{ github.event.inputs.version }} + user-name: 'AboutBits' + user-email: 'info@aboutbits.it' diff --git a/.gitignore b/.gitignore index 723ef36..ec376bb 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.idea \ No newline at end of file +.idea +target \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..473c72e --- /dev/null +++ b/pom.xml @@ -0,0 +1,19 @@ + + + 4.0.0 + + it.aboutbits + java-checkstyle-config + BUILD-SNAPSHOT + Checkstyle config for all JAVA projects. + jar + + + + github + GitHub Packages + https://maven.pkg.github.com/aboutbits/java-checkstyle-config + + + diff --git a/checkstyle-suppressions.xml b/src/main/resources/checkstyle-suppressions.xml similarity index 100% rename from checkstyle-suppressions.xml rename to src/main/resources/checkstyle-suppressions.xml diff --git a/checkstyle.xml b/src/main/resources/checkstyle.xml similarity index 100% rename from checkstyle.xml rename to src/main/resources/checkstyle.xml From 99011240094726fcc417ef7fe8afbb171a525334 Mon Sep 17 00:00:00 2001 From: Andreas Hufler Date: Tue, 1 Oct 2024 11:18:34 +0200 Subject: [PATCH 2/2] update readme --- readme.md | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/readme.md b/readme.md index 6eb9765..127fa4e 100644 --- a/readme.md +++ b/readme.md @@ -4,14 +4,6 @@ Checkstyle config for all JAVA projects. ## Usage -Add this repository as a submodule of your main project by creating a `.gitmodules` file: -``` -[submodule "checkstyle-config"] - path = checkstyle-config - url = https://github.com/aboutbits/java-checkstyle-config - branch = main -``` - Add the `maven-checkstyle-plugin` to your `pom.xml`: ```xml @@ -19,8 +11,8 @@ Add the `maven-checkstyle-plugin` to your `pom.xml`: maven-checkstyle-plugin 3.5.0 - checkstyle-config/checkstyle.xml - checkstyle-config/checkstyle-suppressions.xml + checkstyle.xml + checkstyle-suppressions.xml true true true @@ -41,21 +33,20 @@ Add the `maven-checkstyle-plugin` to your `pom.xml`: checkstyle 10.18.1 + + it.aboutbits + java-checkstyle-config + 1.0.0 + ``` -For use with github-actions, you will also have to tell `actions/checkout` to also recurse submodules: -```yaml -- uses: actions/checkout@v4 - with: - submodules: 'true' -``` - **Configure your IDE:** -Go to `Settings` then search for "checkstyle". -Add a new checkstyle configuration and select the `checkstyle-config/checkstyle.xml` file. -Set the property `org.checkstyle.sun.suppressionfilter.config` to `checkstyle-config/checkstyle-suppressions.xml` +First you need to run `mvn verify` once. +In your IDE go to `Settings` then search for "checkstyle". +Add a new checkstyle configuration and select the `target/checkstyle-checker.xml` file. +Set the property `org.checkstyle.sun.suppressionfilter.config` to `checkstyle-suppressions.xml` ## Information