Skip to content

Commit

Permalink
Strip micro-version while importing packages
Browse files Browse the repository at this point in the history

This commit resets the micro-version to ‘0’ while importing packages as
part of quick fix, as it is not relevant.
Fixes:
#401
  • Loading branch information
alshamams committed Dec 14, 2023
1 parent d7a9363 commit cd950ea
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import org.eclipse.swt.graphics.Point;
import org.eclipse.text.edits.TextEdit;
import org.osgi.framework.Constants;
import org.osgi.framework.Version;

/**
* A factory class used to create resolutions for JDT problem markers which involve modifying a project's MANIFEST.MF (or possibly plugin.xml)
Expand Down Expand Up @@ -321,14 +322,19 @@ 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);
String versionAttr = (manifestVersion < 2) ? ICoreConstants.PACKAGE_SPECIFICATION_VERSION
: Constants.VERSION_ATTRIBUTE;
Version version = desc.getVersion();
ImportPackageObject impObject = new ImportPackageObject((ManifestHeader) header, desc,
versionAttr);
impObject.setVersion(version.getMajor() + "." + version.getMinor() + ".0"); //$NON-NLS-1$ //$NON-NLS-2$
if (!isUndo()) {
ipHeader.addPackage(impObject);
} else {
Expand Down

0 comments on commit cd950ea

Please sign in to comment.