File tree Expand file tree Collapse file tree 4 files changed +4
-9
lines changed
plugins/license-gather-plugin/src/main/kotlin/com/github/vlsi/gradle Expand file tree Collapse file tree 4 files changed +4
-9
lines changed Original file line number Diff line number Diff line change @@ -74,9 +74,7 @@ internal class LicenseCompatibilityInterpreter(
74
74
resolvedCases[licenseExpression]?.let { return it.asResolved(licenseExpression) }
75
75
76
76
// Expand the license (e.g. expand OR_LATER into OR ... OR)
77
- val e = licenseEquivalence.expand(licenseExpression)
78
-
79
- return when (e) {
77
+ return when (val e = licenseEquivalence.expand(licenseExpression)) {
80
78
is DisjunctionLicenseExpression ->
81
79
// A or X => A
82
80
e.unordered.takeIf { it.isNotEmpty() }?.map { eval(it) }?.reduce { a, b ->
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ class LicenseEquivalence(
55
55
}
56
56
}
57
57
val result = seq.toSet()
58
- return if ( result.isEmpty()) null else result
58
+ return result.ifEmpty { null }
59
59
}
60
60
61
61
fun expand (licenseExpression : LicenseExpression ): LicenseExpression {
Original file line number Diff line number Diff line change @@ -160,7 +160,7 @@ fun LicenseExpression.weight(): Int =
160
160
is JustLicense -> 1
161
161
is OrLaterLicense -> 2
162
162
is WithException -> license.weight() + 1
163
- is ConjunctionLicenseExpression -> licenses.map { it.weight() + 1 }.maxOrNull() ? : 1
164
- is DisjunctionLicenseExpression -> licenses.map { it.weight() + 1 }.maxOrNull() ? : 1
163
+ is ConjunctionLicenseExpression -> licenses.maxOfOrNull { it.weight() + 1 } ? : 1
164
+ is DisjunctionLicenseExpression -> licenses.maxOfOrNull { it.weight() + 1 } ? : 1
165
165
else -> TODO (" Unexpected expression: ${this ::class .simpleName} : $this " )
166
166
}
Original file line number Diff line number Diff line change @@ -22,11 +22,8 @@ import com.github.vlsi.gradle.license.api.License
22
22
import com.github.vlsi.gradle.license.api.LicenseEquivalence
23
23
import com.github.vlsi.gradle.license.api.LicenseExpression
24
24
import com.github.vlsi.gradle.license.api.LicenseExpressionSet
25
- import com.github.vlsi.gradle.license.api.LicenseExpressionSetOperation
26
25
import com.github.vlsi.gradle.license.api.SpdxLicense
27
26
import com.github.vlsi.gradle.license.api.SpdxLicenseException
28
- import com.github.vlsi.gradle.license.api.orLater
29
- import com.github.vlsi.gradle.license.api.with
30
27
31
28
/* *
32
29
* See https://apache.org/legal/resolved.html
You can’t perform that action at this time.
0 commit comments