diff --git a/biz.aQute.resolve/src/biz/aQute/resolve/RunResolution.java b/biz.aQute.resolve/src/biz/aQute/resolve/RunResolution.java index 2c80c45019..99c93bc85a 100644 --- a/biz.aQute.resolve/src/biz/aQute/resolve/RunResolution.java +++ b/biz.aQute.resolve/src/biz/aQute/resolve/RunResolution.java @@ -14,6 +14,8 @@ import java.util.function.Predicate; import java.util.stream.Collectors; +import aQute.bnd.header.Parameters; +import aQute.bnd.osgi.Instructions; import org.osgi.resource.Resource; import org.osgi.resource.Wire; import org.osgi.service.resolver.ResolutionException; @@ -194,6 +196,15 @@ public boolean updateBundles(BndEditModel model) { List newer = new ArrayList<>(nonNull(getRunBundles())); List older = new ArrayList<>(nonNull(model.getRunBundles())); + // Apply the -runbundles decorator on the computed RunBundles + Parameters bundles = HeaderClause.toParameters(newer); + Instructions decorator = new Instructions(project.mergeProperties(Constants.RUNBUNDLES_DECORATOR)); + decorator.decorate(bundles); + + newer = bundles.entrySet() + .stream().map(entry -> new VersionedClause(entry.getKey(), entry.getValue())) + .collect(Collectors.toList()); + if (newer.equals(older)) return false; diff --git a/biz.aQute.resolve/test/biz/aQute/resolve/RunResolutionTest.java b/biz.aQute.resolve/test/biz/aQute/resolve/RunResolutionTest.java index 47896c1b24..c091efd18d 100644 --- a/biz.aQute.resolve/test/biz/aQute/resolve/RunResolutionTest.java +++ b/biz.aQute.resolve/test/biz/aQute/resolve/RunResolutionTest.java @@ -14,6 +14,8 @@ import java.util.Set; import java.util.TreeMap; +import aQute.bnd.build.model.clauses.HeaderClause; +import aQute.bnd.build.model.conversions.NoopConverter; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -502,4 +504,25 @@ public void testPrintHumanReadableDifference() throws Exception { } + @Test + public void testStartLevelDecoration() throws Exception { + Bndrun bndrun = Bndrun.createBndrun(workspace, IO.getFile(ws.toFile(), "test.simple/resolve.bndrun")); + bndrun.setProperty("-runstartlevel", "order=leastdependenciesfirst,begin=100,step=10"); + + // Decorate test.simple to get startlevel 90 (which would otherwise be 110 within the assigned runstartlevel). + bndrun.setProperty("-runbundles+", "test.simple;startlevel=90"); + + List runBundles = List.copyOf(bndrun.resolve(false, false, new NoopConverter<>())); + + assertThat(runBundles).hasSize(2); + assertThat(runBundles.get(0) + .getName()).isEqualTo("osgi.enroute.junit.wrapper"); + assertThat(runBundles.get(0) + .getAttribs()).containsEntry(Constants.RUNBUNDLES_STARTLEVEL_ATTRIBUTE, "100"); + assertThat(runBundles.get(1) + .getName()).isEqualTo("test.simple"); + assertThat(runBundles.get(1) + .getAttribs()).containsEntry(Constants.RUNBUNDLES_STARTLEVEL_ATTRIBUTE, "90"); + } + }