@@ -23,7 +23,6 @@ import com.github.vlsi.gradle.license.api.License
23
23
import com.github.vlsi.gradle.license.api.LicenseExpression
24
24
import com.github.vlsi.gradle.license.api.LicenseExpressionParser
25
25
import com.github.vlsi.gradle.license.api.OsgiBundleLicenseParser
26
- import com.github.vlsi.gradle.license.api.ParseException
27
26
import com.github.vlsi.gradle.license.api.SpdxLicense
28
27
import com.github.vlsi.gradle.license.api.asExpression
29
28
import com.github.vlsi.gradle.license.api.text
@@ -329,9 +328,15 @@ open class GatherLicenseTask @Inject constructor(
329
328
spdxPredictor
330
329
workerExecutor.await()
331
330
331
+ val licenseNormalizer =
332
+ GuessBasedNormalizer (logger, similarityThreshold.get().toDouble())
333
+
332
334
if (predictor != null ) {
333
335
findManifestLicenses(allDependencies, licenseExpressionParser)
334
- findPomLicenses(allDependencies)
336
+ findPomLicenses(
337
+ allDependencies,
338
+ licenseNormalizer
339
+ )
335
340
findLicenseFromFiles(allDependencies, predictor)
336
341
}
337
342
@@ -341,6 +346,11 @@ open class GatherLicenseTask @Inject constructor(
341
346
val metadata = mutableMapOf<ModuleComponentIdentifier , LicenseInfo >()
342
347
343
348
val licenseTextCache = mutableMapOf<SpdxLicense , String >()
349
+
350
+ val ignoreMissingLicenseFor = ignoreMissingLicenseFor.get().map {
351
+ licenseNormalizer.normalize(it)
352
+ }
353
+
344
354
for ((id, licenseInfo) in allDependencies) {
345
355
if (licenseInfo.license == null ) {
346
356
missingLicenseId.add(id)
@@ -349,7 +359,7 @@ open class GatherLicenseTask @Inject constructor(
349
359
if (licenseFiles != null && ! licenseFiles.containsLicenseFile()) {
350
360
// Add default license text if needed
351
361
val licenseExpression = licenseInfo.license
352
- if (licenseExpression != null && licenseExpression in ignoreMissingLicenseFor.get() ) {
362
+ if (licenseExpression != null && licenseExpression in ignoreMissingLicenseFor) {
353
363
logger.debug(
354
364
" No LICENSE file detected for component ${id.displayName} " +
355
365
" however licenseid $licenseExpression is included in ignoreMissingLicenseFor set." +
@@ -521,7 +531,8 @@ open class GatherLicenseTask @Inject constructor(
521
531
operator fun GPathResult.get (name : String ) = getProperty(name) as GPathResult
522
532
523
533
private fun findPomLicenses (
524
- detectedLicenses : MutableMap <ComponentIdentifier , LicenseInfo >
534
+ detectedLicenses : MutableMap <ComponentIdentifier , LicenseInfo >,
535
+ licenseNormalizer : GuessBasedNormalizer
525
536
) {
526
537
val compIds =
527
538
detectedLicenses
@@ -533,9 +544,7 @@ open class GatherLicenseTask @Inject constructor(
533
544
return
534
545
}
535
546
536
- val normalizer = GuessBasedNormalizer (logger, similarityThreshold.get().toDouble())
537
-
538
- val licenses = loadLicenses(compIds, project, licenseOverrides, normalizer)
547
+ val licenses = loadLicenses(compIds, project, licenseOverrides, licenseNormalizer)
539
548
val failures = mutableListOf<Throwable >()
540
549
for ((id, licenseResult) in compIds.zip(licenses)) {
541
550
if (licenseResult.isFailure) {
0 commit comments