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;
private final Path base;
public FsA2Source(Path base) {
- super();
this.base = base;
}
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())
}
+ @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(