Checkstyle with Maven plugin has not expected failed checks

45 Views Asked by At

I have my_checkstyle.xml file. I assume it is based on Sun's checkstyle. It is located in separated module that is built together with other common modules for the project. I try to useit for the specific service module and run checkstyle plugins there.

What I have done:

  1. Added to pom.xml of checkstyle module, that consists of only pom.xml and my_checkstyle.xml files:
<build>
        <resources>
            <resource>
                <directory>${project.basedir}</directory>
                <includes>
                    <include>my_checkstyle.xml</include>
                </includes>
            </resource>
        </resources>
</build>

Then I have added to my common base module this:

<build>
...
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-checkstyle-plugin</artifactId>
  <version>3.3.1</version>
</plugin>
</build>
<reporting>
        <plugins>           
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>3.3.1</version>
                <configuration>
                    <configLocation>../checkstyle-config/my_checkstyle.xml</configLocation>
                </configuration>
            </plugin>
        </plugins>
    </reporting>
  1. Re-built my common project.
  2. Reloaded maven and rebuilt my service where I use common dependency module(second step seems to be not required). After that I dont have checkstyle plugin added in Maven plugins list.

I tried another way by adding checkstyle module as dependency to my service directly:

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>3.3.1</version>
                <dependencies>
                    <dependency>
                        <groupId>com.example</groupId>
                        <artifactId>checkstyle-config</artifactId>
                        <version>1.0-SNAPSHOT</version>
                    </dependency>
                </dependencies>
</plugin>
<reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>3.3.1</version>
                <configuration>
                    <configLocation>../../../common/checkstyle-config/my_checkstyle.xml</configLocation>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jxr-plugin</artifactId>
                <version>3.3.0</version>
            </plugin>
        </plugins>
    </reporting>

After just reloading Maven, I have got Checkstyle plugin. Main problem is - Checkstyle seems not reading my_checkstyle.xml. I have noticed that after commenting all checks in my_checkstyle.xml(and rebuild), it still fails on the same checks.

For example:

(javadoc) JavadocPackage: Missing package-info.java file.

(javadoc) MissingJavadocMethod: Missing a Javadoc comment.

(misc) FinalParameters: Parameter event should be final.

Also, for some reason checkstyle:checkstyle does nothing except Build Success messages, but checkstyle:check runs checks and I see the report. What did I wrong to run checkstyle correctly?

0

There are 0 best solutions below