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

Strip micro-version and add upper bound when adding package imports #1007

Merged
merged 1 commit into from
Dec 22, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ public class ImportPackageObject extends PackageObject {
private static final long serialVersionUID = 1L;

private static String getVersion(ExportPackageDescription desc) {
String version = desc.getVersion().toString();
if (!version.equals(Version.emptyVersion.toString())) {
return desc.getVersion().toString();
Version version = desc.getVersion();
if (version != null && !Version.emptyVersion.equals(version)) {
return new VersionRange(
"[" + version.getMajor() + "." + version.getMinor() + "," + (version.getMajor() + 1) + "]") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$
.toString();
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import org.eclipse.pde.internal.core.text.bundle.ExportPackageObject;
import org.eclipse.pde.internal.core.text.bundle.ImportPackageHeader;
import org.eclipse.pde.internal.core.text.bundle.ImportPackageObject;
import org.eclipse.pde.internal.core.text.bundle.ManifestHeader;
import org.eclipse.pde.internal.ui.PDEPlugin;
import org.eclipse.pde.internal.ui.PDEPluginImages;
import org.eclipse.pde.internal.ui.PDEUIMessages;
Expand Down Expand Up @@ -321,14 +320,17 @@ protected void modifyModel(IBaseModel model, IProgressMonitor monitor) throws Co
if (!(model instanceof IBundlePluginModelBase base))
return;
IBundle bundle = base.getBundleModel().getBundle();
String pkgId = ((ExportPackageDescription) getChangeObject()).getName();
ExportPackageDescription desc = (ExportPackageDescription) getChangeObject();
String pkgId = desc.getName();
IManifestHeader header = bundle.getManifestHeader(Constants.IMPORT_PACKAGE);
if (header == null) {
bundle.setHeader(Constants.IMPORT_PACKAGE, pkgId);
} else if (header instanceof ImportPackageHeader ipHeader) {
int manifestVersion = BundlePluginBase.getBundleManifestVersion(bundle);
String versionAttr = (manifestVersion < 2) ? ICoreConstants.PACKAGE_SPECIFICATION_VERSION : Constants.VERSION_ATTRIBUTE;
ImportPackageObject impObject = new ImportPackageObject((ManifestHeader) header, (ExportPackageDescription) getChangeObject(), versionAttr);
header = bundle.getModel().getFactory().createHeader(Constants.IMPORT_PACKAGE, pkgId);
}
if (header instanceof ImportPackageHeader ipHeader) {
String versionAttr = (BundlePluginBase.getBundleManifestVersion(bundle) < 2)
? ICoreConstants.PACKAGE_SPECIFICATION_VERSION
: Constants.VERSION_ATTRIBUTE;
ImportPackageObject impObject = new ImportPackageObject(ipHeader, desc, versionAttr);
if (!isUndo()) {
ipHeader.addPackage(impObject);
} else {
Expand Down
Loading