vlsi / vlsi-release-plugins

A set of plugins to simplify Gradle release tasks
Apache License 2.0
41 stars 13 forks source link

[Discussion] Advice for using the license gather plugin in a multi-module project. #53

Open bric3 opened 2 years ago

bric3 commented 2 years ago

I'm working on a project that is split across sub-modules, some of these modules had plugins that adds dependencies (that are part of a platform).

I would like to report only the dependencies that I'm actually declaring (and of course their dependencies). However the setup indicates the task has to be configured for each modules (It'd be nice if the plugin could do this automatically).

Also, is there a way to merge the reports (metadata) ?

vlsi commented 2 years ago

Technically speaking, MetadataStore.load(folders: Iterable<File>) loads and merges multiple files. You could register VerifyLicenseCompatibilityTask task and configure VerifyLicenseCompatibilityTask.metadata file collection with several files, so the verification task should combine the information. Have you tried it?

However the setup indicates the task has to be configured for each modules

That sounds like a convention plugin to me.

In other words, something like

plugins {
  id("com.github.vlsi.license-gather.verify")
}

// registers verification tasks for common types of projects.
// For instance, in case of java-library, and java-application it could verify runtimeClasspath
// there might be an extension for handing known cases
// For example
licenseVerifications {
    allow(SpdxLicense.EPL_2_0) {
        // The message would be displayed, so the verification results are easier to understand
        because("ISSUE-23: EPL-2.0 is fine in our projects")
    }
    allow(new SimpleLicense("The W3C License", uri("http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/java-binding.zip"))) {
        because("ISSUE-42: John Smith decided the license is OK")
    }
    // License category
    // See https://www.apache.org/legal/resolved.html
    allow(AsfLicenseCategory.A) {
        because("The ASF category A is allowed")
    }
    reject(AsfLicenseCategory.X) {
        because("The ASF category X is forbidden")
    }
}

WDYT?

bric3 commented 2 years ago

Technically speaking, MetadataStore.load(folders: Iterable<File>) loads and merges multiple files. You could register VerifyLicenseCompatibilityTask task and configure VerifyLicenseCompatibilityTask.metadata file collection with several files, so the verification task should combine the information. Have you tried it?

I'll give it a try when I have access to my laptop.

However the setup indicates the task has to be configured for each modules

That sounds like a convention plugin to me.

That's indeed a possibility, but it requires to setup the project this way (with plugin conventions). But I saw some plugins that do most of this stuff automatically like io.cloudflight.license-gradle-plugin , which somehow pushed me to to discuss about multi-module.

vlsi commented 2 years ago

I mean I could release both com.github.vlsi.license-gather.base and com.github.vlsi.license-gather.verify plugins.