Skip to content

Commit 065e7a2

Browse files
committed
add usage guide to readme
1 parent 8276219 commit 065e7a2

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

readme.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,61 @@
22

33
Checkstyle config for all JAVA projects.
44

5+
## Usage
6+
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+
15+
Add the `maven-checkstyle-plugin` to your `pom.xml`:
16+
```xml
17+
<plugin>
18+
<groupId>org.apache.maven.plugins</groupId>
19+
<artifactId>maven-checkstyle-plugin</artifactId>
20+
<version>3.5.0</version>
21+
<configuration>
22+
<configLocation>checkstyle-config/checkstyle.xml</configLocation>
23+
<suppressionsLocation>checkstyle-config/checkstyle-suppressions.xml</suppressionsLocation>
24+
<includeTestSourceDirectory>true</includeTestSourceDirectory>
25+
<consoleOutput>true</consoleOutput>
26+
<failsOnError>true</failsOnError>
27+
<linkXRef>false</linkXRef>
28+
</configuration>
29+
<executions>
30+
<execution>
31+
<id>validate</id>
32+
<phase>validate</phase>
33+
<goals>
34+
<goal>check</goal>
35+
</goals>
36+
</execution>
37+
</executions>
38+
<dependencies>
39+
<dependency>
40+
<groupId>com.puppycrawl.tools</groupId>
41+
<artifactId>checkstyle</artifactId>
42+
<version>10.18.1</version>
43+
</dependency>
44+
</dependencies>
45+
</plugin>
46+
```
47+
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+
55+
**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`
59+
560
## Information
661

762
About Bits is a company based in South Tyrol, Italy. You can find more information about us on [our website](https://aboutbits.it).

0 commit comments

Comments
 (0)