jk1/Gradle-License-Report

Allow to give URL or stream for bundle to `LicenseBundleNormalizer`

Vampire opened this issue · 1 comments

When building a convention plugin with an embedded normalizer bundle, it would be nice if you could give it as resource or stream to the LicenseBundleNormalizer constructor.
Currently, you can only give it a file.

Here a way to do it by customization using Kotlin:

class CustomLicenseBundleNormalizer : LicenseBundleNormalizer(null, false) {
    @Synchronized
    override fun init() {
        if (isInitialized) {
            return
        }

        super.init()

        val slurpResult = JsonSlurper()
            .setType(LAX)
            .parse(javaClass.getResource("license-normalizer-bundle.json"))
        mergeConfigIntoGlobalConfig(toConfig(slurpResult) as LicenseBundleNormalizerConfig)
    }
}