|
3 | 3 | Reusable build configuration for for BorderTech open source projects. |
4 | 4 |
|
5 | 5 | ## Status |
6 | | - |
7 | 6 | [](https://travis-ci.com/BorderTech/java-common) |
| 7 | +[](https://sonarcloud.io/dashboard?id=bordertech-java-common) |
| 8 | +[](https://sonarcloud.io/dashboard?id=bordertech-java-common) |
8 | 9 | [](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) |
9 | 10 | [](https://search.maven.org/search?q=g:%22com.github.bordertech.common%22%20AND%20a:%22bordertech-parent%22) |
10 | 11 |
|
@@ -54,3 +55,194 @@ Full documentation is available in the wiki under [Releasing](https://github.com |
54 | 55 | ## build-tools |
55 | 56 |
|
56 | 57 | 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