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

Consider the version string when adding bnd requirements #3826

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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