Skip to content

Quick fix to add available matching version for Imported packages#1962

Merged
noopur2507 merged 1 commit intoeclipse-pde:masterfrom
nburnwal09:quickFix_verMatch_import_package
Apr 10, 2026
Merged

Quick fix to add available matching version for Imported packages#1962
noopur2507 merged 1 commit intoeclipse-pde:masterfrom
nburnwal09:quickFix_verMatch_import_package

Conversation

@nburnwal09
Copy link
Copy Markdown

@nburnwal09 nburnwal09 commented Sep 9, 2025

This is to provide a quick fix for adding the available matching version for Imported packages in MANIFEST.MF warning.
Similar to the fix: #1623 and as suggested in here

Attaching screenshot for the quick fix:

image

After applying:

image

@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 9, 2025

Test Results

  147 files  ±0    147 suites  ±0   39m 20s ⏱️ + 3m 49s
3 497 tests ±0  3 443 ✅ +69   54 💤 ±0  0 ❌  - 69 
9 312 runs  ±0  9 182 ✅ +74  130 💤 ±0  0 ❌  - 74 

Results for commit df3c116. ± Comparison against base commit 12fa5d0.

♻️ This comment has been updated with latest results.

@nburnwal09
Copy link
Copy Markdown
Author

nburnwal09 commented Sep 15, 2025

@HannesWell
Can you please review this PR?

Corrected:
Also, as you suggested here to provide the version range
I have added a method VersionUtil.computeInitialRequirementVersionRange() and providing version range with minor and major versions as quick fix - for both Required packages and Imported packages

exportedPackage.getVersion().toString(), NameVersionDescriptor.TYPE_PACKAGE);
exportedPackage.getExporter().getBundle();

if (("java".equals(name) || name.startsWith("java."))) { //$NON-NLS-1$ //$NON-NLS-2$
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this check be moved to the beginning of the loop, as soon as name is available?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@nburnwal09 nburnwal09 force-pushed the quickFix_verMatch_import_package branch from adb0579 to 7089fa0 Compare November 24, 2025 05:17
@nburnwal09 nburnwal09 force-pushed the quickFix_verMatch_import_package branch from 7089fa0 to 7687e6f Compare December 1, 2025 12:04
@eclipse-pde-bot
Copy link
Copy Markdown
Contributor

eclipse-pde-bot commented Dec 1, 2025

This pull request changes some projects for the first time in this development cycle.
Therefore the following files need a version increment:

ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF

An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch.

Git patch
From 866ec4afa8f8cfc8ccb2d50e39ac55ecb9063b5f Mon Sep 17 00:00:00 2001
From: Eclipse PDE Bot <pde-bot@eclipse.org>
Date: Thu, 5 Mar 2026 07:43:16 +0000
Subject: [PATCH] Version bump(s) for 4.40 stream


diff --git a/ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF
index 87bb6898ee..ddaa9c6ccc 100644
--- a/ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF
+++ b/ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %name
 Bundle-SymbolicName: org.eclipse.pde.ui; singleton:=true
-Bundle-Version: 3.16.400.qualifier
+Bundle-Version: 3.16.500.qualifier
 Bundle-Activator: org.eclipse.pde.internal.ui.PDEPlugin
 Bundle-Vendor: %provider-name
 Bundle-Localization: plugin
-- 
2.53.0

Further information are available in Common Build Issues - Missing version increments.

Copy link
Copy Markdown
Member

@HannesWell HannesWell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one point from me at the moment, I'll try to do a full review this evening.

Comment on lines +123 to +131
public static String computeInitialRequirementVersionRange(String version) {
if (version != null && VersionUtil.validateVersion(version).isOK()) {
Version pvi = Version.parseVersion(version);
return new VersionRange(
"[" + pvi.getMajor() + "." + pvi.getMinor() + "," + (pvi.getMajor() + 1) + ")") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$
.toString();
}
return ""; //$NON-NLS-1$
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recently I added a method that does this to ManifestUtils:

public static Optional<VersionRange> createConsumerRequirementRange(Version version) {
if (version != null && !Version.emptyVersion.equals(version)) {
return Optional.ofNullable(new VersionRange(VersionRange.LEFT_CLOSED, //
new Version(version.getMajor(), version.getMinor(), 0), //
new Version(version.getMajor() + 1, 0, 0), //
VersionRange.RIGHT_OPEN));
}
return Optional.empty();
}

Admittedly this method would probably better be moved to this class and probably be used instead of the existing method. That would hopefully add proper version ranges in more places.
I can try to have a look at unifying these as soon as possible. Or if you want to have a look at it, it would be more than welcome.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HannesWell
I have moved your method createConsumerRequirementRange to VersionUtil class and updated the corresponding callers(found 2 classes - JavaResolutionFactory and ImportPackageObject).
Kindly check the changes.

@nburnwal09 nburnwal09 force-pushed the quickFix_verMatch_import_package branch from 35827e3 to cc2fb8c Compare December 13, 2025 13:10
@nburnwal09
Copy link
Copy Markdown
Author

@HannesWell
Could you please check this whenever you get sometime?

@nburnwal09 nburnwal09 requested a review from HannesWell January 5, 2026 09:46
@nburnwal09 nburnwal09 force-pushed the quickFix_verMatch_import_package branch 2 times, most recently from d0529e8 to a045060 Compare January 12, 2026 06:58
@nburnwal09 nburnwal09 force-pushed the quickFix_verMatch_import_package branch 2 times, most recently from 6d5c079 to eb69bb5 Compare January 17, 2026 18:13
@nburnwal09 nburnwal09 force-pushed the quickFix_verMatch_import_package branch from eb69bb5 to 2c25e5b Compare February 13, 2026 06:07
@gireeshpunathil
Copy link
Copy Markdown
Contributor

this is ready to land, but would like another quick look from you, @HannesWell !

@HannesWell
Copy link
Copy Markdown
Member

this is ready to land, but would like another quick look from you, @HannesWell !

Yes I will do it soon.
But please note that we are in RC1 week now and in the freeze period. So even when this is ready and reviewed we probably have to wait until the next dev-cycle opens in a bit more than one and a half week.

@nburnwal09 nburnwal09 force-pushed the quickFix_verMatch_import_package branch from 2c25e5b to b23030f Compare March 5, 2026 07:35
@nburnwal09
Copy link
Copy Markdown
Author

@HannesWell
Could you pls check this PR now.

this is ready to land, but would like another quick look from you, @HannesWell !

Yes I will do it soon. But please note that we are in RC1 week now and in the freeze period. So even when this is ready and reviewed we probably have to wait until the next dev-cycle opens in a bit more than one and a half week.

@nburnwal09
Copy link
Copy Markdown
Author

@HannesWell

image The test failures are unrelated to this PR. They are passing in my local.

@nburnwal09 nburnwal09 force-pushed the quickFix_verMatch_import_package branch from 4030b60 to 33e07d7 Compare March 17, 2026 06:20
@nburnwal09
Copy link
Copy Markdown
Author

@HannesWell
If you are good with this fix(screenshots attached) then I can request @noopur2507 to review and merge this.

@nburnwal09 nburnwal09 force-pushed the quickFix_verMatch_import_package branch from 33e07d7 to 40bbadd Compare April 1, 2026 10:39
Copy link
Copy Markdown
Member

@noopur2507 noopur2507 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Neha. The overall approach looks good and aligns well with the existing Require-Bundle quick fix. I’ve added a few comments to improve the correctness.

Also, please add tests if applicable for PDE quick fixes.

@HannesWell / @gireeshpunathil – please take a look and suggest if anything else should be adjusted.

Once the above comments are addressed, this should be in good shape for merging.

// $NON-NLS-2$
continue;
}
if (name.equalsIgnoreCase(inputElement.toString())) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Package names in OSGi are case-sensitive, so this can lead to incorrect matches.

continue;
}
if (name.equalsIgnoreCase(inputElement.toString())) {
return exportedPackage.getVersion();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This returns the first matching exported package. This may produce incorrect results when multiple bundles export the same package. IMO, the fix should select the highest available version instead.

super(type, marker);
}

