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

#439 - Adopt PDE configurations for maven-bundle-plugins #440

Merged
merged 2 commits into from
Jan 5, 2022

Conversation

laeubi
Copy link
Member

@laeubi laeubi commented Dec 9, 2021

This add initial code contribution and project setup to m2e. This code is copied from (with slight adjustments e.g. package name and constant inlining):

both files are EPL 1.0 and the contribution is below 1000 LOC (including configuration files), so I would assume no IP review is required, but like to get a verification by @mickaelistria and @fbricon as project lead.

If the legal part is done I'd like to test and maybe enhance the code later on, e.g. currently I have only used it with felix plugin but the same should apply to the bnd-bundle plugin.

@laeubi laeubi force-pushed the issue_439 branch 3 times, most recently from 5d306a2 to 70dbb2f Compare December 10, 2021 07:25
@mickaelistria mickaelistria marked this pull request as ready for review December 10, 2021 09:13
Copy link
Contributor

@mickaelistria mickaelistria left a comment

Choose a reason for hiding this comment

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

We'll need to check with IP team whether it's fine to just pick some other EPL code here.
I'm a bit worried about the file with missing copyright header being a blocker.

@akurtakov
Copy link
Contributor

Whenever new code that is not submitted by author and is not coming from project governed by EF a CQ has to be open. Please open new one of type Project Content (Content to be maintained by an Eclipse Foundation Project) and refer to this PR.

@laeubi
Copy link
Member Author

laeubi commented Dec 10, 2021

@laeubi
Copy link
Member Author

laeubi commented Dec 10, 2021

The CQ require PMC approval: https://dev.eclipse.org/ipzilla/show_bug.cgi?id=23882

@laeubi
Copy link
Member Author

laeubi commented Dec 10, 2021

The CQ require PMC approval

if @fbricon responsible for PMC for m2e? Can we ping someone else if not?

add initial code contribution and project setup

Signed-off-by: Christoph Läubrich <laeubi@laeubi-soft.de>
@HannesWell
Copy link
Contributor

Is it necessary to place the connector in a dedicated plug-in project?
Wouldn't it be possible to have it in the o.e.m2e.pde plug-in in a package named org.eclipse.m2e.pde.connector?
The TP related classes maybe would be better moved in their own package, o.e.m2e.pde.target (in a separate PR)?

@laeubi
Copy link
Member Author

laeubi commented Dec 12, 2021

Is it necessary to place the connector in a dedicated plug-in project?

I think it is not strictly necessary but I don't see a reason why a dedicated plugin would harm here. Even though its unlikely if one likes to have the maven-bundle support but not the target support it could be installed separately.

@HannesWell
Copy link
Contributor

Is it necessary to place the connector in a dedicated plug-in project?

I think it is not strictly necessary but I don't see a reason why a dedicated plugin would harm here. Even though its unlikely if one likes to have the maven-bundle support but not the target support it could be installed separately.

I don't consider it harmful as well.
But having more plug-ins just fills the dev-workspace and adds management overhead (more versions to bump, more metadata files, etc.). Of course only very few big plug-ins is probably as bad too many very small plug-ins. So apart from the technical boundaries/requirements (like separate installability, dependencies) the decision for a new plug-in it should be weigh up sensibly. And IMHO in this case a new plug-in is not worth it. I think it would be better to introduce multiple packages in org.eclipse.m2e.pde.
But this is of course also a matter of preferences/habits, so there is not one right solution.

@laeubi
Copy link
Member Author

laeubi commented Dec 12, 2021

I don't think any "count" is a valid measure of putting code into separate plugins. Especially when it comes to (semantic) versioning, smaller items are generally better than bigger ones. Just because both contribute to PDE don't make them related. The target part contributes to the target handling of pde and this contributes to the m2e connectors so this are two separate concerns that should be live in separate plugins.

@HannesWell
Copy link
Contributor

I don't think any "count" is a valid measure of putting code into separate plugins. Especially when it comes to (semantic) versioning, smaller items are generally better than bigger ones. Just because both contribute to PDE don't make them related. The target part contributes to the target handling of pde and this contributes to the m2e connectors so this are two separate concerns that should be live in separate plugins.

That also makes sense.
But then the o.e.m2e.pde should be renamed to o.e.m2e.pde.target (or similar) as well as the corresponding ui plug-in to reflect the fact that it is dedicated to that concern. Otherwise the name is actually too general. But that's off topic of this PR.

