maven-checkstyle-plugin icon indicating copy to clipboard operation
maven-checkstyle-plugin copied to clipboard

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

Open shailpatels opened this issue 4 months ago • 1 comments

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.

shailpatels avatar Sep 30 '25 03:09 shailpatels