Uploaded image for project: 'XWiki Commons'
  1. XWiki Commons
  2. XCOMMONS-3747

Fail the build on wrong import order

    XMLWordPrintable

Details

    • Unknown
    • N/A
    • N/A

    Description

      The XWiki Java code style documents an import order (java, javax, jakarta, org, com, anything else, then static imports, each group separated by a blank line and sorted alphabetically), and the IntelliJ IDEA and Eclipse settings we ship produce exactly that order, but nothing verifies it at build time.

      As a consequence:

      • A file whose imports are in the wrong order produces a spurious diff as soon as somebody with a properly configured IDE touches it.
      • The order has to be corrected by hand during reviews, both for contributions from non-committers and for code written by coding agents.

      Enable Checkstyle's ImportOrder check so that a wrong import order fails the build, for main sources (checkstyle.xml) as well as for test sources (checkstyle-test.xml).

      Note that this applies to every project inheriting the XWiki parent POM, including xwiki-contrib extensions.

      See the proposal on the forum.

      Attachments

        Activity

          People

            vmassol Vincent Massol
            vmassol Vincent Massol
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: