jaredsburrows / gradle-license-plugin

Gradle plugin that provides a task to generate a HTML license report of your project.
https://central.sonatype.com/artifact/com.jaredsburrows/gradle-license-plugin
Apache License 2.0
413 stars 66 forks source link

Licenses of a single project are not sorted correctly #408

Closed monae closed 9 months ago

monae commented 9 months ago

On generating HTML report, the method sortedWith of list is called but its return value is discarded. Maybe this is a confusion with the non-const method sortWith. https://github.com/jaredsburrows/gradle-license-plugin/blob/0.9.4/gradle-license-plugin/src/main/kotlin/com/jaredsburrows/license/internal/report/HtmlReport.kt#L59

As a result, two projects with the same combination of licenses but in different order will not be grouped together.

<!-- .pom 1 -->
<licenses>
  <license>
    <name>Some license 1</name>
    <url>http://website-1.tld/</url>
    <distribution>repo</distribution>
  </license>
  <license>
    <name>Some license 2</name>
    <url>http://website-2.tld/</url>
    <distribution>repo</distribution>
  </license>
</licenses>
<!-- .pom 2 -->
<licenses>
  <license>
    <name>Some license 2</name>
    <url>http://website-2.tld/</url>
    <distribution>repo</distribution>
  </license>
  <license>
    <name>Some license 1</name>
    <url>http://website-1.tld/</url>
    <distribution>repo</distribution>
  </license>
</licenses>

Is it a bug? If so, I think the order of licenses on the report also needs to be sorted in some fixed way. https://github.com/jaredsburrows/gradle-license-plugin/blob/0.9.4/gradle-license-plugin/src/main/kotlin/com/jaredsburrows/license/internal/report/HtmlReport.kt#L140

jaredsburrows commented 9 months ago

Good idea. Feel free to submit a PR for this!