mathieucarbou / license-maven-plugin

Manage license headers in your source files

Home Page:https://oss.carbou.me/license-maven-plugin/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

v4.1 (as well as v4.0) wrongly identifies the header as SLASHSTAR instead of JAVADOC and fails the checking

sparkhi opened this issue · comments

Observed on one of our projects.

When using v3.0 of the plugin, everything was fine, however after moving to 4.1, the checks were failing on some of the headers. I have a feeling that it probably happens based on what is matched first

   JAVADOC_STYLE("/**", " * ", " */", "", null, "(\\s|\\t)*/\\*.*$", ".*\\*/(\\s|\\t)*$", false, true, false),
   SLASHSTAR_STYLE("/*", " * ", " */", "", null, "(\\s|\\t)*/\\*.*$", ".*\\*/(\\s|\\t)*$", false, true, false), 

Our headers are javadoc style but that's probably enough to match the SLASHSTAR_STYLE as well, when this happens, the comparison fails indicating an extra * in the first line of header.

Replicated on Ubuntu 20.04, Java 8

I experienced the same or similar issue in our project. Even after format the check check fails for every *.java file.
Another project did fine however for some reason with the exact same plugin configuration.
As a workaround I explicitly declared:

<mapping>
    <java>SLASHSTAR_STYLE</java>
</mapping>

There war a breaking change from v3 to v4. The license header in a java file should not be placed in some javadoc-style comments: it could trigger some javadoc validations.