fix(java): preserve Eclipse Classpath license expressions (#5080)

* fix(java): preserve Eclipse Classpath license expressions

Signed-off-by: Eljees <yurytumanov.r@yandex.ru>

* chore: use tagged switch for quote handling in splitUnquoted

Signed-off-by: Eljees <3.14hell@gmail.com>

* Fix unquoted Apache license names in Java manifests

Recognize the FreeMarker Bundle-License name as Apache-2.0 while
preserving neighboring license clauses and parameters.

Assisted-by: OpenAI Codex
Signed-off-by: Eljees <3.14hell@gmail.com>

---------

Signed-off-by: Eljees <yurytumanov.r@yandex.ru>
Signed-off-by: Eljees <3.14hell@gmail.com>
This commit is contained in:
Yuriy Tumanov
2026-11-12 13:11:54 -05:00
committed by GitHub
parent a0c0d3890a
commit 2d8cc94c02
6 changed files with 372 additions and 4 deletions
+12
View File
@@ -14,8 +14,15 @@ import (
const (
LicenseRefPrefix = "LicenseRef-" // prefix for non-standard licenses
epl2LicenseID = "EPL-2.0"
)
var licenseExpressionsByURL = map[string]string{
"projects.eclipse.org/license/secondary-gpl-2.0-cp": "GPL-2.0-only WITH Classpath-exception-2.0",
"www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt": epl2LicenseID,
"www.gnu.org/software/classpath/license.html": "GPL-2.0-only WITH Classpath-exception-2.0",
}
//go:generate go run ./generate
// ID returns the canonical license ID for the given license ID
@@ -53,6 +60,11 @@ func LicenseByURL(url string) (LicenseInfo, bool) {
ID: id,
}, true
}
if expression, exists := licenseExpressionsByURL[url]; exists {
return LicenseInfo{
ID: expression,
}, true
}
if normalized, ok := normalizeOpenSourceOrgURL(url); ok {
if id, exists := openSourceOrgURLToLicense[normalized]; exists {
return LicenseInfo{
+18
View File
@@ -41,6 +41,24 @@ func TestLicenseByURL(t *testing.T) {
wantID: "BSD-3-Clause",
wantFound: true,
},
{
name: "GNU Classpath Exception URL",
url: "https://www.gnu.org/software/classpath/license.html",
wantID: "GPL-2.0-only WITH Classpath-exception-2.0",
wantFound: true,
},
{
name: "Eclipse secondary GPL Classpath URL",
url: "https://projects.eclipse.org/license/secondary-gpl-2.0-cp",
wantID: "GPL-2.0-only WITH Classpath-exception-2.0",
wantFound: true,
},
{
name: "Eclipse Public License legacy URL",
url: "https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt",
wantID: "EPL-2.0",
wantFound: true,
},
{
name: "URL with trailing whitespace",
url: " http://opensource.org/licenses/MIT ",