Skip to content

Commit

Permalink
Rework on fix for #6364 based on PR feedback.
Browse files Browse the repository at this point in the history
* Moved decoration between older/newer check to ensure that check also incorporates the decoration.
* Added JUnit test.

Signed-off-by: Arnoud Glimmerveen <[email protected]>
  • Loading branch information
glimmerveen committed Dec 19, 2024
1 parent 509d0e2 commit 5f42c87
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
20 changes: 10 additions & 10 deletions biz.aQute.resolve/src/biz/aQute/resolve/RunResolution.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,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 All @@ -210,16 +219,7 @@ public boolean updateBundles(BndEditModel model) {
newer = older;
}

// 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);

List<VersionedClause> decorated = bundles.entrySet()
.stream().map(entry -> new VersionedClause(entry.getKey(), entry.getValue()))
.toList();

model.setRunBundles(decorated);
model.setRunBundles(newer);

return true;
}
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");
}

}

0 comments on commit 5f42c87

Please sign in to comment.