X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=src%2Forg%2Fargeo%2Fbuild%2FRepackage.java;h=3e87c864b860308dd01f7cf75e9d8cef633d43d9;hb=aa9ee858b9d39cf5be6ffec96cc6cf86c3430918;hp=8d48c2f9f6e2a47a128cc8222e4a7f07684944fe;hpb=fe6c61fa7630164e2d5160b19cf8d2ad6f93b7ab;p=cc0%2Fargeo-build.git diff --git a/src/org/argeo/build/Repackage.java b/src/org/argeo/build/Repackage.java index 8d48c2f..3e87c86 100644 --- a/src/org/argeo/build/Repackage.java +++ b/src/org/argeo/build/Repackage.java @@ -9,6 +9,7 @@ import static java.nio.file.FileVisitResult.CONTINUE; import static java.util.jar.Attributes.Name.MANIFEST_VERSION; import static org.argeo.build.Repackage.ManifestConstants.ARGEO_ORIGIN_M2; import static org.argeo.build.Repackage.ManifestConstants.ARGEO_ORIGIN_M2_REPO; +import static org.argeo.build.Repackage.ManifestConstants.BUNDLE_LICENSE; import static org.argeo.build.Repackage.ManifestConstants.BUNDLE_SYMBOLICNAME; import static org.argeo.build.Repackage.ManifestConstants.BUNDLE_VERSION; import static org.argeo.build.Repackage.ManifestConstants.ECLIPSE_SOURCE_BUNDLE; @@ -835,8 +836,8 @@ public class Repackage { String value = entries.get(key); String previousValue = manifest.getMainAttributes().getValue(key); boolean wasDifferent = previousValue != null && !previousValue.equals(value); + boolean keepPrevious = false; if (wasDifferent) { - boolean keepPrevious = false; if (SPDX_LICENSE_IDENTIFIER.toString().equals(key) && previousValue != null) keepPrevious = true; else if (BUNDLE_VERSION.toString().equals(key) && wasDifferent) @@ -852,7 +853,7 @@ public class Repackage { } manifest.getMainAttributes().putValue(key, value); - if (wasDifferent) { + if (wasDifferent && !keepPrevious) { if (IMPORT_PACKAGE.toString().equals(key) || EXPORT_PACKAGE.toString().equals(key)) logger.log(TRACE, () -> file.getFileName() + ": " + key + " was modified"); else @@ -866,6 +867,14 @@ public class Repackage { manifest.getMainAttributes().remove(key); } } + + // last checks + String spdxLicenceId = manifest.getMainAttributes().getValue(SPDX_LICENSE_IDENTIFIER.toString()); + String bundleLicense = manifest.getMainAttributes().getValue(BUNDLE_LICENSE.toString()); + if (spdxLicenceId == null) + logger.log(WARNING, file.getFileName() + ": " + SPDX_LICENSE_IDENTIFIER + " not available, " + + BUNDLE_LICENSE + " is " + bundleLicense); + try (OutputStream out = Files.newOutputStream(manifestPath)) { manifest.write(out); } @@ -1062,6 +1071,8 @@ public class Repackage { BUNDLE_SYMBOLICNAME("Bundle-SymbolicName"), // /** OSGi bundle version. */ BUNDLE_VERSION("Bundle-Version"), // + /** OSGi bundle license. */ + BUNDLE_LICENSE("Bundle-License"), // /** OSGi exported packages list. */ EXPORT_PACKAGE("Export-Package"), // /** OSGi imported packages list. */ @@ -1070,8 +1081,14 @@ public class Repackage { /** Java module name. */ AUTOMATIC_MODULE_NAME("Automatic-Module-Name"), // // Eclipse + /** Eclipse source bundle. */ ECLIPSE_SOURCE_BUNDLE("Eclipse-SourceBundle"), // // SPDX + /** + * SPDX license identifier. + * + * @see https://spdx.org/licenses/ + */ SPDX_LICENSE_IDENTIFIER("SPDX-License-Identifier"), // // Argeo Origin /**