Skip to content

Commit 08ffe84

Browse files
Merge pull request #44 from BorderTech/overrides
Property overrides
2 parents 472c059 + 5802ee0 commit 08ffe84

File tree

6 files changed

+342
-125
lines changed

6 files changed

+342
-125
lines changed

.travis.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
1+
dist: trusty
2+
3+
cache:
4+
directories:
5+
- $HOME/.m2
6+
7+
addons:
8+
sonarcloud:
9+
organization: "bordertech-github"
10+
token:
11+
secure: $SONAR_TOKEN
12+
113
before_install:
214
- echo "MAVEN_OPTS='-Xmx512m -XX:MaxPermSize=128m'" > ~/.mavenrc
315
- mvn clean
416

517
language: Java
618
jdk:
7-
- oraclejdk8
19+
- oraclejdk8
820

921
## Travis installs the project with the following maven command:- "mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V"
1022
script:
11-
- mvn test
23+
- mvn package sonar:sonar -Dsonar.projectKey="bordertech-java-common"

README.md

Lines changed: 193 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
Reusable build configuration for for BorderTech open source projects.
44

55
## Status
6-
76
[![Build Status](https://travis-ci.com/BorderTech/java-common.svg?branch=master)](https://travis-ci.com/BorderTech/java-common)
7+
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=bordertech-java-common&metric=alert_status)](https://sonarcloud.io/dashboard?id=bordertech-java-common)
8+
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=bordertech-java-common&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=bordertech-java-common)
89
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/c7a2226acd574943af9ae966c54b05e6)](https://app.codacy.com/app/BorderTech/java-common?utm_source=github.com&utm_medium=referral&utm_content=BorderTech/java-common&utm_campaign=Badge_Grade_Dashboard)
910
[![Maven Central](https://img.shields.io/maven-central/v/com.github.bordertech.common/bordertech-parent.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.github.bordertech.common%22%20AND%20a:%22bordertech-parent%22)
1011

@@ -54,3 +55,194 @@ Full documentation is available in the wiki under [Releasing](https://github.com
5455
## build-tools
5556

5657
This is primarily a shared resources module used by qa-parent and potentially other BorderTech maven modules.
58+
59+
## qa-parent overrides
60+
61+
### Enable Static Analysis
62+
63+
By default qa checks do not run, you must enable them on a per-module basis.
64+
65+
``` xml
66+
<property>
67+
<bt.qa.skip>false</bt.qa.skip>
68+
</property>
69+
```
70+
71+
### Checkstyle
72+
73+
Refer to [Checkstyle plugin](https://maven.apache.org/plugins/maven-checkstyle-plugin/checkstyle-mojo.html) for all override details.
74+
75+
#### Skip Checkstyle
76+
77+
``` xml
78+
<property>
79+
<checkstyle.skip>true</checkstyle.skip>
80+
</property>
81+
```
82+
83+
#### Change or Add Checkstyle Rules
84+
85+
The checkstyle config defaults to `bordertech/bt-checkstyle.xml`. This config is based on `sun-checks.xml` provided by checkstyle.
86+
87+
To add or change a checkstyle rule you are required to create your own [config.xml](http://checkstyle.sourceforge.net/config.html) file and set the `checkstyle.config.location` property.
88+
89+
``` xml
90+
<property>
91+
<checkstyle.config.location>${basedir}/my-checkstyle-config.xml</checkstyle.config.location>
92+
</property>
93+
```
94+
95+
#### Ignore Checkstyle Rule
96+
97+
Create a [suppression](http://checkstyle.sourceforge.net/config_filters.html) file add set the `checkstyle.suppressions.location` property.
98+
99+
``` xml
100+
<property>
101+
<checkstyle.suppressions.location>${basedir}/my-suppression.xml</checkstyle.suppressions.location>
102+
</property>
103+
```
104+
105+
Example suppression file:-
106+
``` xml
107+
<?xml version="1.0"?>
108+
<!DOCTYPE suppressions PUBLIC "-//Puppy Crawl//DTD Suppressions 1.0//EN" "http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
109+
<suppressions>
110+
<!-- Ignores for all files -->
111+
<suppress checks="NPathComplexity" files="."/>
112+
</suppressions>
113+
```
114+
115+
### PMD and CPD
116+
117+
Refer to [PMD plugin](https://maven.apache.org/plugins/maven-pmd-plugin/) for all override details.
118+
119+
#### Skip PMD and CPD
120+
121+
``` xml
122+
<property>
123+
<pmd.skip>true</pmd.skip>
124+
<cpd.skip>true</cpd.skip>
125+
</property>
126+
```
127+
128+
#### Change PMD Rule Set
129+
130+
The default rule set is `bordertech/bt-pmd-rules.xml`.
131+
132+
You can override the default by creating your own custom [rule set](https://pmd.github.io/latest/pmd_userdocs_making_rulesets.html) and set the `bt.pmd.rules.file` property.
133+
134+
``` xml
135+
<property>
136+
<bt.pmd.rules.file>${basedir}/my-rules.xml</bt.pmd.rules.file>
137+
</property>
138+
```
139+
140+
#### Add extra PMD Rule set
141+
142+
An extra [rule set](https://pmd.github.io/latest/pmd_userdocs_making_rulesets.html) can be added via the plugin `rulesets` configuration.
143+
144+
``` xml
145+
<plugin>
146+
...
147+
<configuration>
148+
<rulesets>
149+
<ruleset>${bt.pmd.rules.file}</ruleset>
150+
<ruleset>${basedir}/my-rules.xml</ruleset>
151+
</rulesets>
152+
</configuration>
153+
...
154+
</plugin>
155+
```
156+
157+
#### Ignore PMD Rule
158+
159+
Create an [excludes](https://pmd.github.io/latest/pmd_userdocs_suppressing_warnings.html#xpath-and-regex-message-suppression) file that lists classes and rules to be excluded from failures and set the `pmd.excludeFromFailureFile` property.
160+
161+
``` xml
162+
<property>
163+
<pmd.excludeFromFailureFile>${basedir}/my-pmd-excludes.properties</pmd.excludeFromFailureFile>
164+
</property>
165+
```
166+
167+
Example properties file:
168+
169+
``` java
170+
com.my.example.MyClass=LoggerIsNotStaticFinal
171+
```
172+
173+
### Spotbugs
174+
175+
Refer to [spotbugs plugin](https://spotbugs.github.io/spotbugs-maven-plugin/spotbugs-mojo.html) or [doco](https://spotbugs.readthedocs.io/en/latest/index.html) for all override details.
176+
177+
#### Skip spotbugs
178+
179+
``` xml
180+
<property>
181+
<spotbugs.skip>true</spotbugs.skip>
182+
</property>
183+
```
184+
185+
#### Ignore Spotbugs Rule
186+
187+
Create a [filter](https://spotbugs.readthedocs.io/en/latest/filter.html) file and set `spotbugs.excludeFilterFile` property.
188+
189+
``` xml
190+
<property>
191+
<!-- List of exclude filter files -->
192+
<spotbugs.excludeFilterFile>${basedir}/my-spotbugs-exclude-file.xml</spotbugs.excludeFilterFile>
193+
</property>
194+
```
195+
196+
Example filter file:-
197+
198+
``` xml
199+
<?xml version="1.0" encoding="UTF-8"?>
200+
<FindBugsFilter>
201+
<!-- False Positive on Loading Property Filenames -->
202+
<Match>
203+
<Bug pattern="PATH_TRAVERSAL_IN" />
204+
</Match>
205+
</FindBugsFilter>
206+
```
207+
208+
### OWASP
209+
210+
Refer to [OWASP plugin](https://jeremylong.github.io/DependencyCheck/dependency-check-maven/index.html) for all override details.
211+
212+
#### Skip OWASP
213+
214+
``` xml
215+
<property>
216+
<dependency-check.skip>true</dependency-check.skip>
217+
</property>
218+
```
219+
220+
#### Ignore OWASP Rule
221+
222+
Create a [suppression](https://jeremylong.github.io/DependencyCheck/general/suppression.html) file add set the `suppression.file` property.
223+
224+
``` xml
225+
<property>
226+
<suppression.file>${basedir}/my-owasp-suppressions.xml</suppression.file>
227+
</property>
228+
```
229+
230+
### Enforcer Plugin
231+
232+
Refer to [enforcer plugin](https://maven.apache.org/enforcer/maven-enforcer-plugin/enforce-mojo.html) for all override details.
233+
234+
#### Skip enforcer
235+
236+
``` xml
237+
<property>
238+
<enforcer.skip>true</enforcer.skip>
239+
</property>
240+
```
241+
242+
#### Report issues but dont fail
243+
244+
``` xml
245+
<property>
246+
<enforcer.fail>false</enforcer.fail>
247+
</property>
248+
```

0 commit comments

Comments
 (0)