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 1 commit
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
13 changes: 12 additions & 1 deletion 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 @@ -208,7 +210,16 @@ public boolean updateBundles(BndEditModel model) {
newer = older;
}

model.setRunBundles(newer);
// Apply the -runbundles decorator on the computed RunBundles
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to change the check if the runbundles are identical before on line 197. The decoration might change the runbundles.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have moved the application of decoration above the older/newer check.

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

return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
invoker.goals=--no-transfer-progress package
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I am not too happy this testing takes place in the maven sub project. The functional change is in bnd so it should be tested in the normal bnd testing. The biz.aQute.resolve.RunResolutionTest in biz.aQute.resolve contains examples.

I know it is more comfortable to stay in your comfort zone but bnd is a shared project. If you change a function in bnd the test must take place as close as possible to the change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, I will look into adding test case(s) in RunResolutionTest. Do you want to retain these maven sub project test as well for this particular case, or just the tests within biz.aQute.resolve?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to test it once in bnd. I consider ANY error that would be detected in a 'driver' (maven, gradle, eclipse, intellij) an error of the highest severity. We rarely have them fortunately. And in this case, the functionality is clearly in bnd, not the driver.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I have removed the integration tests from the maven sub module.


# Run mvn with --debug for debug logging
#invoker.debug=true

# Run mvn in debugging mode and wait for a debugger to attach
#invoker.environmentVariables.MAVEN_DEBUG_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>biz.aQute.bnd-test</groupId>
<artifactId>resolver-test</artifactId>
<version>0.0.1</version>
<relativePath>../parent</relativePath>
</parent>

<artifactId>resolve-with-starlevel-and-runbundles-decorator</artifactId>
<version>0.0.1</version>
<packaging>pom</packaging>

<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.13</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.eventadmin</artifactId>
<version>1.4.8</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework</artifactId>
<version>5.4.0</version>
<scope>runtime</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-resolver-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import aQute.bnd.build.Workspace
import aQute.bnd.build.model.BndEditModel
import aQute.bnd.osgi.Processor
import aQute.bnd.properties.Document
import aQute.lib.io.IO;

// The resolve-with-starlevel-and-runbundles-decorator case

// Check the bndrun file exist!
File bndrunFile = new File(basedir, 'test.bndrun')
assert bndrunFile.isFile()

// Load the BndEditModel of the bndrun file so we can inspect the result
Processor processor = new Processor()
processor.setProperties(bndrunFile)
BndEditModel bem = new BndEditModel(Workspace.createStandaloneWorkspace(processor, bndrunFile.toURI()))
Document doc = new Document(IO.collect(bndrunFile))
bem.loadFrom(doc)

// Get the -runbundles.
def bemRunBundles = bem.getRunBundles()
assert bemRunBundles
assert bemRunBundles.size() == 4

StringBuilder sb = new StringBuilder()
bemRunBundles.get(0).formatTo(sb)
assert sb.toString() == "org.apache.felix.eventadmin;version='[1.4.8,1.4.9)';startlevel=1000"

sb = new StringBuilder()
bemRunBundles.get(1).formatTo(sb)
assert sb.toString() == "ch.qos.logback.core;version='[1.2.13,1.2.14)';startlevel=1001"

sb = new StringBuilder()
bemRunBundles.get(2).formatTo(sb)
assert sb.toString() == "ch.qos.logback.classic;version='[1.2.13,1.2.14)';startlevel=1002"

sb = new StringBuilder()
bemRunBundles.get(3).formatTo(sb)
assert sb.toString() == "slf4j.api;version='[1.7.36,1.7.37)';startlevel=999"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-runfw: org.apache.felix.framework
-runrequires: \
osgi.identity;filter:='(osgi.identity=org.apache.felix.eventadmin)',\
osgi.identity;filter:='(osgi.identity=slf4j.api)'

-runbundles+: slf4j.api; startlevel=999

-runstartlevel: \
order = leastdependenciesfirst, \
begin = 1000, \
step = 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
invoker.goals=--no-transfer-progress package

# Run mvn with --debug for debug logging
#invoker.debug=true

# Run mvn in debugging mode and wait for a debugger to attach
#invoker.environmentVariables.MAVEN_DEBUG_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>biz.aQute.bnd-test</groupId>
<artifactId>resolver-test</artifactId>
<version>0.0.1</version>
<relativePath>../parent</relativePath>
</parent>

<artifactId>resolve-with-starlevel</artifactId>
<version>0.0.1</version>
<packaging>pom</packaging>

<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.13</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.eventadmin</artifactId>
<version>1.4.8</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework</artifactId>
<version>5.4.0</version>
<scope>runtime</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-resolver-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import aQute.bnd.build.Workspace
import aQute.bnd.build.model.BndEditModel
import aQute.bnd.osgi.Processor
import aQute.bnd.properties.Document
import aQute.lib.io.IO;

// The resolve-with-starlevel case

// Check the bndrun file exist!
File bndrunFile = new File(basedir, 'test.bndrun')
assert bndrunFile.isFile()

// Load the BndEditModel of the bndrun file so we can inspect the result
Processor processor = new Processor()
processor.setProperties(bndrunFile)
BndEditModel bem = new BndEditModel(Workspace.createStandaloneWorkspace(processor, bndrunFile.toURI()))
Document doc = new Document(IO.collect(bndrunFile))
bem.loadFrom(doc)

// Get the -runbundles.
def bemRunBundles = bem.getRunBundles()
assert bemRunBundles
assert bemRunBundles.size() == 4

StringBuilder sb = new StringBuilder()
bemRunBundles.get(0).formatTo(sb)
assert sb.toString() == "org.apache.felix.eventadmin;version='[1.4.8,1.4.9)';startlevel=1000"

sb = new StringBuilder()
bemRunBundles.get(1).formatTo(sb)
assert sb.toString() == "ch.qos.logback.core;version='[1.2.13,1.2.14)';startlevel=1001"

sb = new StringBuilder()
bemRunBundles.get(2).formatTo(sb)
assert sb.toString() == "ch.qos.logback.classic;version='[1.2.13,1.2.14)';startlevel=1002"

sb = new StringBuilder()
bemRunBundles.get(3).formatTo(sb)
assert sb.toString() == "slf4j.api;version='[1.7.36,1.7.37)';startlevel=1003"
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-runfw: org.apache.felix.framework
-runrequires: \
osgi.identity;filter:='(osgi.identity=org.apache.felix.eventadmin)',\
osgi.identity;filter:='(osgi.identity=slf4j.api)'

-runstartlevel: \
order = leastdependenciesfirst, \
begin = 1000, \
step = 1
Loading