A2 variants supported
[lgpl/argeo-commons.git] / org.argeo.init / src / org / argeo / init / a2 / AbstractProvisioningSource.java
index f43a6162a26b3a303b66792d9d980a32551ef1da..0c3cefd014a915f7a02d0c5b8caf69c858a0b6e1 100644 (file)
@@ -122,6 +122,25 @@ public abstract class AbstractProvisioningSource implements ProvisioningSource {
 
        }
 
+       protected String[] readNameVersionFromModule(Path modulePath) {
+               Manifest manifest;
+               if (Files.isDirectory(modulePath)) {
+                       manifest = findManifest(modulePath);
+               } else {
+                       try (JarInputStream in = new JarInputStream(newInputStream(modulePath))) {
+                               manifest = in.getManifest();
+                       } catch (IOException e) {
+                               throw new A2Exception("Cannot read manifest from " + modulePath, e);
+                       }
+               }
+               String versionStr = manifest.getMainAttributes().getValue(Constants.BUNDLE_VERSION);
+               String symbolicName = manifest.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
+               int semiColIndex = symbolicName.indexOf(';');
+               if (semiColIndex >= 0)
+                       symbolicName = symbolicName.substring(0, semiColIndex);
+               return new String[] { symbolicName, versionStr };
+       }
+
        protected String readVersionFromModule(Path modulePath) {
                Manifest manifest;
                if (Files.isDirectory(modulePath)) {