@laeubi
Copy link
Member Author

laeubi commented Dec 13, 2021

But then the o.e.m2e.pde should be renamed to o.e.m2e.pde.target

probably yes, but this would require using some kind of patch feature to make P2 aware of it (I have never used that) so for now I won't complicate it too much just for the sake of naming.

Copy link
Contributor

@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 tested it with a little Maven-project that uses the maven-bundle-plugin:manifest goal and it worked very well.

There is just an error markers in the Dependencies-Tab of the Manifest-Editor, even tough the plug-in/package from the Maven-project was proposed by the Add... dialogues (for Require-Bundle and Import-Package). So I think this is an PDE issue.

I also like the warnings, in the POM regarding the missing configuration. This is very helpful.

Some parts of the code could be simplified using present-day Java-11 methods. But I think this should be done in a subsequent PR, so that the initial move to Eclipse has as few changes as possible and we get a more clear git-history.

org.eclipse.m2e.pde.connector/build.properties Outdated Show resolved Hide resolved
@HannesWell
Copy link
Contributor

HannesWell commented Dec 14, 2021

But then the o.e.m2e.pde should be renamed to o.e.m2e.pde.target

probably yes, but this would require using some kind of patch feature to make P2 aware of it (I have never used that) so for now I won't complicate it too much just for the sake of naming.

For the installation process an uninstallBundle p2-touchpoint instruction could be used. But another issue would be down-stream users that use require the m2e.pde bundle or import a package from it. At the moment the content is de-facto public API because it is not internal.

Which gives me another question: Is the code in this new m2e.pde.connector plug-in meant to be public API or should it better be internal?

@laeubi
Copy link
Member Author

laeubi commented Dec 14, 2021

I consider none of the code in m2e.pde.* as public API beside that is very unlikely that anyone is already enhancing that stuff right now :-)

Don't know if one could mark a bundle as "internal" but I really don't like these eclipse extension as they are extremely confusing and against OSGi principles.

@laeubi
Copy link
Member Author

laeubi commented Dec 14, 2021

There is just an error markers in the Dependencies-Tab of the Manifest-Editor, even tough the plug-in/package from the Maven-project was proposed by the Add... dialogues (for Require-Bundle and Import-Package). So I think this is an PDE issue.

Will you take a look at this?

I sometimes noted that PDE also marks bundles with unresolved requirements with such an error marker, e.g. if your maven-bundle import-package a dependency but this is not available at the current target platform (I opened Bug 577605 for such cases). If you double click the bundle it should open the manifest and show if there is any unresolved package.

@laeubi
Copy link
Member Author

laeubi commented Dec 14, 2021

Some parts of the code could be simplified using present-day Java-11 methods. But I think this should be done in a subsequent PR, so that the initial move to Eclipse has as few changes as possible and we get a more clear git-history.

Yep exactly main goal is to get the code in even though it seems we would have been faster If I have rewritten it from scratch as it seem no one of the PMC likes to approve the CQ :-(

@HannesWell
Copy link
Contributor

I consider none of the code in m2e.pde.* as public API beside that is very unlikely that anyone is already enhancing that stuff right now :-)

Don't know if one could mark a bundle as "internal" but I really don't like these eclipse extension as they are extremely confusing and against OSGi principles.

Are you referring to the package name element .internal. or the Manifest header-arguments ;x-internal/friend in the Manifest?
Personally I also don't like the internal-package names but at least it is a clear statement.

However I have noticed that this plug-in does not export its only package so it is not public (regardless of the name), so sorry for the disturbance in this regard. To keep the off-scope discussion about o.e.m2e.pde out of this PR I have created #454, we should continue there if there is more to say.

@HannesWell
Copy link
Contributor

There is just an error markers in the Dependencies-Tab of the Manifest-Editor, even tough the plug-in/package from the Maven-project was proposed by the Add... dialogues (for Require-Bundle and Import-Package). So I think this is an PDE issue.

Will you take a look at this?

I can, but at the moment I have too many other things on my list (in my mind), that I would like to do before. So if this flaw persists and nobody else takes care of it, I can do it later :)

Some parts of the code could be simplified using present-day Java-11 methods. But I think this should be done in a subsequent PR, so that the initial move to Eclipse has as few changes as possible and we get a more clear git-history.

