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.
Co-authored-by: Hannes Wellmann <wellmann.hannes1@gmx.net>


Fixes:eclipse-pde#401
  • Loading branch information
alshamams authored and HannesWell committed Dec 21, 2023
1 parent 1d27d86 commit 4300d25
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 4300d25

Please sign in to comment.