Skip to content

Maven checkstyle does not support comma seperated list for custom import order #633

@shailpatels

Description

@shailpatels

Affected version

3.6.1-SNAPSHOT

Bug description

The custom import order rule https://checkstyle.sourceforge.io/checks/imports/customimportorder.html has deprecated the ### as a delimiter for the order of packages in the custom import order.

A comma separated list can be passed but is not supported by maven checkstyle:

<module name="Checker">
  <module name="TreeWalker">
    <module name="CustomImportOrder">
      <property name="customImportOrderRules"
        value="STATIC, STANDARD_JAVA_PACKAGE, THIRD_PARTY_PACKAGE"/>
    </module>
  </module>
</module>

Fails with

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.20.0:site (default-site) on project MCHECKSTYLE-357: Error generating maven-checkstyle-plugin:3.6.1-SNAPSHOT:checkstyle report: Failed during checkstyle configuration: cannot initialize module TreeWalker - cannot initialize module CustomImportOrder - Cannot set property 'customImportOrderRules' to 'STATIC, STANDARD_JAVA_PACKAGE, THIRD_PARTY_PACKAGE': InvocationTargetException: Unexpected rule: STATIC, STANDARD_JAVA_PACKAGE, THIRD_PARTY_PACKAGE -> [Help 1]

For a minimal example you can edit src/it/MCHECKSTYLE-357/pom.xml to use the new syntax and then run it with
mvn invoker:run -Dinvoker.test=MCHECKSTYLE-357 to see the above error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions