+ /** MANIFEST headers. */
+ enum ManifestHeader {
+ // OSGi
+ /** OSGi bundle symbolic name. */
+ 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. */
+ IMPORT_PACKAGE("Import-Package"), //
+ /** OSGi path to embedded jar. */
+ BUNDLE_CLASSPATH("Bundle-Classpath"), //
+ // Java
+ /** 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
+ /**
+ * Maven coordinates of the origin, possibly partial when using common.bnd or
+ * merge.bnd.
+ */
+ ARGEO_ORIGIN_M2("Argeo-Origin-M2"), //
+ /** List of Maven coordinates to merge. */
+ ARGEO_ORIGIN_M2_MERGE("Argeo-Origin-M2-Merge"), //
+ /** Maven repository, if not the default one. */
+ ARGEO_ORIGIN_M2_REPO("Argeo-Origin-M2-Repo"), //
+ /**
+ * Do not perform BND analysis of the origin component. Typically Import_package
+ * and Export-Package will be kept untouched.
+ */
+ ARGEO_ORIGIN_NO_METADATA_GENERATION("Argeo-Origin-NoMetadataGeneration"), //
+// /**
+// * Embed the original jar without modifying it (may be required by some
+// * proprietary licenses, such as JCR Day License).
+// */
+// ARGEO_ORIGIN_EMBED("Argeo-Origin-Embed"), //
+ /**
+ * Do not modify original jar (may be required by some proprietary licenses,
+ * such as JCR Day License).
+ */
+ ARGEO_DO_NOT_MODIFY("Argeo-Origin-Do-Not-Modify"), //
+ /**
+ * Origin (non-Maven) URI of the component. It may be anything (jar, archive,
+ * etc.).
+ */
+ ARGEO_ORIGIN_URI("Argeo-Origin-URI"), //
+ /**
+ * Origin (non-Maven) URI of the source of the component. It may be anything
+ * (jar, archive, code repository, etc.).
+ */
+ ARGEO_ORIGIN_SOURCES_URI("Argeo-Origin-Sources-URI"), //
+ ;
+
+ final String headerName;
+
+ private ManifestHeader(String headerName) {
+ this.headerName = headerName;
+ }
+
+ @Override
+ public String toString() {
+ return headerName;
+ }
+
+ /** Get the value from either a {@link Manifest} or a {@link Properties}. */
+ String get(Object map) {
+ if (map instanceof Manifest manifest)
+ return manifest.getMainAttributes().getValue(headerName);
+ else if (map instanceof Properties props)
+ return props.getProperty(headerName);
+ else
+ throw new IllegalArgumentException("Unsupported mapping " + map.getClass());
+ }
+
+ /** Put the value into either a {@link Manifest} or a {@link Properties}. */
+ void put(Object map, String value) {
+ if (map instanceof Manifest manifest)
+ manifest.getMainAttributes().putValue(headerName, value);
+ else if (map instanceof Properties props)
+ props.setProperty(headerName, value);
+ else
+ throw new IllegalArgumentException("Unsupported mapping " + map.getClass());
+ }
+ }
+
+ /** Name of the file centralising information for multiple M2 artifacts. */
+ final static String COMMON_BND = "common.bnd";
+ /** Name of the file centralising information for mergin M2 artifacts. */
+ final static String MERGE_BND = "merge.bnd";
+ /**
+ * Subdirectory of the jar file where origin informations (changes, legal
+ * notices etc. are stored)
+ */
+ final static String ARGEO_ORIGIN = "ARGEO-ORIGIN";
+ /** File detailing modifications to the original component. */
+ final static String CHANGES = ARGEO_ORIGIN + "/changes";
+ /**
+ * Name of the file at the root of the repackaged jar, which prominently
+ * notifies that the component has be repackaged.
+ */
+ final static String README_REPACKAGED = "README.repackaged";
+
+ // cache
+ /** Summary of all license seen during the repackaging. */
+ final static Map<String, Set<String>> licensesUsed = new TreeMap<>();