]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.init/src/org/argeo/init/a2/FsA2Source.java
Work on native compilation of SPNEGO client.
[lgpl/argeo-commons.git] / org.argeo.init / src / org / argeo / init / a2 / FsA2Source.java
index 949dbdf81dec07b0753b2009c753a2fc02c2564f..eb00659dcb4b7db84d381a1d5f86642a6c8d215f 100644 (file)
@@ -1,6 +1,8 @@
 package org.argeo.init.a2;
 
 import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.nio.file.DirectoryStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
@@ -16,7 +18,6 @@ public class FsA2Source extends AbstractProvisioningSource implements A2Source {
        private final Path base;
 
        public FsA2Source(Path base) {
-               super();
                this.base = base;
        }
 
@@ -43,27 +44,28 @@ public class FsA2Source extends AbstractProvisioningSource implements A2Source {
                                        String ext = moduleFileName.substring(lastDot + 1);
                                        if (!"jar".equals(ext))
                                                continue modules;
-                                       String moduleName = moduleFileName.substring(0, lastDot);
-                                       if (moduleName.endsWith("-SNAPSHOT"))
-                                               moduleName = moduleName.substring(0, moduleName.length() - "-SNAPSHOT".length());
-                                       int lastDash = moduleName.lastIndexOf('-');
-                                       String versionStr = moduleName.substring(lastDash + 1);
-                                       String componentName = moduleName.substring(0, lastDash);
+//                                     String moduleName = moduleFileName.substring(0, lastDot);
+//                                     if (moduleName.endsWith("-SNAPSHOT"))
+//                                             moduleName = moduleName.substring(0, moduleName.length() - "-SNAPSHOT".length());
+//                                     int lastDash = moduleName.lastIndexOf('-');
+//                                     String versionStr = moduleName.substring(lastDash + 1);
+//                                     String componentName = moduleName.substring(0, lastDash);
                                        // if(versionStr.endsWith("-SNAPSHOT")) {
                                        // versionStr = readVersionFromModule(modulePath);
                                        // }
                                        Version version;
-                                       try {
+//                                     try {
+//                                             version = new Version(versionStr);
+//                                     } catch (Exception e) {
+                                       String versionStr = readVersionFromModule(modulePath);
+                                       String componentName = readSymbolicNameFromModule(modulePath);
+                                       if (versionStr != null) {
                                                version = new Version(versionStr);
-                                       } catch (Exception e) {
-                                               versionStr = readVersionFromModule(modulePath);
-                                               if (versionStr != null) {
-                                                       version = new Version(versionStr);
-                                               } else {
-                                                       OsgiBootUtils.debug("Ignore " + modulePath + " (" + e.getMessage() + ")");
-                                                       continue modules;
-                                               }
+                                       } else {
+                                               OsgiBootUtils.debug("Ignore " + modulePath + " since version cannot be found");
+                                               continue modules;
                                        }
+//                                     }
                                        A2Component component = contribution.getOrAddComponent(componentName);
                                        A2Module module = component.getOrAddModule(version, modulePath);
                                        if (OsgiBootUtils.isDebug())
@@ -74,6 +76,20 @@ public class FsA2Source extends AbstractProvisioningSource implements A2Source {
 
        }
 
+       @Override
+       public URI getUri() {
+               URI baseUri = base.toUri();
+               try {
+                       if (baseUri.getScheme().equals("file")) {
+                               return new URI(SCHEME_A2, null, base.toString(), null);
+                       } else {
+                               throw new UnsupportedOperationException("Unsupported scheme " + baseUri.getScheme());
+                       }
+               } catch (URISyntaxException e) {
+                       throw new IllegalStateException("Cannot build URI from " + baseUri, e);
+               }
+       }
+
        public static void main(String[] args) {
                try {
                        FsA2Source context = new FsA2Source(Paths.get(