fix(java): improve lz4 detection (#4642)

Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@surgut.co.uk>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Co-authored-by: Keith Zantow <kzantow@gmail.com>
This commit is contained in:
Dimitri John Ledkov 2026-02-27 19:38:05 +00:00 committed by GitHub
parent db76d85d51
commit 35278f3d3d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 1 deletions

View File

@ -302,7 +302,11 @@ func GetManifestFieldGroupIDs(manifest *pkg.JavaManifest, fields []string) (grou
} }
func cleanGroupID(groupID string) string { func cleanGroupID(groupID string) string {
return strings.TrimSpace(strings.Split(removeOSCIDirectives(groupID), "#")[0]) groupID = strings.TrimSpace(strings.Split(removeOSCIDirectives(groupID), "#")[0])
if replacement, ok := GroupIDCorrections[groupID]; ok {
return replacement
}
return groupID
} }
func removeOSCIDirectives(groupID string) string { func removeOSCIDirectives(groupID string) string {

View File

@ -1,5 +1,9 @@
package cpegenerate package cpegenerate
var GroupIDCorrections = map[string]string{
"org.lz4.java": "org.lz4",
}
var DefaultArtifactIDToGroupID = map[string]string{ var DefaultArtifactIDToGroupID = map[string]string{
"ant": "org.apache.ant", "ant": "org.apache.ant",
"ant-antlr": "org.apache.ant", "ant-antlr": "org.apache.ant",

View File

@ -183,6 +183,22 @@ func Test_groupIDsFromJavaPackage(t *testing.T) {
}, },
expects: []string{"io.jenkins-ci.plugin.thing"}, expects: []string{"io.jenkins-ci.plugin.thing"},
}, },
{
name: "groupId correction properly applied",
pkg: pkg.Package{
Metadata: pkg.JavaArchive{
Manifest: &pkg.JavaManifest{
Main: pkg.KeyValues{
{
Key: "Automatic-Module-Name",
Value: "org.lz4.java",
},
},
},
},
},
expects: []string{"org.lz4"},
},
{ {
name: "from main Extension-Name field", name: "from main Extension-Name field",
pkg: pkg.Package{ pkg: pkg.Package{