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

licenseSets do not work properly

hazendaz opened this issue · comments

See https://github.com/hazendaz/base-parent/tree/license-issue

Run on that branch, 'mvn license:format'.

Results in warning that

[WARNING] Parameter 'legacyConfigHeader' (user property 'license.header') is deprecated: use {@link LicenseSet#header}

But I updated it to use licenseSets

Without the update, see the master branch and do same.

That one gives 2 expected warnings.

[WARNING] Parameter 'legacyConfigExcludes' (user property 'license.excludes') is deprecated: use {@link LicenseSet#excludes}
[WARNING] Parameter 'legacyConfigHeader' (user property 'license.header') is deprecated: use {@link LicenseSet#header}

Looked at IT tests in this project and they do not seem to have this issue. I cannot see anything different other than using all modern plugins from maven. So I think the issue is present due to resolution. Further, the injection points throughout this project are the same naming. So from just looking at it, I cannot see how maven would not have issue here. The legacy vs new should really be called something different IMO to avoid such conflicts.

@mathieucarbou Can you take a quick look at this and see if you see anything wrong? I've persisted on the legacy now since 2020 so nearly 3 years and want to upgrade as maven 3.9.0 is a lot more in our face about the warnings. I'm not sure what exactly is the cause other than I suspect naming the 'header' and 'excludes' the same results in them being injected in both places but only because I overload nearly everything to latest.

Maven used 3.9.0
Java used 17.0.6

Tested against 4.2.rc3 of this plugin.

If I look at the diff here (hazendaz/base-parent@master...license-issue), you juste added empty tags but didn't move the header related attributes like header and excludes inside.
Example from the doc:

  <configuration>
    <properties>
      <owner>Mycila</owner>
      <email>mathieu.carbou@gmail.com</email>
    </properties>
    <licenseSets>
      <licenseSet>
        <header>com/mycila/maven/plugin/license/templates/APACHE-2.txt</header>
        <excludes>
          <exclude>**/README</exclude>
          <exclude>src/test/resources/**</exclude>
          <exclude>src/main/resources/**</exclude>
        </excludes>
      </licenseSet>
    </licenseSets>
  </configuration>

I wrapped the existing header / excludes entirely. Diff shows that, am I missing something with that? I just didn't tab it in for sake of keeping diff reasonable.

Full section.

                        <licenseSets>
                        <licenseSet>
                        <header>${license.header}</header>
                        <excludes>
                            <!-- Default excludes located at https://github.com/mathieucarbou/license-maven-plugin/blob/master/license-maven-plugin/src/main/java/com/mycila/maven/plugin/license/Default.java -->
                            <!-- Exclude old license types I used in the past -->
                            <exclude>LICENSE.txt</exclude>
                            <exclude>LICENSE.TXT</exclude>
                            <exclude>license.txt</exclude>
                            <!-- Exclude special folder to ignore license -->
                            <exclude>**/unlicensed/**</exclude>
                        </excludes>
                        </licenseSet>
                        </licenseSets>

No, should be fine. That's weird... We should look at the effective pom i think

ok - I'll look more into that and also look at the ITs and possibly mimicking some of the changes I have in that base parent to see if I can figure out the root on this.

@mathieucarbou I resolved my issue, was very obscure but finally found it. I was using a profile that had property 'license.header' that then was used in the block of code I provided earlier. Reason for the code like that is that I used to have a different license header file name as 'license.txt' and migrated over to 'LICENSE_HEADER' and supported both for a period of time. I no longer have the old support so fixing was easy. I didn't realize that was then propagated entirely to the plugin so I just had to remove the property 'license.header' and add 'header' directly in the licenseSet.