-
Notifications
You must be signed in to change notification settings - Fork 194
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
Add PDE API Tools Mojo for Tycho #1328
Conversation
This is most likely because the classpath of your mojo contains some OSGi API in addition to the equinox one, e.g. BND sadly pulls in some stuff at compile scope, so it needs to be excluded.
The question is more: Why do you want org.eclipse.tycho.embedder-api be part of your framework? As it is not part of eclipse you should be able to drop that, please note that this currently is only required in Tycho because of "historic reasons", a much more cleaner approach would be (an that what the tycho-p2-maven plugin does) to select one entry-point service (that is for P2 the
Actually there is not much special, just keep in mind that you can only get one shared instance! So the question is, how do your normally access the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somme comments below
@@ -0,0 +1,92 @@ | |||
package org.eclipse.tycho.apitools; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Header is missing
|
||
// TODO: or encapsulate this into own class? | ||
@Requirement(hint = "connect") | ||
private EquinoxServiceFactory serviceFactory; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The encapsualtion is only done to share it across mojos in Tycho, I dont think it is required here.
// TODO: See | ||
// org.eclipse.pde.api.tools.model.tests.TestSuiteHelper.createTestingBaseline(); | ||
|
||
ITargetPlatformService tpService = serviceFactory.getService(ITargetPlatformService.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be aware that fetching a service can return null, so if you require the service, its better to use Object.requireNonNull(..., "Some usefull message"); this will simplify debugging a lot.
getLog().info("Skipped"); | ||
return; | ||
} | ||
if (new File(project.getBasedir(), JarFile.MANIFEST_NAME).isFile()) { // TODO: consider non PDE bundles |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a more general approach would be to take a look at the project artifact and check if:
- it is a jar
- it is an OSGi Bundle
} | ||
|
||
@SuppressWarnings("removal") | ||
public Set<File> collectProjectDependencyPaths() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I think it might be even better to actually inspect the compile path of the maven project here but we could investigate this later on...
@HannesWell I think the quirks you see here are because you use Tycho (core) APIs here, I think this should not be required (as it is not requires as of today):
|
Yes I really like the idea and this would be a good case to polish the |
@HannesWell do you plan to work on this further soon so we can include it in the 3.0 release end of month? Or should we mark this for 3.1? |
Thank you Christoph for your help, I'm about to try out your hints and I'm glad you like the idea.
Yes I would like to have it in the 3.0 release (if it is working until then), this is currently my number one priority work for Eclipse. |
Just a gentle reminder: I think we should create the 3.0.x branch and switch the master to 3.1.0-SNAPSHOT at 21.09.2022 what would mean no new features (just bugfixes), so if you want your changes to be included it would be good to have them until 20.09.2022 EOD. |
I'm not sure I'll be able to complete this until then, probably not. I investigated the This has the effect that all OSGi-framework instances are created by the same classloader and (probably) because To tackel the shared classloader issue I tried different approaches, like wrapping the ClassRealm to ignore imported realms but that did not succeed when it comes to classes like I would see two other options:
But as far as I understand it this will lead to ClassCastExceptions when exchanging objects between the OSGi-framework and the mojo because different classloaders are used and the classes are not the same. |
d6cc634
to
112e80f
Compare
As said above, you should not import any Tycho specific parts, this will simply not work for this use case and is not necessary. The maven class realms are very hard to manage so one should try to keep them as much separated as possible. |
@HannesWell if there are any changes required for the sisu part please open a separate PR so we can merge these as a perquisite. Beside that, please note there is already a And then it would be good to have a minimal example in the integration tests (see for example https://github.com/eclipse-tycho/tycho/blob/master/tycho-its/src/test/java/org/eclipse/tycho/test/apitools/ApiToolsTest.java), such an integration test must not really do much useful stuff, but at least show how to configure / run the mojo, I might then also be able to help debugging class-loading problems. |
112e80f
to
c1f45cf
Compare
Can you tell/point to some code, how that should be done better? The current implementation is basically a stripped version from While looking up the latter, I noticed the
I tried it with even with only basic maven dependency and pde.core without any transitive dependencies (the current state), but even then each Equinox-instance is created with the same classloader of
Yes I already had the intention do create a dedicated issue, that's why I made these changes in a separate commit (some clean-ups and actual changes separated). I first wanted to make this API-analysis story work in general, but I think I will do the separate PR earlier. The new mojo is already in the
Yes, I had the intention to create that. But I was lazy until now and just used a correspondingly modified M2E build for that. |
c1f45cf
to
67f0688
Compare
After investigating the 'plain'-Java mode of PDE apitools a bit deeper and figuring out why my previous test failed I went back to that approach and now plan to continue without OSGi. And yes it looks promising. The little test case I added already worked. I also tried the M2E build but that failed, but I haven't yet investigated further. One reason I would like to have that in 3.0 is that with this mojo the |
If you like to suggest any mojo removal that should have a separate issue, assign the issue to 4.x Milestone and as a first step create a PR to deprecate the mojo so users can get aware of it. |
FWIW, I think we can deprecate mojo when we have a good alternative, make it warn with a replacement, keep it for 3-4 releases and remove it after that. No need to a major release to remove such non-core mojos IMO. |
The error is actually caused by the cleanup of the connect framework cleaning up one important method see: |
🤦🏽♂️ Looks like I shot myself in the foot with that clean up. Sorry for that, I hope it didn't cause to much extra work. At least I then wasted half my of a weekend to circumvent that problem. Thanks for the fix. |
No problem, I have no idea why I didn't noticed that at the review... anyways I played around a bit and further proceed with getting things out of OSGi into maven world. While this works quite good it now was required to export This revealed, the the API tools seem so do some Because of this I have to disabled the |
@HannesWell as we have a new major release we can "break" things, so if you like to consider that for your change just add a note to the migration guide. |
@HannesWell can you probably make the integration test an own PR I'd like to experiment with a new way for mojos to fire up an OSGi framework and this seems perfectly suited, so as a first step we might can get something similar to just a 1:1 replace ant by a maven-mojo call and build on it later on to improve things!? |
67f0688
to
d837101
Compare
Yes I can do that, but I first have to check that the test actually makes sense. For now I rebased the current state of the PR an resolved all conflicts respectively reworked what has changed. In general this seems to work, but I had the impression that there are some flaws in the PDE/Equinox-Resolver state, because for the attached test case I get API problems reports like:
And JavaSE 0.0.0 is strange. I remberer there where issues in this area when I worked last on it in the end of last year, but I have to check it again. |
@HannesWell is this still relevant? If yes can you rebase/resolve conflicts? |
@HannesWell this is now > 1 year old and currently has some conflicts, should we close this for now and probably have a fresh start once this becomes relevant again. |
Frankly I don't understand how it helps to close this now and start again in another PR, as long as there is a chance that it is completed on day? Some tasks take longer to complete, may it be because of the task itself or because other more important things come up in the meantime, but that doesn't mean they are obsolete. |
You can also reopen this PR but if it is in conflicting state for so long time we can't even simply rebase the PR with current master, so probably this is a sign that the change is (no longer) important. |
I would say not as important as other things, but not obsolete. |
The goal of this PR is to provide an API-anysis Mojo as discussed in #1233.
In contrast to my suggestion for an initial implementation of that mojo in the mentioned discussion this implementation goes one step further and uses PDE's
IApiAnalyzer
directly. Thanks tosisu-osgi-connect
I assume it is possible to now use that directly and to run the api-analysis in a operating Equinox instance?Compared to the current approach used by Eclipse-Platform and suggested in the discussion this has the advantage that there is now Eclipse instance to assemble and launch (or at least it is much cheaper), the project does not have to be recompiled and the baseline artifact is cached in the
.m2/repository
Maven cache, which makes it instantly available after the first run.The setup of the API-baseline could still be enhanced, but for now I'm presenting my preliminary current state of work because I'm struggling to launch the connected Equinox/Eclipse properly.
After the Equinox instance is started in the
APIAnalyser
I get many errors like the following:Subsequently there are also some resolution errors like the following but I assume I just have to update the connect.bundles accordingly.
Furthermore I'm not sure if I use sisu-osgi-connect correctly. My goal is to run
IApiAnalyzer.analyzeComponent()
and the creation of theIApiBaseline
within a running Equinox instance without a workspace, which is supportd by PDE-apitools. I have the impression that it was even the intention to support to run it in non OSGi-environment but it looks like that does not work well.However the reasons for my doubt regarding correct use is that the Equinox-instance is only launched after I got a service from the
EquinoxServiceFactory
. Is this just a design quirk or am I doing something fundamentally wrong?@laeubi can you help me with some advice?