Yep exactly main goal is to get the code in even though it seems we would have been faster If I have rewritten it from scratch as it seem no one of the PMC likes to approve the CQ :-(

Aren't @akurtakov and @vogella in the Eclipse PMC? Could you be so kind and have a look at this or refer to somebody else from PMC?

@mickaelistria
Copy link
Contributor

Aren't @akurtakov and @vogella in the Eclipse PMC? Could you be so kind and have a look at this or refer to somebody else from PMC?

m2e is a project under technology. PMC members for Technology are listed at https://projects.eclipse.org/projects/technology/who .

@HannesWell
Copy link
Contributor

m2e is a project under technology. PMC members for Technology are listed at https://projects.eclipse.org/projects/technology/who .

Thanks Mickael for that hint, I already wondered if there is more than one PMC, because I have the impression that the term Project is used redundantly.

So could @guw, @caniszczyk or @waynebeaton be so kind and have a look at the associated CQ at
https://dev.eclipse.org/ipzilla/show_bug.cgi?id=23882

Copy link
Contributor

@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.

I tested this PR with the pure Maven m2e's maven-runtime projects as proposed in PR #466 and found one problem with clean and full builds:

In the beginning of a clean/full build the target/classes folder is purged and with it the META-INF/MANIFEST.MF file located within it. At the same time target/maven-bundle-plugin/org.apache.felix_maven-bundle-plugin_manifest_xx is not touched. Consequently the manifest Mojo does not re-generate the MANIFEST.MF in the build when supportIncrementalBuild is enabled, because the mojo only checks org.apache.felix_maven-bundle-plugin_manifest_xx and not if the MANIFEST.MF is present.
To workaround this, org.apache.felix_maven-bundle-plugin_manifest_xx has to be target/maven-bundle-plugin in each clean/full build before the manifest Mojo is executed.

@@ -2,7 +2,7 @@
<feature
id="org.eclipse.m2e.pde.feature"
label="%featureName"
version="1.19.0.qualifier"
version="1.20.0.qualifier"
Copy link
Contributor

Choose a reason for hiding this comment

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

The minor version of m2e itself (i.e. the m2e-sdk feature) should also be bumped to be 20.
Actually I expected the tycho-p2-extras-plugin:compare-version-with-baselines goal to consider minor and major versions too.

}

