avoid bundle.getLocation to be null and avoid to deploy twice the same bundle if it is in provided manifests (generated metadata and standard *-INF files)
diff --git a/winegrower-core/src/main/java/org/apache/winegrower/deployer/BundleImpl.java b/winegrower-core/src/main/java/org/apache/winegrower/deployer/BundleImpl.java
index 721109e..e1090cf 100644
--- a/winegrower-core/src/main/java/org/apache/winegrower/deployer/BundleImpl.java
+++ b/winegrower-core/src/main/java/org/apache/winegrower/deployer/BundleImpl.java
@@ -165,7 +165,7 @@
@Override
public String getLocation() {
- return includedResources != null ? null : file.getAbsolutePath();
+ return includedResources != null || file == null ? "" : file.getAbsolutePath();
}
@Override
diff --git a/winegrower-core/src/main/java/org/apache/winegrower/scanner/StandaloneScanner.java b/winegrower-core/src/main/java/org/apache/winegrower/scanner/StandaloneScanner.java
index 5eb650f..8505805 100644
--- a/winegrower-core/src/main/java/org/apache/winegrower/scanner/StandaloneScanner.java
+++ b/winegrower-core/src/main/java/org/apache/winegrower/scanner/StandaloneScanner.java
@@ -182,6 +182,7 @@
urls.stream()
.map(Files::toFile)
.filter(this::isIncluded)
+ .filter(file -> !providedManifests.containsKey(file.getName())) // don't duplicate it
.filter(it -> this.configuration.getIgnoredBundles().stream().noneMatch(ex -> it.getName().startsWith(ex)))
.map(this::toDefinition)
.filter(Objects::nonNull),
diff --git a/winegrower-core/src/test/java/org/apache/winegrower/deployer/BundleImplTest.java b/winegrower-core/src/test/java/org/apache/winegrower/deployer/BundleImplTest.java
index b5f9218..c14736b 100644
--- a/winegrower-core/src/test/java/org/apache/winegrower/deployer/BundleImplTest.java
+++ b/winegrower-core/src/test/java/org/apache/winegrower/deployer/BundleImplTest.java
@@ -41,20 +41,28 @@
class BundleImplTest {
private static BundleImpl bundle;
private static BundleRegistry registry;
+ private static Manifest manifest;
+ private static Ripener.Configuration configuration;
+ private static BundleContextImpl context;
@BeforeAll
static void initBundle() throws IOException {
- final Manifest manifest = new Manifest(new ByteArrayInputStream(("Manifest-Version: 1.0\nBundle-Version: 1.0\nBundle-SymbolicName: test\n").getBytes(StandardCharsets.UTF_8)));
- final Ripener.Configuration configuration = new Ripener.Configuration();
+ manifest = new Manifest(new ByteArrayInputStream(("Manifest-Version: 1.0\nBundle-Version: 1.0\nBundle-SymbolicName: test\n").getBytes(StandardCharsets.UTF_8)));
+ configuration = new Ripener.Configuration();
final OSGiServices services = new OSGiServices(new Ripener.Impl(configuration), new ArrayList<>(), new ArrayList<>());
registry = new BundleRegistry(services, configuration);
- final BundleContextImpl context = new BundleContextImpl(manifest, services, () -> bundle, registry);
+ context = new BundleContextImpl(manifest, services, () -> bundle, registry);
final File file = new File(registry.getFramework().getParentFile(), "test-classes");
bundle = new BundleImpl(manifest, file, context, configuration, 1, null);
registry.getBundles().put(bundle.getBundleId(), new OSGiBundleLifecycle(manifest, file, services, registry, configuration, 1, null));
}
@Test
+ void noEmptyLocation() {
+ assertNotNull(new BundleImpl(manifest, null, context, configuration, 1, null).getLocation());
+ }
+
+ @Test
void adaptBundleWiring() {
assertNotNull(bundle.adapt(BundleWiring.class));
}