Checkstyle will make java code more readable & maintainable.
checkstyle-maven plugin configuration:
<build>
<plugins>
..................
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.5</version>
<inherited>true</inherited>
<configuration>
<!--to skip checkstyle validation set value as "true" -->
<skip>false</skip>
<consoleOutput>true</consoleOutput>
<logViolationsToConsole>true</logViolationsToConsole>
<!--want to make build fail, when checkstyle found validation error. set value as "true".-->
<failOnViolation>true</failOnViolation>
<violationSeverity>warning</violationSeverity>
<!-- sun_checks.xml is default checkstyle configuration from checkstyle. Can add/remove validations in this file. --> <configLocation>${basedir}/src/main/resources/sun_checks.xml</configLocation>
</configuration>
<!-- the below configuration will ask maven build to execute checkstyle goal -->
<!-- the below configuration will ask maven build to execute checkstyle goal -->
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
With above configuration build will fail if checkstyle found validation error.
Comments
Post a Comment