Skip to content

Commit fb52280

Browse files
authored
Merge pull request #1 from aboutbits/ab-291-extract-checkstyle-config-in-its-own-package
Ab 291 extract checkstyle config in its own package
2 parents 065e7a2 + 9901124 commit fb52280

7 files changed

Lines changed: 109 additions & 21 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
4+
http://maven.apache.org/xsd/settings-1.0.0.xsd">
5+
6+
<activeProfiles>
7+
<activeProfile>github</activeProfile>
8+
</activeProfiles>
9+
10+
<profiles>
11+
<profile>
12+
<id>github</id>
13+
<repositories>
14+
<repository>
15+
<id>central</id>
16+
<url>https://repo1.maven.org/maven2</url>
17+
</repository>
18+
<repository>
19+
<id>github</id>
20+
<url>https://maven.pkg.github.com/aboutbits/*</url>
21+
</repository>
22+
</repositories>
23+
</profile>
24+
</profiles>
25+
26+
<servers>
27+
<server>
28+
<id>github</id>
29+
<username>${env.GITHUB_USER_NAME}</username>
30+
<password>${env.GITHUB_ACCESS_TOKEN}</password>
31+
</server>
32+
</servers>
33+
</settings>

.github/workflows/publish.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Publish package to GitHub Packages
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
version:
6+
description: "Version name to publish (eg: x.x.x)"
7+
type: string
8+
required: true
9+
10+
jobs:
11+
publish:
12+
timeout-minutes: 15
13+
runs-on: ubuntu-22.04
14+
permissions:
15+
contents: read
16+
packages: write
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- uses: aboutbits/github-actions-java/setup@v3
22+
23+
- name: Set Version
24+
run: sed -i 's|<version>BUILD-SNAPSHOT</version>|<version>${{ github.event.inputs.version }}</version>|g' pom.xml
25+
26+
- name: Publish package
27+
run: mvn -s $GITHUB_WORKSPACE/.github/workflows/maven-settings.xml --batch-mode deploy
28+
env:
29+
GITHUB_USER_NAME: ${{ github.actor }}
30+
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
32+
tag:
33+
timeout-minutes: 5
34+
runs-on: ubuntu-22.04
35+
needs: publish
36+
steps:
37+
- uses: actions/checkout@v4
38+
39+
- name: Tag Deployment
40+
uses: aboutbits/github-actions-base/git-create-or-update-tag@v1
41+
with:
42+
tag-name: ${{ github.event.inputs.version }}
43+
user-name: 'AboutBits'
44+
user-email: 'info@aboutbits.it'

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
.idea
1+
.idea
2+
target

pom.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>it.aboutbits</groupId>
7+
<artifactId>java-checkstyle-config</artifactId>
8+
<version>BUILD-SNAPSHOT</version>
9+
<description>Checkstyle config for all JAVA projects.</description>
10+
<packaging>jar</packaging>
11+
12+
<distributionManagement>
13+
<repository>
14+
<id>github</id>
15+
<name>GitHub Packages</name>
16+
<url>https://maven.pkg.github.com/aboutbits/java-checkstyle-config</url>
17+
</repository>
18+
</distributionManagement>
19+
</project>

readme.md

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,15 @@ Checkstyle config for all JAVA projects.
44

55
## Usage
66

7-
Add this repository as a submodule of your main project by creating a `.gitmodules` file:
8-
```
9-
[submodule "checkstyle-config"]
10-
path = checkstyle-config
11-
url = https://github.com/aboutbits/java-checkstyle-config
12-
branch = main
13-
```
14-
157
Add the `maven-checkstyle-plugin` to your `pom.xml`:
168
```xml
179
<plugin>
1810
<groupId>org.apache.maven.plugins</groupId>
1911
<artifactId>maven-checkstyle-plugin</artifactId>
2012
<version>3.5.0</version>
2113
<configuration>
22-
<configLocation>checkstyle-config/checkstyle.xml</configLocation>
23-
<suppressionsLocation>checkstyle-config/checkstyle-suppressions.xml</suppressionsLocation>
14+
<configLocation>checkstyle.xml</configLocation>
15+
<suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation>
2416
<includeTestSourceDirectory>true</includeTestSourceDirectory>
2517
<consoleOutput>true</consoleOutput>
2618
<failsOnError>true</failsOnError>
@@ -41,21 +33,20 @@ Add the `maven-checkstyle-plugin` to your `pom.xml`:
4133
<artifactId>checkstyle</artifactId>
4234
<version>10.18.1</version>
4335
</dependency>
36+
<dependency>
37+
<groupId>it.aboutbits</groupId>
38+
<artifactId>java-checkstyle-config</artifactId>
39+
<version>1.0.0</version>
40+
</dependency>
4441
</dependencies>
4542
</plugin>
4643
```
4744

48-
For use with github-actions, you will also have to tell `actions/checkout` to also recurse submodules:
49-
```yaml
50-
- uses: actions/checkout@v4
51-
with:
52-
submodules: 'true'
53-
```
54-
5545
**Configure your IDE:**
56-
Go to `Settings` then search for "checkstyle".
57-
Add a new checkstyle configuration and select the `checkstyle-config/checkstyle.xml` file.
58-
Set the property `org.checkstyle.sun.suppressionfilter.config` to `checkstyle-config/checkstyle-suppressions.xml`
46+
First you need to run `mvn verify` once.
47+
In your IDE go to `Settings` then search for "checkstyle".
48+
Add a new checkstyle configuration and select the `target/checkstyle-checker.xml` file.
49+
Set the property `org.checkstyle.sun.suppressionfilter.config` to `checkstyle-suppressions.xml`
5950

6051
## Information
6152

File renamed without changes.

0 commit comments

Comments
 (0)