You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
13
29
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:
15
36
16
37
```xml
17
38
<project>
@@ -25,18 +46,48 @@ BorderTech java projects should generally use this as their parent POM.
25
46
</project>
26
47
```
27
48
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:
31
50
32
51
```xml
33
-
<properties>
34
-
<!-- Set bt.qa.skip to false to run QA checks. -->
52
+
<property>
35
53
<bt.qa.skip>false</bt.qa.skip>
36
-
</properties>
54
+
</property>
37
55
```
38
56
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:
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
40
91
41
92
The qa-parent also runs:
42
93
@@ -46,17 +97,19 @@ The qa-parent also runs:
46
97
- the [JaCoCo plugin](https://www.eclemma.org/jacoco/trunk/doc/maven.html) for code coverage reports
47
98
- the [Surefire plugin](https://maven.apache.org/surefire/maven-surefire-plugin) for running unit tests
48
99
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.
50
101
51
-
##bordertech-parent
102
+
### build-tools
52
103
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.
54
105
55
-
It configures the maven release plugin for open source BorderTech projects to release to Maven Central.
106
+
## Configuration
56
107
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
58
109
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:
60
113
61
114
```xml
62
115
<!--
@@ -65,56 +118,44 @@ Projects using this must ensure the necessary POM sections are overriden - these
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
71
122
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.
73
124
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:
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:
98
139
99
140
```xml
100
141
<property>
101
142
<bt.qa.skip>false</bt.qa.skip>
102
143
</property>
103
144
```
104
145
105
-
### Checkstyle
146
+
####Checkstyle
106
147
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.
108
149
109
-
#### Skip Checkstyle
150
+
#####Skip Checkstyle
110
151
111
152
```xml
112
153
<property>
113
154
<checkstyle.skip>true</checkstyle.skip>
114
155
</property>
115
156
```
116
157
117
-
#### Change or Add Checkstyle Rules
158
+
#####Change or Add Checkstyle Rules
118
159
119
160
The checkstyle config defaults to `bordertech/bt-checkstyle.xml`. This config is based on `sun-checks.xml` provided by checkstyle.
120
161
@@ -126,7 +167,7 @@ To add or change a checkstyle rule you are required to create your own [config.x
126
167
</property>
127
168
```
128
169
129
-
#### Ignore Checkstyle Rule
170
+
#####Ignore Checkstyle Rule
130
171
131
172
Create a [suppression](http://checkstyle.sourceforge.net/config_filters.html) file add set the `checkstyle.suppressions.location` property.
132
173
@@ -147,11 +188,11 @@ Example suppression file:-
147
188
</suppressions>
148
189
```
149
190
150
-
### PMD and CPD
191
+
####PMD and CPD
151
192
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.
153
194
154
-
#### Skip PMD and CPD
195
+
#####Skip PMD and CPD
155
196
156
197
```xml
157
198
<property>
@@ -160,7 +201,7 @@ Refer to [PMD plugin](https://maven.apache.org/plugins/maven-pmd-plugin/) for al
160
201
</property>
161
202
```
162
203
163
-
#### Change PMD Rule Set
204
+
#####Change PMD Rule Set
164
205
165
206
The default rule set is `bordertech/bt-pmd-rules.xml`.
166
207
@@ -172,7 +213,7 @@ You can override the default by creating your own custom [rule set](https://pmd.
172
213
</property>
173
214
```
174
215
175
-
#### Add extra PMD Rule set
216
+
#####Add extra PMD Rule set
176
217
177
218
An extra [rule set](https://pmd.github.io/latest/pmd_userdocs_making_rulesets.html) can be added via the plugin `rulesets` configuration.
178
219
@@ -189,7 +230,7 @@ An extra [rule set](https://pmd.github.io/latest/pmd_userdocs_making_rulesets.ht
189
230
</plugin>
190
231
```
191
232
192
-
#### Ignore PMD Rule
233
+
#####Ignore PMD Rule
193
234
194
235
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.
195
236
@@ -205,19 +246,19 @@ Example properties file:
205
246
com.my.example.MyClass=LoggerIsNotStaticFinal
206
247
```
207
248
208
-
### Spotbugs
249
+
####Spotbugs
209
250
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.
211
252
212
-
#### Skip spotbugs
253
+
#####Skip spotbugs
213
254
214
255
```xml
215
256
<property>
216
257
<spotbugs.skip>true</spotbugs.skip>
217
258
</property>
218
259
```
219
260
220
-
#### Ignore Spotbugs Rule
261
+
#####Ignore Spotbugs Rule
221
262
222
263
Create a [filter](https://spotbugs.readthedocs.io/en/latest/filter.html) file and set `spotbugs.excludeFilterFile` property.
223
264
@@ -240,19 +281,19 @@ Example filter file:-
240
281
</FindBugsFilter>
241
282
```
242
283
243
-
### OWASP
284
+
####OWASP
244
285
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.
Create a [suppression](https://jeremylong.github.io/DependencyCheck/general/suppression.html) file add set the `suppression.file` property.
258
299
@@ -262,7 +303,7 @@ Create a [suppression](https://jeremylong.github.io/DependencyCheck/general/supp
262
303
</property>
263
304
```
264
305
265
-
#### Using OWASP behind a Proxy
306
+
#####Using OWASP behind a Proxy
266
307
267
308
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).
268
309
@@ -274,29 +315,31 @@ If you are behind a Proxy then the OWASP plugin needs to be told which proxy to
274
315
275
316
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`
276
317
277
-
### Enforcer Plugin
318
+
####Enforcer Plugin
278
319
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.
280
321
281
-
#### Skip enforcer
322
+
#####Skip enforcer
282
323
283
324
```xml
284
325
<property>
285
326
<enforcer.skip>true</enforcer.skip>
286
327
</property>
287
328
```
288
329
289
-
#### Report issues but dont fail
330
+
#####Report issues but dont fail
290
331
291
332
```xml
292
333
<property>
293
334
<enforcer.fail>false</enforcer.fail>
294
335
</property>
295
336
```
296
337
297
-
### Build tools module for override artefacts
338
+
####Build tools module for override artefacts
298
339
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.
300
343
301
344
```xml
302
345
<!-- 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
313
356
</dependencies>
314
357
</plugin>
315
358
```
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