ramverma | af74a62 | 2018-07-31 18:25:39 +0100 | [diff] [blame] | 1 | // |
| 2 | // ============LICENSE_START======================================================= |
| 3 | // Copyright (C) 2016-2018 Ericsson. All rights reserved. |
| 4 | // ================================================================================ |
| 5 | // This file is licensed under the CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE |
| 6 | // Full license text at https://creativecommons.org/licenses/by/4.0/legalcode |
| 7 | // |
| 8 | // SPDX-License-Identifier: CC-BY-4.0 |
| 9 | // ============LICENSE_END========================================================= |
| 10 | // |
| 11 | // @author Sven van der Meer (sven.van.der.meer@ericsson.com) |
| 12 | // |
| 13 | |
| 14 | == Configure Checkstyle (Maven) |
| 15 | |
| 16 | When using a custom style configuration with Checkstyle, the definition of that style must of course be available to Checkstyle. |
| 17 | In order not to have to distribute style files for checkstyle into all Maven modules, it is recommended that a special Maven module be built that contains the checkstyle style definition. |
| 18 | That module is then used as a dependency in the __POM__ for all other modules that wish to use that checkstyle style. |
| 19 | For a full explanation see link:https://maven.apache.org/plugins/maven-checkstyle-plugin/examples/multi-module-config.html[the explanation of Checkstyle multi-module configuration]. |
| 20 | |
| 21 | In Apex, the module `apex-model.build-tools` provides the Apex checkstyle style files as resources in `src/main/resources/checkstyle`. |
| 22 | This style is a slightly tweaked version of the standard Google checkstyle style that allows longer lines and has some other checks slightly relaxed. |
| 23 | Therefore, all modules that wish to use the Apex style must put the following build directive into their `pom.xml`. |
| 24 | |
| 25 | [source%nowrap,xml] |
| 26 | ---- |
| 27 | <plugin> |
| 28 | <groupId>org.apache.maven.plugins</groupId> |
| 29 | <artifactId>maven-checkstyle-plugin</artifactId> |
| 30 | <version>2.17</version> |
| 31 | <dependencies> |
| 32 | <dependency> |
| 33 | <groupId>org.onap.policy.apex.model</groupId> |
| 34 | <artifactId>apex-model.build-tools</artifactId> |
| 35 | <version>${project.version}</version> |
| 36 | </dependency> |
| 37 | </dependencies> |
| 38 | <configuration> |
| 39 | <configLocation>checkstyle/apex_style_checks.xml</configLocation> |
| 40 | <headerLocation>checkstyle/apex_header.txt</headerLocation> |
| 41 | </configuration> |
| 42 | </plugin> |
| 43 | ---- |
| 44 | |
| 45 | |