'lineWrappingIndentation' property in 'Indentation' module causes error

183 views
Skip to first unread message

Frank Kobzik

unread,
Mar 10, 2015, 6:34:43 AM3/10/15
to check...@googlegroups.com
Hi there,

I've got a problem with $subj$, maybe someone encountered this as well.
I use checkstyle via maven plugin, my pom contains this:

In dependencies element:
<dependency>
     <groupId>com.puppycrawl.tools</groupId>
     <artifactId>checkstyle</artifactId>
     <version>6.4.1</version>
</dependency>

In plugins element:
<plugin>
  <groupId>com.puppycrawl.tools</groupId>
  <artifactId>maven-checkstyle-plugin</artifactId>
  <version>6.4.1</version>
  <configuration>
    <configLocation>checkstyle.xml</configLocation>
    <encoding>UTF-8</encoding>
    <consoleOutput>true</consoleOutput>
    <failsOnError>true</failsOnError>
    <linkXRef>false</linkXRef>
  </configuration>
</plugin>


My checkstyle.xml looks like this:
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
    "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
    "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
    <module name="TreeWalker">
        <module name="Indentation">
            <property name="lineWrappingIndentation" value="8"/>
            <property name="basicOffset" value="4"/>
        </module>
    </module>
</module>


When I run checkstyle via maven: mvn clean checkstyle:checkstyle , I get the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.14:check (default-cli) on project saltstack-netapi-client-java: Failed during checkstyle configuration: cannot initialize module com.puppycrawl.tools.checkstyle.TreeWalker - Property 'lineWrappingIndentation' in module com.puppycrawl.tools.checkstyle.checks.indentation.Indentation does not exist, please check the documentation -> [Help 1]

I also used various prefixes to module names "com.puppycrawl....." to match the package hierarchy but with no sucess. I also decompiled the Indentation class bytecode to check if there is lineWrappingIndentation attribute and it's really there, so I don't know where the problem can be.

Thanks for any feedback!

Cheers,
Frank.

Frank Kobzik

unread,
Mar 10, 2015, 3:28:45 PM3/10/15
to check...@googlegroups.com
Ok, I've solved it now. If I only RTFM!

I had two problems in pom.xml:
1, There is no com.puppycrawl.tools maven-checkstyle-plugin
The plugin is org.apache.maven.plugins which makes use of checkstyle by puppycrawl!
Which brings us to the 2nd problem:
2, By default maven checkstyle plugin ver. 2.14 uses puppycrawl checkstyle 5.8, which doesn't have 'lineWrappingIndentation' attribute in Indentation class. Changing checkstyle version is simple as this:
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-checkstyle-plugin</artifactId>
<!-- plugin version is 2.14 -->
  <version>2.14</version>
  <dependencies>

    <dependency>
      <groupId>com.puppycrawl.tools</groupId>
      <artifactId>checkstyle</artifactId>
<!-- internal checkstyle is 6.4.1 -->
      <version>6.4.1</version>
    </dependency>
  </dependencies>

  <configuration>
    <configLocation>checkstyle.xml</configLocation>
    <encoding>UTF-8</encoding>
    <consoleOutput>true</consoleOutput>
    <failsOnError>true</failsOnError>
    <linkXRef>false</linkXRef>
  </configuration>
</plugin>


Sorry for a silly question, have a nice day!
F.

Roman Ivanov

unread,
Mar 10, 2015, 4:09:30 PM3/10/15
to Frank Kobzik, check...@googlegroups.com
Hi Frank,

Sorry for a silly question

It is ok, it is a reason of that mail-list, sorry that we did not found time to help you.

thanks,
Roman Ivanov

Frank Kobzik

unread,
Mar 11, 2015, 3:58:14 AM3/11/15
to check...@googlegroups.com, frantise...@gmail.com
No problem :)

Have a nice day.
F.
Reply all
Reply to author
Forward
0 new messages