Maven Checkstyle: check, not working

I have been working on trying to get Checkstyle working in Maven in the Eclipse Indigo IDE for a while. Finally, I thought that I would ask for expert advice on this.

I am using Eclipse Indigo and trying to configure Checkstyle to run in Maven.

Below is a snippet of my pom.xml. Only checkstlye: checkstlye works and generates reports.

======

    <profile>
        <id>checkstyle-profile</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-checkstyle-plugin</artifactId>
                    <version>2.9.1</version>
                    <configuration>
                        <includeTestSourceDirectory>true</includeTestSourceDirectory>
                        <configLocation>${basedir}/src/main/resources/maven_checks.xml</configLocation>
                    </configuration>
                    <executions>
                        <execution>
                            <id>checkstyle-check</id>
                            <goals>
                                <goal>check</goal>
                            </goals>
                            <phase>compile</phase>  <!--  Default is "verify" -->
                            <configuration>
                                <violationSeverity>error</violationSeverity>
                                <maxAllowedViolations>7000</maxAllowedViolations>
                                <failOnViolation>true</failOnViolation>
                                <failsOnError>true</failsOnError>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>   
            </plugins>
        </build>
    </profile>

</profiles>

<reporting>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <version>2.9.1</version>
            <configuration>
                <configLocation>${basedir}/src/main/resources/maven_checks.xml</configLocation>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jxr-plugin</artifactId>
            <version>2.3</version>
        </plugin>
    </plugins>
</reporting>    

Some of the things that do not work:

  • configLocation for custom checkstlye is ignored and is always used by default to validate Sun.
  • checkstlye: check. . , checkstyle: check . org.apache.maven.plugins: maven-checkstyle-plugin: 2.9.1: check (default-cli) zzz-web: 5950 .
  • , Crossess 7000?
  • Checkstyle Java . , Java, , Java. , jxr .

.

.

+5
3

check maven checkstyle plugin compile. mvn compile , . mvn checkstyle:check . 1 2 .

mvn compile, failOnViolation failOnError, true. mvn compile , 7000.

+7

1.configLocation checkstlye Sun.

: >

<properties<checkstyle.config.location>properties/checkstyle.xml</checkstyle.config.location>  </properties>

POM.xml, checkstyle.this pom.xml.

<version>0.0.1-SNAPSHOT</version>
0

googe_checks.xml should be in your project where pom.xml is present. mvn checkstyle: check

<properties>
    <checkstyle.config.location>google_checks.xml</checkstyle.config.location>
    <checkstyle.violationSeverity>warning</checkstyle.violationSeverity>
    <checkstyle.consoleOutput>true</checkstyle.consoleOutput>
</properties>

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>3.0.0</version>
                <dependencies>
                    <dependency>
                        <groupId>com.puppycrawl.tools</groupId>
                        <artifactId>checkstyle</artifactId>
                        <version>8.8</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>validate</id>
                        <phase>validate</phase>`
                        <properties>
                            <checkstyle.config.location>google_checks.xml</checkstyle.config.location>
                            <checkstyle.violationSeverity>warning</checkstyle.violationSeverity>
                            <checkstyle.consoleOutput>true</checkstyle.consoleOutput>
                        </properties>

                        <build>
                            <pluginManagement>
                                <plugins>
                                    <plugin>
                                        <groupId>org.apache.maven.plugins</groupId>
                                        <artifactId>maven-checkstyle-plugin</artifactId>
                                        <version>3.0.0</version>
                                        <dependencies>
                                            <dependency>
                                                <groupId>com.puppycrawl.tools</groupId>
                                                <artifactId>checkstyle</artifactId>
                                                <version>8.8</version>
                                            </dependency>
                                        </dependencies>
                                        <executions>
                                            <execution>
                                                <id>validate</id>
                                                <phase>validate</phase>
                                                <goals>
                                                    <goal>check</goal>
                                                </goals>
                                            </execution>
                                        </executions>
                                    </plugin>
                                </plugins>
                            </pluginManagement>
                        </build>
                        </project>
                        `
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </pluginManagement>
</build>
</project>
0
source

All Articles