Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuration of sources when determining licenses #377

Draft
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

TheMrMilchmann
Copy link

Currently, Licensee prefers the URL of license POM entries to determine the correct SPDX entry. From what I understood, this decision was made based on practicality because the data suggested that it would lead to better results at the time. Though, technically, this is incorrect as the license name should usually be an SPDX identifier while the URL can be arbitrary. From my experience, this is the wrong default for projects, I am working on. I'm not the first person to express interest in matching by name and this has been brought up numerous times on the issue tracker and Slack before. In fact, this has even caused some projects to omit the license URL altogether.

To rectify this unfortunate default (without breaking compatibility for current users), I propose to make the sources used to determine the license configurable. This is an implementation of the behavior I initially described in #137 (comment):

I propose to expose an API that the build author may use to tune the strategy. Specifically, we can mimic the API for configuring metadata sources for repositories. This could look as follows (exact names and syntax are tbd):

licensee {
    licenseSources {       // 1
        licenseName()      // 2
        licenseUrl()       // 3
    }
}

We introduce a LicenseSources interface that may be used to configure the sources from which to infer license information. In the DSL, this is exposed under the licensee extension (1).
The interface defines several methods that may be used to enable certain sources of information. Initially, those would use be license name (2) and license URL (3), but additional sources could be added in the future without breaking configuration or introducing needless complexity.

licenseSources would be a regular function under the licensee extension and probably have the signature fun licenseSources(action: Action<LicenseSources>). If the function is not called, we resort to the current behavior as default.

As an added benefit, we could allow the build author to call licenseSources {} (without adding any sources) to indicate that all license mappings must be specified explicitly. However, I suggest deferring this decision and treating it as a configuration mistake for now.

I'm aware that documentation is missing and there is probably some more room for improvements but I'm reaching out now to check if there even is interest in merging this feature.

@TheMrMilchmann TheMrMilchmann marked this pull request as ready for review November 13, 2024 16:50
@TheMrMilchmann TheMrMilchmann marked this pull request as draft November 13, 2024 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant