-
Notifications
You must be signed in to change notification settings - Fork 41
Switch the underlying xml implementation to the one from maven #236
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
Conversation
Is this really the right thing to do? We should rather encapsulate our stuff, no? |
What do you mean by "our stuff" ? The plexus xml bits ? The goal is not expose the plexus xml bits anymore. In order to do so, a new api has been introduced in maven 4. For compatibility, the old plexus has to be rewritten on top of this new api, else maven and plugins won't be able to share any xml config. |
Ah, you are leaving this as a hull/wrapper to the "new" solution? |
Exactly. The new |
so it means using this with maven 3.9.x and maven 3.9.x will have a dependency on maven 4.x.x 🤣 |
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.
sisu plexus as a dependency is really something to avoid, I think
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-api-xml</artifactId> | ||
<version>4.0.0-alpha-4</version> |
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 find it weird to depend on a version 4.0.0-alpha-4
I already fear the dependabot upgrades in the future when new Maven releases happen
</dependency> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-xml-impl</artifactId> |
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.
this one https://github.com/apache/maven/blob/maven-4.0.0-alpha-4/maven-xml-impl/pom.xml depends on sisu plexus
and sisu plexus depends on many many things, including plexus-utils (not provided, as at least maven-xml-impl did as a workaround for these circular dependencies): https://github.com/eclipse/sisu.plexus/blob/releases/0.3.5/org.eclipse.sisu.plexus/pom.xml
this dependency adds a dependency hell IMHO
why does maven-xml-impl require sisu plexus?
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.
Because of this class which depends on sisu. It could be moved out of maven-xml-impl
I suppose.
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 class is used in maven-plugin-api
unfortunately, so it can't be moved easily into maven-core
.
notice that in previous conversations, I proposed to split plexus-utils 3.x into plexus-utils 4.x + plexus-xml 4.x (containing org.codehaus.plexus.utils.xml packages) to at least have the current tweaks only happen on the plexus-xml side but this step was conflated with other (independently valid) ones, and now we are adding many Maven dependencies to the full plexus-utils, which may not be great for basic "non-XML" use of plexus-utils |
Well, let's create a |
Will users migrating to plexus-utils 4.x have to a new dependency on plexus-xml 4.x, or were you thinking about adding this dependency so that the migration could be done seamlessly ? Another way to tackle the problem would be split plexus-utils into plexus-xml and plexus-utils-core and keep plexus-utils with the two dependencies so that users could migrate easily... |
to me, they'd have to evaluate if they use the xml API or not, then choose if they add plexus-xml or not while upgrading plexus-utils to 4.x for all other utilities |
split from plexus-utils 3 to plexus-utils 4 + plexus-xml 4 prototyped in 2 plexus-utils branches: There was 1 small unexpected change to do: move ReaderFactory/WriterFactory from o.c.plexus.util to o.c.plexus.util.xml If we find this split useful to ease our Maven core XML changes, plexus-utils-4 is meant to become master of plexus-utils. (notice: it is what happened in the past with interpolation, which was extracted from an o.c.plexus.interpolation package in plexus-utils to plexus-interpolation Git repo) WDYT? |
Très bien ! |
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.
It is a very bad idea to move classes around from one Maven artifact to another without renaming them. This causes major problems when more than one instance ends up in the classpath at the same time and Java selects the wrong one, if it doesn't just give up and exit (which it can do in Java 9+). The classes need to be renamed, not just the artifacts.
I've experimented porting maven with those libraries, here are a few points:
The second point is a bit of a problem I think. I wonder if we should split the pull parser only in If we want to keep other xml related classes, we could split in 3 parts:
Note that the original point is to keep maven 3.x plugins working on maven 4, so I'm a bit worried of any incompatibility, in particular, moving the |
One possibility to fix the |
The goal is to provide some compatibility. In the future, plugins should use the new maven 4 api with the |
The key is the fully qualified class name including the package name. If that is in fact different, then there's no problem, and I withdraw my objection. Although now that I think about it...you can still have a problem if the same package (subpackages count as different packages for this) is split across two different jars. That causes problems too. |
import org.codehaus.plexus.util.xml.pull.XmlPullParser; | ||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; |
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.
wild card imports are usually avoided since they increase the risk of unintentional conflicts
@elharo I think you misunderstand the problem. Here's a small recap. The new maven 4 api provides an immutable xml api Note that the final state will be that all plugins will use the new maven 4 api with So to get back to your original point, the discussion is exactly about moving classes from |
I keep getting confused as to what is and is not moving how. However. my bottom line is that the same fully qualified class name should not be published in different artifacts, ever. Once com.example.Something has been publicly released in foo:bar:0.6.2 it should never be published in foo2:baz:x.x If you need to change things the way forward is to change BOTH the fully package qualified classnames AND the Maven groupID:artifactID. It is not possible to release a drop-in replacement under a different group ID or artifact ID without causing very painful, very hard-to-debug problems for end users and dependents. If we're not doing that, fine. If we are doing that, it's time to go back to the drawing board. https://jlbp.dev/JLBP-6 |
sadly yes :( |
Here's part of what I see in the jar for org.apache.maven:plexus-utils:
Is there some plan to change this? This is exactly what's going to cause dependency conflicts and classpath breakages for clients. |
That's what we were trying to do since a few months, but each time we suggest something, you keep insisting the state (present or suggested) breaks some rule and we should definitely not go in that direction. Once again, the goal is to remain binary compatible, i.e. allow existing plugins to work on maven 4.x. That cause a bunch of constraints, in particular, the fact that the And the ultimate state is that plugins will use the maven 4 api, so |
Yes, ultimately as "in Maven 5 or 6", because it requires all plugins to upgrade to the new Maven 4 API = something that will take a long time before we can just cut the past and say "old plugins using Maven 3 API cannot run any more"... (just for reference, just removing in Maven 3.9.0 the old plexus-utils injection trick from Maven 2 is causing complaints for dead plugins: see https://issues.apache.org/jira/browse/MNG-6965 ) for the near future, with existing Maven plugins of the next few years using Maven 3 plugin API before they migrate to Maven 4 API, the classloading of Maven core (core and API classloaders) protects them from dependency conflicts and classpath breakages |
I keep coming back to the same point: If the artifact ID or group ID of an existing class is changed, the fully package qualified name of the class should be changed too. If you want to remain binary compatible, you need to keep the fully package qualified name AND the group and artifact IDs the same. There is no way around this. The existing scheme that moves the classes into a new Maven artifact is NOT binary compatible. It will cause dependency conflicts and runtime and compile time breakages that do not currently occur. Some of these are extremely hard to diagnose and debug and cause much developer pain. I have no particular concern about new classes or implementation details inside classes. If Xpp3Dom now depends on a new XmlNode class that didn't exist before, fine. But the existing org.codehaus.plexus.util.xml.Xpp3Dom from org.codehaus.plexus:plexus-utils should not also be published in org.apache.maven:plexus-utils. That will lead to multiple versions being included in the classpath, and which one will be selected is hard to guess. Furthermore, Maven and Gradle will not necessary select the same version of this class given the same pom.xml. In JDK 9+ this can turn into a compile or runtime error due to split packages. This is sometimes called overlapping classes, and it's cumbersome to debug and workaround even if you're expecting it. If you're not familiar with it, it can take days or weeks to figure out what's happening. https://jlbp.dev/JLBP-5 |
I don't care about compile time breakages. What I'd like to achieve is 99% runtime compatibility.
Thanks, but once again, that's the current state. Stating that it's not good does not really help, we all know this, and we'd like to get past it.
In theory yes, but in reality, that's not true, because maven controls the classloader of plugins. And the class exported by maven's own classloader will take precedence over the one from the plugin classloader, so this definitely works.
Yes, that's exactly what we're trying to fix. It's also a pain in terms of maintenance. So, can we get past the rules and try to find a lesser evil here ? There are multiple ways forward, but basically, the idea is to bring back the change from maven 4 into the plexus xml classes in the plexus source tree, instead of duplicating the class in maven. That will allow us to get rid of the repackaged artifact in maven and should bring us back to a cleaner state.
I personally don't care so much about which solution we favour, but I'd really like to go forward on fixing the current state. |
next try:
extracting plexus-xml-pull from plexus-xml seems not feasible because there are many classes uses crossing packages @gnodet do you think these 2 would make sense and ease Maven 4 core maintenance on the XML compatibility update? |
@hboutemy fwiw, the Here's a branch that update maven to the two branches you created: |
@gnodet yes, I had to remove the methods using IMHO, the easiest update in Modello to support the change is to avoid using this If we need to do that, I'm even not sure that deprecating |
Yes, very good idea.
I don't follow. The original one is in I also think we should deprecate it, regardless of other considerations. The |
oh, optional dependency to |
Isn't the convention to call it |
I don't think we need to have the |
Alright, makes sense. Otherwise it'd be another GAV. |
Update:
Note that two unit tests are failing in |
|
Here's a fix for the failing unit tests. The behavior has changed with #216 but plexus-utils contains duplicate xml merge code in We may want to run the full maven IT suite before merging, but it looks good to me otherwise. |
@hboutemy I've been running the maven integration test suite successfully with the 3 branches above. |
great, yes, please create |
I'm not really keen on duplicating the code, I thought the idea was to reduce maintenance ;-)
|
yes, reducing maintenance is important I want to full stop plexus-utils 3.x maintenance, replaced with split in plexus-utils 4.x and plexus-xml 3 (or other version = the question I was asking), just to have separate releases for the XML part vs the non-XML part and maintain the new plexus-xml 4 with maven-xml-impl 4.x, yes |
Sounds good. I think a version 3 for plexus-xml would be weird, I'd rather align it with the next plexus-utils (i.e. 4, as it is now), or start again from 1. But 4 definitely sounds good. |
great job, thanks |
Yes, great job. After preparing releases would be good to send recommendations - what artefact should be used where for our/user plugins or libs. Something that we must do now or something for near future (transition to mvn4 API). I would skip most exciting part of Maven4 internals ;-) that will be more important when we bump minimal supported Maven version. |
AFAIK, adding the dependency to |
I prefer having users add plexus-xml dependency if they need it |
Done |
Two issues need to be fixed in maven before merging: