Open bjmi opened 2 years ago
Can corroborate and evaluate: Tried several versions of Maven and Tycho. Tycho 2.5.0 seems to require a Maven at least after 3.2.5. For 3.2.5, I see a weird NullPointerException at startup of Tycho during initialization.
It started working for me with Maven 3.6.3. (Skipped the intervening versions, because I was too lazy to install them and it is a Tycho/Maven issue anyway, but it serves to demonstrate, that the promise of Reficio, that it is going to work with Maven up to 3.2 is likely void for recent versions of Tycho)
It is also working with Tycho 2.7.5 and Maven 3.8.6
But it actually stops working with Tycho 3.0.0 -> Obviously, Tycho 3.0.0 breaks the Reficio:p2-maven-plugin.
In https://github.com/eclipse-tycho/tycho/commit/72747e79e8ad9bc6ee556cac11bdc2e262ce6db2 org.eclipse.sisu.equinox.launching.internal.P2ApplicationLauncher
has been removed.
It is more complicated than just that, I investigated further:
<min.jdk.version>17</min.jdk.version>
...
<maven-version>3.8.6</maven-version>
Thanks for analyzing the problem. Would it be helpful for your patch to prepare an update to the last 2.x version of Tycho (including a release) and update the master branch to Java 17. It seems that Java 17 is mandatory for Tycho 3.x
It would certainly not hurt. To an extend, it would depend on how comfortable you feel about switching to 17 coming from 8, in my carrer, I encountered a lot of organizations really conservative on JDK updates, that weren't too lucky about getting that pushed down their throat. I found that a surpringly bold move on part of tycho. Just as surprising as skiping to Maven 3.8.3 from 3.2.x. But I'm the last one to complain, and would be comfortable leaving them behind.
When switching to 2.7.5, the last pre 3.0 Tycho release, make sure to match their maven-version on your build, so you can rely on Javas compile time guarantees.
But you should point out these changes on your readme, i. e. updating your prerequisites. (Tycho seemes to miss this too).
The patch is going to take some time. Following @bjmjs hint shows, that Tycho replaced the P2ApplicationLauncher essentially with nothing. So I got to figure out an alternate way of invocation from scratch.
As a workaround we could split our build into a "p2" build and "tycho" build and could circumvent the tycho version dependence.
Hm. I'm not that familiar with all that stuff, I'm still struggling to wrap my head around the mess that is stacking OSGi, Equinox and Tycho on top of each other, let alone to start an OSGi service within a maven build. Is a catalog an Equinoxe or a Tycho thing? If the former, using Tycho would be a pure thing of convenience, i. e. not requiring to roll your own catalog builder. If there is enough support for this in the lower tiers, say Equinox, we might collapse a whole tier, and cutting out Tycho as an intermediate.
So it boils down to the question: how expensive is it to do this without Tycho?
@gtsh p2 maven plugin tried to reuse already existing implementation from maven bundle plugin and Tycho.
IMHO Tycho started a new way how to handle maven artifacts in a Tycho build (see this blog post and a Twitter discussion). Also, they created a bunch of new p2 plugins (Had no time to analyze them).
First Idea: Maybe we can move the deleted code to this plugin and try to reduce the dependency to Tycho. I need some time to analyze that.
Meanwhile I experimented a bit on my own, and found out, that this might be way over my head. My first attempt at trivially replacing the P2-Launcher by instantiating CategoryPublisherApplication my self failed, since I should have done this in an Equinoxe/OSGi-container. Currently, I don't even know, how I get one within Maven. If this is a recurring thing with Tycho, there should be some other way to start one from within Maven, that can be reused? Time to analyze the Tycho-Plugins to find out?
Some more hints, you might already know: https://rtist.hcldoc.com/help/topic/org.eclipse.platform.doc.isv/guide/p2_publisher.html#category_publisher has the command line invocation of the CategoryPublisherApplication.
The startup - as mentioned above - actually fails for me, because the org.eclipse.equinox.internal.p2.publisher.Activator hasn't its BundleContext set.
Thanks, @gtsh, for your analysis. I found the issue where the P2ApplicationLauncher was replaced. They use now a TychoFeaturesAndBundlesPublisherApplication that is part of an also called p2-maven-plugin. It seems for me that is a 1:1 replacement.
@gtsh I had some time to go deeper into the analysis. I t seems we can use the CatogoryPublisherApplication directly in the code if an embedded Equinox is started (therefore you got a NullPointerException). Tycho has already implemented an equinox sisu integration. I need some time to figure out how it works (currently I don't find a documentation about it)
I actually figured as much, but was not able to pinpoint, how Tycho starts its OSGi-Context. A detail of that is the question, whether this would be a unique OSGi container started once for the complete maven lifecycle and then reused, or whether you may have one just for that one mojo execution.
In the back of my mind is, that it might be possible, to inject Tycho's mojo into ours, then delegate. If we are lucky, the mojo knows, how and when to create the container, or to join an existing one.
Else, it might be possible, to build a trivial project with just that mojo, to explore with the debugger.
Hi @gtsh,
I tried out to call 'mvn org.eclipse.tycho:tycho-p2-plugin:3.0.0:category-p2-metadata' manually. But without a Tycho context, I get a NullPointerExeption. I think this problem is similar to the problem that is described in this Tycho issue
Currently, it seems, I had to move the old Tycho logic to this plugin or find out how to use the equinox sisu integration.
Any more progress or new ideas how to get this solved? Or are there alternative ways to replace p2-maven-plugin features in the future?
I just ran into this issue myself. I'm working on a project that will typically perform a major upgrade of all its dependencies once a year, and sadly this is the third year in a row where p2-maven-plugin
broke in one way or another due to the update. The reliance on internal implementation details of other plug-ins and modules is probably the main contributing factor for these repeated breakages.
I had to upgrade to Tycho 3.0.5 (from 2.7.5) for other reasons, and as @gtsh and @bjmi have already pointed out, the 3.0.5 version of tycho-core
no longer contains P2ApplicationLauncher
. I may be naive here, but I don't fully understand how p2-maven-plugin
picks up the new Tycho version in the first place. Doesn't Maven's Plexus DI/dependency management system have a similar hierarchical class loading/class isolation feature as OSGi? (maybe that's my misconception?) I guess I don't fully understand how a ${tycho.version}
variable that's used by tycho-compiler-plugin
overrides p2-maven-plugin
's own declared Tycho 2.7.5 dependency when p2-maven-plugin:site
is executed.
At any rate, does anyone have any progress to report this issue? (fork with a fix, work-around, alternative plugin?) Staying on Tycho 2.7.5 for the build is unfortunately not an option for me.
Hi @daniel-matheis-vivavis, @raner,
I started an implementation, where I try to merge Tycho old logic in this plugin. It doesn't work well.
In https://github.com/sparsick/p2-maven-plugin/tree/297-updateTycho3 you can find the current state of my implementation.
Which options we have?
Currently, I can't find time to finish it (this issue has currently not so high priority in my projects). But I could answer questions if someone want to finish it.
Thanks for your prompt reply, @sparsick :-) and thanks for sharing a starting point for an implementation.
It seems that the key will be to find a replacement for P2ApplicationLauncher
, but I'm hesitant to go down that road, since it will still depend on other modules' internal implementation details and might break again with the next release.
I'm still looking at the läubisoft blog article you shared, but it seems it has a lot of manual steps, which might not work for me since I need to be able to consume updated versions of dependencies in a fully automated fashion from within the Maven build. If a version update of a dependency requires a manual step, this approach won't really work.
In the meantime, I might have found a way to stay on Tycho 2.7.5 for my project. If I can make that work, hopefully, p2-maven-plugin
should still work as desired.
My naive approach was to just copy and paste the deleted classes from the Tycho project to the plugin.
But the integration tests fail with errors (I don't have them to hand right now).
This commit removes the original P2ApplicationLauncher.
Running
p2:site
with Maven 3.8.6 and Tycho 3.0.0 ends up with