public Version getVersion(Object inputElement) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this parameter be of type String instead of Object?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

versionRange is calculated based on version object(in line 79). If we change the type to string, we will have to change the type again there.

ImportPackageHeader header = (ImportPackageHeader) bundle.getManifestHeader(Constants.IMPORT_PACKAGE);
if (header != null) {
for (ImportPackageObject importPackage : header.getPackages()) {
if (bundleId.equals(importPackage.getName())) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"bundleId" is misleading here as the value represents a package name. Please update it across all usages of "bundleId" in the PR.

for (ImportPackageObject importPackage : header.getPackages()) {
if (bundleId.equals(importPackage.getName())) {
Version version = getVersion(bundleId);
if (version != null) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, if no matching exported package is found i.e. if version is null, the quick fix will silently fail. So, the quick fix will appear but will have no effect. Better to avoid offering it if no version is available.

Comment on lines +1306 to +1307
AddMatchingVersion = Require latest available version
AddMatchingVersionDescription = Add a version range aligned with the latest compatible available version
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review both strings to reflect the intended change for the latest version / version range as these are now used by both Require-Bundle and Import-Package quick fixes.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@noopur2507
I have updated the msg. Attached the screenshot in the PR description

@noopur2507
Copy link
Copy Markdown
Member

@nburnwal09, I still see old changes in the PR. Can you please update it?

@nburnwal09 nburnwal09 force-pushed the quickFix_verMatch_import_package branch from 40bbadd to c3b57fe Compare April 10, 2026 06:09
Copy link
Copy Markdown
Member

@noopur2507 noopur2507 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Neha.

@noopur2507 noopur2507 force-pushed the quickFix_verMatch_import_package branch from c3b57fe to df3c116 Compare April 10, 2026 06:25
@nburnwal09
Copy link
Copy Markdown
Author

@nburnwal09, I still see old changes in the PR. Can you please update it?

Yeah sorry about that. That pushed got rejected in my local and I didn't notice. Have updated just now

@noopur2507 noopur2507 merged commit 4808f71 into eclipse-pde:master Apr 10, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a quickfix to add missing version information

5 participants