- Path tempJar = null;
- if (module.getLocator() instanceof Path && Files.isDirectory((Path) module.getLocator()))
- tempJar = toTempJar((Path) module.getLocator());
- Bundle bundle;
- try (InputStream in = newInputStream(tempJar != null ? tempJar : module.getLocator())) {
- bundle = bc.installBundle(module.getBranch().getCoordinates(), in);
+ Object locator = module.getLocator();
+ if (usingReference && locator instanceof Path locatorPath) {
+ String referenceUrl = "reference:file:" + locatorPath.toString();
+ Bundle bundle = bc.installBundle(referenceUrl);
+ return bundle;
+ } else {
+ Path locatorPath = (Path) locator;
+ Path pathToUse;
+ boolean isTemp = false;
+ if (locator instanceof Path && Files.isDirectory(locatorPath)) {
+ pathToUse = toTempJar(locatorPath);
+ isTemp = true;
+ } else {
+ pathToUse = locatorPath;
+ }
+ Bundle bundle;
+ try (InputStream in = newInputStream(pathToUse)) {
+ bundle = bc.installBundle(locatorPath.toAbsolutePath().toString(), in);
+ }
+
+ if (isTemp && pathToUse != null)
+ Files.deleteIfExists(pathToUse);
+ return bundle;