Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply the -runbundles+ decorator on the computed RunBundles when resolving #6407

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions biz.aQute.resolve/src/biz/aQute/resolve/RunResolution.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -194,6 +196,15 @@ public boolean updateBundles(BndEditModel model) {
List<VersionedClause> newer = new ArrayList<>(nonNull(getRunBundles()));
List<VersionedClause> 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;

Expand Down
23 changes: 23 additions & 0 deletions biz.aQute.resolve/test/biz/aQute/resolve/RunResolutionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<? extends HeaderClause> 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");
}

}
Loading