Skip to content

Commit

Permalink
Consider the version string when adding bnd requirements
Browse files Browse the repository at this point in the history
Currently Tycho ignores the version string for buildpath entries defined
in pde.bnd what leads to faulty dependency requirements.

This now correctly evaluates the version string and maps it to a P2
requirement.
  • Loading branch information
laeubi committed May 6, 2024
1 parent c146887 commit 7e3ba0e
Showing 1 changed file with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
package org.eclipse.tycho.core.resolver;

import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
Expand All @@ -37,6 +36,8 @@
import org.eclipse.tycho.p2maven.tmp.BundlesAction;
import org.eclipse.tycho.resolver.InstallableUnitProvider;

import aQute.bnd.header.Attrs;
import aQute.bnd.header.OSGiHeader;
import aQute.bnd.osgi.Constants;
import aQute.bnd.osgi.Processor;

Expand Down Expand Up @@ -86,10 +87,20 @@ public static List<IRequirement> getBndClasspathRequirements(Processor processor
//See https://bnd.bndtools.org/instructions/buildpath.html
String buildPath = processor.mergeProperties(Constants.BUILDPATH);
if (buildPath != null && !buildPath.isBlank()) {
return Arrays.stream(buildPath.split(","))
.map(bundleName -> MetadataFactory.createRequirement(BundlesAction.CAPABILITY_NS_OSGI_BUNDLE,
bundleName.trim(), VersionRange.emptyRange, null, true, true))
.toList();
return OSGiHeader.parseHeader(buildPath).entrySet().stream().map(entry -> {
String bundleName = entry.getKey();
Attrs attrs = entry.getValue();
String version = attrs.get(Constants.VERSION_ATTRIBUTE, Constants.VERSION_ATTR_LATEST);
VersionRange range;
if (Constants.VERSION_ATTR_LATEST.equals(version)) {
range = VersionRange.emptyRange;
} else {
range = VersionRange.create(version);
}
return MetadataFactory.createRequirement(BundlesAction.CAPABILITY_NS_OSGI_BUNDLE, bundleName.trim(),
range, null, true, true);
}).toList();

}
return Collections.emptyList();
}
Expand Down

0 comments on commit 7e3ba0e

Please sign in to comment.