X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.init%2Fsrc%2Forg%2Fargeo%2Finit%2Fa2%2FFsA2Source.java;h=eb00659dcb4b7db84d381a1d5f86642a6c8d215f;hb=e25d219d5523f51f5acfcc79732b2da4638f0790;hp=949dbdf81dec07b0753b2009c753a2fc02c2564f;hpb=b7d8618ce593bbeca7e311d32a4d98988e27f877;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.init/src/org/argeo/init/a2/FsA2Source.java b/org.argeo.init/src/org/argeo/init/a2/FsA2Source.java index 949dbdf81..eb00659dc 100644 --- a/org.argeo.init/src/org/argeo/init/a2/FsA2Source.java +++ b/org.argeo.init/src/org/argeo/init/a2/FsA2Source.java @@ -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(