From 4300d25fb83fb5f161a332dc798c3ffe31f06c0d Mon Sep 17 00:00:00 2001 From: Alshama M S Date: Thu, 14 Dec 2023 18:36:14 +0530 Subject: [PATCH] =?UTF-8?q?Strip=20micro-version=20while=20importing=20pac?= =?UTF-8?q?kages=20=E2=80=A8This=20commit=20resets=20the=20micro-version?= =?UTF-8?q?=20to=20=E2=80=980=E2=80=99=20while=20importing=20packages=20as?= =?UTF-8?q?=20part=20of=20quick=20fix,=20as=20it=20is=20not=20relevant.=20?= =?UTF-8?q?Co-authored-by:=20Hannes=20Wellmann=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 
Fixes:https://github.com/eclipse-pde/eclipse.pde/issues/401 --- .../core/text/bundle/ImportPackageObject.java | 14 +++++++++++--- .../ui/correction/java/JavaResolutionFactory.java | 14 +++++++++----- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/ui/org.eclipse.pde.core/text/org/eclipse/pde/internal/core/text/bundle/ImportPackageObject.java b/ui/org.eclipse.pde.core/text/org/eclipse/pde/internal/core/text/bundle/ImportPackageObject.java index 150eeaad172..b824745c552 100644 --- a/ui/org.eclipse.pde.core/text/org/eclipse/pde/internal/core/text/bundle/ImportPackageObject.java +++ b/ui/org.eclipse.pde.core/text/org/eclipse/pde/internal/core/text/bundle/ImportPackageObject.java @@ -32,9 +32,17 @@ 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(); + // String version = desc.getVersion().toString(); + // + // if (!version.equals(Version.emptyVersion.toString())) { + // return desc.getVersion().toString(); + // } + // return null; + Version version = desc.getVersion(); + if (version != null) { + 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; } diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/correction/java/JavaResolutionFactory.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/correction/java/JavaResolutionFactory.java index b2b9c196b82..7be36150308 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/correction/java/JavaResolutionFactory.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/correction/java/JavaResolutionFactory.java @@ -321,14 +321,18 @@ 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) { + header = bundle.getModel().getFactory().createHeader(Constants.IMPORT_PACKAGE, pkgId); + } + 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; + ImportPackageObject impObject = new ImportPackageObject((ManifestHeader) header, desc, + versionAttr); if (!isUndo()) { ipHeader.addPackage(impObject); } else {