Skip to content

Commit 65a53dc

Browse files
committed
Support jars with MANIFEST using Implementation-* convention
Fixes #1 partially. Jars without proper metadata embedded are not supported yet
1 parent 523bb88 commit 65a53dc

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

cmd/mendix-userlib-cleaner/main.go

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -156,28 +156,35 @@ func getJarProps(filePath string) JarProperties {
156156
return jar2
157157
}
158158
}
159-
log.Warningf("Failed to parse %v", filePath)
159+
log.Warningf("Failed to parse metadata from %v", filePath)
160160

161161
return JarProperties{filePath: ""}
162162
}
163163

164164
func parseManifest(filePath string, text string) JarProperties {
165165
lines := strings.Split(text, "\n")
166-
jarProp := JarProperties{filePath: filePath, packageName: "", fileName: filepath.Base(filePath)}
166+
jarProp := JarProperties{filePath: filePath, packageName: "", fileName: filepath.Base(filePath), version: ""}
167167
for _, line := range lines {
168168
line = strings.TrimSpace(line)
169169
pair := strings.Split(line, ": ")
170-
if pair[0] == "Bundle-SymbolicName" {
171-
jarProp.packageName = pair[1]
172-
} else if pair[0] == "Bundle-Version" {
173-
jarProp.version = pair[1]
170+
171+
if len(pair) < 2 {
172+
continue
173+
}
174+
175+
key := pair[0]
176+
value := pair[1]
177+
if key == "Bundle-SymbolicName" || key == "Extension-Name" {
178+
jarProp.packageName = value
179+
} else if key == "Bundle-Version" || key == "Implementation-Version" {
180+
jarProp.version = value
174181
jarProp.versionNumber = convertVersionToNumber(jarProp.version)
175-
} else if pair[0] == "Bundle-Vendor" {
176-
jarProp.vendor = pair[1]
177-
} else if pair[0] == "Bundle-License" {
178-
jarProp.license = pair[1]
179-
} else if pair[0] == "Bundle-Name" {
180-
jarProp.name = pair[1]
182+
} else if key == "Bundle-Vendor" || key == "Implementation-Vendor" {
183+
jarProp.vendor = value
184+
} else if key == "Bundle-License" {
185+
jarProp.license = value
186+
} else if key == "Bundle-Name" || key == "Implementation-Title" {
187+
jarProp.name = value
181188
}
182189
}
183190
return jarProp

0 commit comments

Comments
 (0)