Skip to content

Commit f84bd46

Browse files
Refactor README (#53)
* Improve README
1 parent 3cc7651 commit f84bd46

File tree

1 file changed

+112
-65
lines changed

1 file changed

+112
-65
lines changed

README.md

Lines changed: 112 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,38 @@
11
# java-common
22

3-
Reusable build configuration for BorderTech open source projects.
4-
53
## Status
64
[![Build Status](https://travis-ci.com/BorderTech/java-common.svg?branch=master)](https://travis-ci.com/BorderTech/java-common)
75
[![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)
86
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=bordertech-java-common&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=bordertech-java-common)
97
[![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)
108
[![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)
119

12-
## qa-parent
10+
## Content
11+
12+
- [What is java-common](#what-is-java-common)
13+
- [Why use java-common](#why-use-java-common)
14+
- [Getting started](#getting-started)
15+
- [Features](#features)
16+
- [Configuration](#configuration)
17+
- [Contributing](#contributing)
18+
19+
## What is java-common
20+
21+
Reusable build configuration and parent pom modules for BorderTech open source projects.
22+
23+
## Why use java-common
24+
25+
- Simplifies the steps to release your project to Maven Central
26+
- Enforce quality assurance and security checks on your project code
27+
28+
## Getting started
1329

14-
BorderTech java projects should generally use this as their parent POM.
30+
java-common provides two parent pom modules:
31+
32+
- [bordertech-parent](https://github.com/BorderTech/java-common/blob/master/pom.xml) is the top level pom that configures [maven release plugin](https://maven.apache.org/maven-release/maven-release-plugin/)
33+
- [qa-parent](https://github.com/BorderTech/java-common/blob/master/qa-parent/pom.xml) provides quality assurance and security checks
34+
35+
Projects should generally use qa-parent as their parent POM:
1536

1637
``` xml
1738
<project>
@@ -25,18 +46,48 @@ BorderTech java projects should generally use this as their parent POM.
2546
</project>
2647
```
2748

28-
It runs quality assurance checks on your java code using tools such as [Checkstyle](https://maven.apache.org/plugins/maven-checkstyle-plugin/checkstyle-mojo.html), [PMD](https://maven.apache.org/plugins/maven-pmd-plugin/) and [Spotbugs](https://spotbugs.github.io/spotbugs-maven-plugin/spotbugs-mojo.html).
29-
30-
By default qa checks do not run, you must enable them on a per-module basis or parent pom like so:
49+
By default qa checks do not run, you must enable them on a per-module basis or in your project parent pom:
3150

3251
``` xml
33-
<properties>
34-
<!-- Set bt.qa.skip to false to run QA checks. -->
52+
<property>
3553
<bt.qa.skip>false</bt.qa.skip>
36-
</properties>
54+
</property>
3755
```
3856

39-
Refer to qa-parent's [pom.xml](https://github.com/BorderTech/java-common/blob/master/qa-parent/pom.xml) for other project properties.
57+
### Releasing
58+
59+
If using maven release ensure the necessary POM sections are overriden - these are marked in the bordertech-parent pom, for example:
60+
61+
``` xml
62+
<!--
63+
Descendants SHOULD override the url.
64+
-->
65+
<url>https://github.com/bordertech/java-common/</url>
66+
```
67+
68+
Once you have configured your project and environment you can release to Maven Central.
69+
70+
The golden rule for releasing is ALWAYS do the release on a separate branch (it makes [backing out](https://github.com/BorderTech/java-common/wiki/Releasing#dealing-with-failure) much easier when problems arise).
71+
72+
Full documentation is available in the wiki under [Releasing](https://github.com/BorderTech/java-common/wiki/Releasing).
73+
74+
## Features
75+
76+
### bordertech-parent
77+
78+
This is the top-level pom.xml file.
79+
80+
It configures the [maven release plugin](https://maven.apache.org/maven-release/maven-release-plugin/index.html) for projects to release to Maven Central.
81+
82+
_Note that java projects should generally not consume this directly but instead should use qa-parent as a parent POM instead._
83+
84+
### qa-parent
85+
86+
The qa-parent runs quality assurance checks on your java code using tools such as:
87+
88+
- the [Checkstyle plugin](https://maven.apache.org/plugins/maven-checkstyle-plugin) to check the code style used by the developers
89+
- the [PMD plugin](https://maven.apache.org/plugins/maven-pmd-plugin) for source code analysis
90+
- the [Spotbugs plugin](https://spotbugs.github.io/spotbugs-maven-plugin) that looks for bugs in Java programs using bug patterns
4091

4192
The qa-parent also runs:
4293

@@ -46,17 +97,19 @@ The qa-parent also runs:
4697
- the [JaCoCo plugin](https://www.eclemma.org/jacoco/trunk/doc/maven.html) for code coverage reports
4798
- the [Surefire plugin](https://maven.apache.org/surefire/maven-surefire-plugin) for running unit tests
4899

49-
The qa-parent inherits all of the release functionality from bordertech-parent, discussed below.
100+
The qa-parent inherits all of the release functionality from bordertech-parent.
50101

51-
## bordertech-parent
102+
### build-tools
52103

53-
This is the top-level pom.xml file.
104+
This is primarily a shared resources module used by qa-parent and potentially other BorderTech maven modules.
54105

55-
It configures the maven release plugin for open source BorderTech projects to release to Maven Central.
106+
## Configuration
56107

57-
_Note that java projects should generally not consume this directly but instead should use qa-parent as a parent POM instead._
108+
### bordertech-parent config
58109

59-
Projects using this must ensure the necessary POM sections are overriden - these are marked in the bordertech-parent pom, for example:
110+
Refer to bordertech-parent's [pom.xml](https://github.com/BorderTech/java-common/blob/master/pom.xml) for all project properties.
111+
112+
Projects must ensure the necessary POM sections are overriden - these are marked in the bordertech-parent pom, for example:
60113

61114
``` xml
62115
<!--
@@ -65,56 +118,44 @@ Projects using this must ensure the necessary POM sections are overriden - these
65118
<url>https://github.com/bordertech/java-common/</url>
66119
```
67120

68-
Once you have configured your project and environment you can release to Maven Central. It may look a little something like the examples below.
69-
70-
### Releasing
121+
### qa-parent config
71122

72-
The golden rule is ALWAYS do the release on a separate branch (it makes [backing out](https://github.com/BorderTech/java-common/wiki/Releasing#dealing-with-failure) much easier when problems arise).
123+
Refer to qa-parent's [pom.xml](https://github.com/BorderTech/java-common/blob/master/qa-parent/pom.xml) for all project properties.
73124

74-
Full documentation is available in the wiki under [Releasing](https://github.com/BorderTech/java-common/wiki/Releasing).
75-
76-
## build-tools
77-
78-
This is primarily a shared resources module used by qa-parent and potentially other BorderTech maven modules.
125+
Refer to the plugins used by qa-parent for all override details:
79126

80-
## qa-parent overrides
81-
82-
### Plugins used in QA Parent
83-
84-
Refer to the plugins for all override details:
85-
86-
- [Checkstyle plugin](https://maven.apache.org/plugins/maven-checkstyle-plugin/checkstyle-mojo.html)
87-
- [PMD plugin](https://maven.apache.org/plugins/maven-pmd-plugin/)
88-
- [Spotbugs plugin](https://spotbugs.github.io/spotbugs-maven-plugin/spotbugs-mojo.html)
89-
- [OWASP plugin](https://jeremylong.github.io/DependencyCheck/dependency-check-maven/index.html)
90-
- [Enforcer plugin](https://maven.apache.org/enforcer/maven-enforcer-plugin/enforce-mojo.html)
127+
- [Checkstyle plugin](https://maven.apache.org/plugins/maven-checkstyle-plugin)
128+
- [PMD plugin](https://maven.apache.org/plugins/maven-pmd-plugin)
129+
- [Spotbugs plugin](https://spotbugs.github.io/spotbugs-maven-plugin)
130+
- [OWASP plugin](https://jeremylong.github.io/DependencyCheck/dependency-check-maven)
131+
- [Enforcer plugin](https://maven.apache.org/enforcer/maven-enforcer-plugin)
91132
- [Version checker plugin](https://www.mojohaus.org/versions-maven-plugin)
92133
- [JaCoCo plugin](https://www.eclemma.org/jacoco/trunk/doc/maven.html)
93134
- [Surefire plugin](https://maven.apache.org/surefire/maven-surefire-plugin)
94135

95-
### Enable Static Analysis
136+
#### Enable Static Analysis
96137

97-
By default qa checks do not run, you must enable them on a per-module basis or parent pom.
138+
By default qa checks (i.e. Checkstyle, PMD and Spotbugs) do not run, you must enable them on a per-module basis or the project parent pom:
98139

99140
``` xml
100141
<property>
101142
<bt.qa.skip>false</bt.qa.skip>
102143
</property>
103144
```
104145

105-
### Checkstyle
146+
#### Checkstyle
106147

107-
Refer to [Checkstyle plugin](https://maven.apache.org/plugins/maven-checkstyle-plugin/checkstyle-mojo.html) for all override details.
148+
Refer to [Checkstyle plugin](https://maven.apache.org/plugins/maven-checkstyle-plugin) for all override details.
108149

109-
#### Skip Checkstyle
150+
##### Skip Checkstyle
110151

111152
``` xml
112153
<property>
113154
<checkstyle.skip>true</checkstyle.skip>
114155
</property>
115156
```
116157

117-
#### Change or Add Checkstyle Rules
158+
##### Change or Add Checkstyle Rules
118159

119160
The checkstyle config defaults to `bordertech/bt-checkstyle.xml`. This config is based on `sun-checks.xml` provided by checkstyle.
120161

@@ -126,7 +167,7 @@ To add or change a checkstyle rule you are required to create your own [config.x
126167
</property>
127168
```
128169

129-
#### Ignore Checkstyle Rule
170+
##### Ignore Checkstyle Rule
130171

131172
Create a [suppression](http://checkstyle.sourceforge.net/config_filters.html) file add set the `checkstyle.suppressions.location` property.
132173

@@ -147,11 +188,11 @@ Example suppression file:-
147188
</suppressions>
148189
```
149190

150-
### PMD and CPD
191+
#### PMD and CPD
151192

152-
Refer to [PMD plugin](https://maven.apache.org/plugins/maven-pmd-plugin/) for all override details.
193+
Refer to [PMD plugin](https://maven.apache.org/plugins/maven-pmd-plugin) for all override details.
153194

154-
#### Skip PMD and CPD
195+
##### Skip PMD and CPD
155196

156197
``` xml
157198
<property>
@@ -160,7 +201,7 @@ Refer to [PMD plugin](https://maven.apache.org/plugins/maven-pmd-plugin/) for al
160201
</property>
161202
```
162203

163-
#### Change PMD Rule Set
204+
##### Change PMD Rule Set
164205

165206
The default rule set is `bordertech/bt-pmd-rules.xml`.
166207

@@ -172,7 +213,7 @@ You can override the default by creating your own custom [rule set](https://pmd.
172213
</property>
173214
```
174215

175-
#### Add extra PMD Rule set
216+
##### Add extra PMD Rule set
176217

177218
An extra [rule set](https://pmd.github.io/latest/pmd_userdocs_making_rulesets.html) can be added via the plugin `rulesets` configuration.
178219

@@ -189,7 +230,7 @@ An extra [rule set](https://pmd.github.io/latest/pmd_userdocs_making_rulesets.ht
189230
</plugin>
190231
```
191232

192-
#### Ignore PMD Rule
233+
##### Ignore PMD Rule
193234

194235
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.
195236

@@ -205,19 +246,19 @@ Example properties file:
205246
com.my.example.MyClass=LoggerIsNotStaticFinal
206247
```
207248

208-
### Spotbugs
249+
#### Spotbugs
209250

210-
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.
251+
Refer to [spotbugs plugin](https://spotbugs.github.io/spotbugs-maven-plugin) or [doco](https://spotbugs.readthedocs.io/en/latest/index.html) for all override details.
211252

212-
#### Skip spotbugs
253+
##### Skip spotbugs
213254

214255
``` xml
215256
<property>
216257
<spotbugs.skip>true</spotbugs.skip>
217258
</property>
218259
```
219260

220-
#### Ignore Spotbugs Rule
261+
##### Ignore Spotbugs Rule
221262

222263
Create a [filter](https://spotbugs.readthedocs.io/en/latest/filter.html) file and set `spotbugs.excludeFilterFile` property.
223264

@@ -240,19 +281,19 @@ Example filter file:-
240281
</FindBugsFilter>
241282
```
242283

243-
### OWASP
284+
#### OWASP
244285

245-
Refer to [OWASP plugin](https://jeremylong.github.io/DependencyCheck/dependency-check-maven/index.html) for all override details.
286+
Refer to [OWASP plugin](https://jeremylong.github.io/DependencyCheck/dependency-check-maven) for all override details.
246287

247-
#### Skip OWASP
288+
##### Skip OWASP
248289

249290
``` xml
250291
<property>
251292
<dependency-check.skip>true</dependency-check.skip>
252293
</property>
253294
```
254295

255-
#### Ignore OWASP Rule
296+
##### Ignore OWASP Rule
256297

257298
Create a [suppression](https://jeremylong.github.io/DependencyCheck/general/suppression.html) file add set the `suppression.file` property.
258299

@@ -262,7 +303,7 @@ Create a [suppression](https://jeremylong.github.io/DependencyCheck/general/supp
262303
</property>
263304
```
264305

265-
#### Using OWASP behind a Proxy
306+
##### Using OWASP behind a Proxy
266307

267308
If you are behind a Proxy then the OWASP plugin needs to be told which proxy to use. You can set the `mavenSettingsProxyId` property in your settings.xml to the appropriate PROXY-ID (which is usually defined in the same settings.xml).
268309

@@ -274,29 +315,31 @@ If you are behind a Proxy then the OWASP plugin needs to be told which proxy to
274315

275316
Updating the OWASP vulnerability database can also be blocked by the PROXY blocking HTTP HEAD requests. To work around this you will need a command line option: `-Ddownloader.quick.query.timestamp=false`
276317

277-
### Enforcer Plugin
318+
#### Enforcer Plugin
278319

279-
Refer to [enforcer plugin](https://maven.apache.org/enforcer/maven-enforcer-plugin/enforce-mojo.html) for all override details.
320+
Refer to [enforcer plugin](https://maven.apache.org/enforcer/maven-enforcer-plugin) for all override details.
280321

281-
#### Skip enforcer
322+
##### Skip enforcer
282323

283324
``` xml
284325
<property>
285326
<enforcer.skip>true</enforcer.skip>
286327
</property>
287328
```
288329

289-
#### Report issues but dont fail
330+
##### Report issues but dont fail
290331

291332
``` xml
292333
<property>
293334
<enforcer.fail>false</enforcer.fail>
294335
</property>
295336
```
296337

297-
### Build tools module for override artefacts
338+
#### Build tools module for override artefacts
298339

299-
If your project has multiple modules and you want to provide the same override/exclude files for all the submodules, then a good solution is to use a `build-tools` module similar to [java-common/build-tools](https://github.com/BorderTech/java-common/tree/master/build-tools). Define a `build-tools` submodule that holds the override/exclude files and then define the plugins you want to override in the project parent pom with the custom build-tools module as a dependency.
340+
If your project has multiple modules and you want to provide the same override/exclude files for all the submodules, then a good solution is to use a `build-tools` module similar to [java-common/build-tools](https://github.com/BorderTech/java-common/tree/master/build-tools).
341+
342+
Once you have created a build-tools submodule, define the plugins you want to override in the project parent pom with the custom build-tools module as a dependency.
300343

301344
``` xml
302345
<!-- Example of adding a custom build-tools module to spotbugs -->
@@ -313,3 +356,7 @@ If your project has multiple modules and you want to provide the same override/e
313356
</dependencies>
314357
</plugin>
315358
```
359+
360+
## Contributing
361+
362+
Refer to these guidelines for [Workflow](https://github.com/BorderTech/java-common/wiki/Workflow) and [Releasing](https://github.com/BorderTech/java-common/wiki/Releasing).

0 commit comments

Comments
 (0)