private boolean isFelixBundleGoal(MojoExecution execution) {
return FELIX_MANIFEST_GOAL.equals(execution.getGoal());
Copy link
Contributor

Choose a reason for hiding this comment

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

The name is actually misleading because it checks on the manifest goal. A name like isFelixManifestGoal() would be more suitable.

@laeubi
Copy link
Member Author

laeubi commented Dec 29, 2021

the manifest Mojo does not re-generate the MANIFEST.MF in the build when supportIncrementalBuild is enabled, because the mojo only checks org.apache.felix_maven-bundle-plugin_manifest_xx and not if the MANIFEST.MF is present.

I think this is a bug in the Felix Bundle plugin, if you agree, would you mind to open a ticket at felix (and maybe provide a PR to fix this)?

@HannesWell
Copy link
Contributor

the manifest Mojo does not re-generate the MANIFEST.MF in the build when supportIncrementalBuild is enabled, because the mojo only checks org.apache.felix_maven-bundle-plugin_manifest_xx and not if the MANIFEST.MF is present.

I think this is a bug in the Felix Bundle plugin, if you agree, would you mind to open a ticket at felix (and maybe provide a PR to fix this)?

Fully agree that this is a bug in the Felix maven-bundle-plugin. I can create an issue and provide a PR (I wanted to report/fix some other minor issues anyway, so now I have one more reason).
But if if this is fixed only future versions of the maven-bundle-plugin will work correctly.
It's probably discouraged to provide a workaround for old versions, but to make users aware of it we could emit a warning when a flawed version is used.

@laeubi
Copy link
Member Author

laeubi commented Dec 29, 2021

But if if this is fixed only future versions of the maven-bundle-plugin will work correctly.

I won't mind to only support latest version given that this was flawed before and we have only limited dev-resources. I even don't see a reason to use old versions of the bundle-plugin... We should also not complicate the code with to much else/if/workaround/... and simply tell people when complain to use always the latest version of the plugin.

Copy link
Contributor

@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.

the manifest Mojo does not re-generate the MANIFEST.MF in the build when supportIncrementalBuild is enabled, because the mojo only checks org.apache.felix_maven-bundle-plugin_manifest_xx and not if the MANIFEST.MF is present.

I think this is a bug in the Felix Bundle plugin, if you agree, would you mind to open a ticket at felix (and maybe provide a PR to fix this)?

I opened issue Apache FELIX-6493 and submitted PR apache/felix-dev#124. Fell free to review it.

With those fixes the suggested workaround is not necessary any more and the manifest generation works well and even the error markers at the Maven-OSGi-Projects in the Manifest-Editor dependencies tab respectively the Target-Platform-State view magically vanished (I'm not sure why exactly and if this is permanently).

But if if this is fixed only future versions of the maven-bundle-plugin will work correctly.

I won't mind to only support latest version given that this was flawed before and we have only limited dev-resources. I even don't see a reason to use old versions of the bundle-plugin... We should also not complicate the code with to much else/if/workaround/... and simply tell people when complain to use always the latest version of the plugin.

I agree that we should not make it too complicated and a workaround is not necessary, but I think a warning would make the user experience much better. Especially because it could take some time until the new maven-bundle-plugin is available and is widely adopted. I think it would be a pity if this great feature would not work in the beginning and users first have to search the internet for a solution while we could simply give them a hint with a corresponding warning. :)

Comment on lines +100 to +102
if (problems.size() > 0) {
this.markerManager.addErrorMarkers(request.getPom(), IMavenConstants.MARKER_LIFECYCLEMAPPING_ID, problems);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This code does not consider that the resource of a problem could be the parent pom (or grand-parent etc.).
The following suggestion does consider this.

Suggested change
if (problems.size() > 0) {
this.markerManager.addErrorMarkers(request.getPom(), IMavenConstants.MARKER_LIFECYCLEMAPPING_ID, problems);
}
if (!problems.isEmpty()) {
IMavenProjectRegistry projectManager = MavenPlugin.getMavenProjectRegistry();
for (MavenProblemInfo problem : problems) {
String[] gav = problem.getLocation().getResourceId().split(":");
IFile pom = projectManager.getMavenProject(gav[0], gav[1], gav[2]).getPom();
markerManager.addErrorMarker(pom, IMavenConstants.MARKER_LIFECYCLEMAPPING_ID, problem);
}
}

IMarker.SEVERITY_WARNING, location);
problems.add(problem);
}
hasManifestExecution = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

The following code would give the user a warning to use the latest Maven-Bundle-Plugin (assuming the mentioned fixes will be integrated there). Maybe the message could be better.

Suggested change
hasManifestExecution = true;
MavenVersion version = MavenVersion.parseMavenString(execution.getPlugin().getVersion());
if (version != null && version.toReleaseVersion().compareTo(new MavenVersion("5.1.4")) < 0) {
SourceLocation location = SourceLocationHelper.findLocation(execution.getPlugin(), "version");
problems.add(new MavenProblemInfo(
"The Maven-Bundle-Plugin only integrates well with Eclipse-M2E with version 5.4.0 or later",
IMarker.SEVERITY_WARNING, location));
}
hasManifestExecution = true;

@laeubi
Copy link
Member Author

laeubi commented Dec 30, 2021

I agree that we should not make it too complicated and a workaround is not necessary, but I think a warning would make the user experience much better. Especially because it could take some time until the new maven-bundle-plugin is available and is widely adopted. I think it would be a pity if this great feature would not work in the beginning and users first have to search the internet for a solution while we could simply give them a hint with a corresponding warning. :)

I think we can at least add a warning marker for older version and suggest an upgrade. But for such improvements I really want to wait until EMO approval of the code.

@mickaelistria
Copy link
Contributor

I really want to wait until EMO approval of the code.

That's now good to merge from a legal POV according to recent comment on the CQ.

@laeubi
Copy link
Member Author

laeubi commented Jan 5, 2022

@HannesWell I'll merge this as-is now, so the code is in the repository can you create separate PR(s) for your enhancements?

- add warnings about missing configuration options
- support bnd-bundle plugin as well
Copy link
Contributor

@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.

@HannesWell I'll merge this as-is now, so the code is in the repository can you create separate PR(s) for your enhancements?

Yes, please go ahead. I'll create a PR afterwards.

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.

5 participants