Home > Mobile >  failed to bypass maven checkstyle plugin
failed to bypass maven checkstyle plugin

Time:10-02

my project is consisted of two modules, one is common, the other let's call it X.

When using maven to "clean install" module X, it complained:

You have 50 Checkstyle violations. 

Looking into the pom.xml I didn't see any checkstyle maven plugin, but in the "common" module I did find it in "common"'s pom.xml:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-checkstyle-plugin</artifactId>
    <version>2.9.1</version>
</plugin>

Since module X depends on module "common", I updated common's checkstyle plugin in pom.xml like this:

<configuration>
  <skip>true</skip>
</configuration>

and rebuilt the common module before I ran the "clean install" on X module.

To play safe, I added one more setting on the mvn command when running X module:

mvn clean install -DskipTests -Dcheckstyle.skip

However, it looks that neitherthe change in "common"'s pom.xml w.rt checkstyle plugin nor the additional setting on mvn command had any effect on the running - it still complained the same.

Can anyone help? I am at my wit's end.

CodePudding user response:

I tried with, pluginManagment and it works fine. You need to add this in your parent pom file.

<pluginManagement> 
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <version>2.9.1</version>
            <configuration>
                <skip>true</skip>
            </configuration>
         </plugin>
    </plugins>
</pluginManagement>

CodePudding user response:

It turned out that there are two places in the pom.xml that involve checkstyle plugin: one is under the tag

<pluginManagement>

, in which I added:

<skip>true</skip>

However it's not sufficient (at least in my case), I found the checkstyle was also registered under:

<build><plugins> 

it looks like:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-checkstyle-plugin</artifactId>
    <dependencies>
        <dependency>
            <groupId>com.puppycrawl.tools</groupId>
            <artifactId>checkstyle</artifactId>
            <version>6.1.1</version>
        </dependency>
    </dependencies>
    <configuration> 
        <skip>true</skip>
        ....
    </configuration>
<plugin>

Now after I added skip being true to both places and rebuilt the project modules, the errors were gone.

  • Related