Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/maven-settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">

<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>

<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
</repository>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/aboutbits/*</url>
</repository>
</repositories>
</profile>
</profiles>

<servers>
<server>
<id>github</id>
<username>${env.GITHUB_USER_NAME}</username>
<password>${env.GITHUB_ACCESS_TOKEN}</password>
</server>
</servers>
</settings>
44 changes: 44 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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|<version>BUILD-SNAPSHOT</version>|<version>${{ github.event.inputs.version }}</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'
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea
.idea
target
19 changes: 19 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>it.aboutbits</groupId>
<artifactId>java-checkstyle-config</artifactId>
<version>BUILD-SNAPSHOT</version>
<description>Checkstyle config for all JAVA projects.</description>
<packaging>jar</packaging>

<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/aboutbits/java-checkstyle-config</url>
</repository>
</distributionManagement>
</project>
31 changes: 11 additions & 20 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,15 @@ 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
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.5.0</version>
<configuration>
<configLocation>checkstyle-config/checkstyle.xml</configLocation>
<suppressionsLocation>checkstyle-config/checkstyle-suppressions.xml</suppressionsLocation>
<configLocation>checkstyle.xml</configLocation>
<suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
Expand All @@ -41,21 +33,20 @@ Add the `maven-checkstyle-plugin` to your `pom.xml`:
<artifactId>checkstyle</artifactId>
<version>10.18.1</version>
</dependency>
<dependency>
<groupId>it.aboutbits</groupId>
<artifactId>java-checkstyle-config</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</plugin>
```

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

Expand Down
File renamed without changes.