-
-
Notifications
You must be signed in to change notification settings - Fork 77
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
published incremental poms have dependencyManagement stripped causing incorrect dependency resolution #705
Comments
dependencyManagement can be used to manage the transitive dependency versions not only direct ones, and this impacts what can end up in the resulting hpi file. By not including the depMgmt section then any downtream consumer will see the un managed versions of the dependencies which will differ from what they should see
So this seems wrong. Why are the dependencies not in the flattened POM? My suspicious eye falls on |
because the flattened pom is not promoting them from transitive dependencies to direct dependencies. you depend on say library X. you do not list all its dependencies - you just get them. now the flatten plugin does have a way to do this - but this breaks the maven hierachy as mentioned in the PR - as the depth first wins changes as you promote something from Depth N to depth 1 and then in other plugins it will go from N+2 to 2. (it will also promote lots of things that really should not be promoted too - as it promotes everything from plugins that you depend on!) |
How widespread is the issue? This case is the first I can recall being a problem so I wondering what about this plugin is different. Can it simply declare all the Kotlin dependencies as direct in its POM? Since it is importing the BOM that would not really increase maintenance cost. Or exclude |
Anything that uses
it does in so much as if new transitive deps are added (or removed) then they can go unnoticed. (very few people checked the maven-hpi log for the WARNING bundling transitive dependency - less still when the bump if via dependabot!)
excludes can be in the flattened pom, and according to the documentation they are by default - but given we are here because the documentation lies.... |
Unfortunately true, and I have thought of upgrading this to an error, though that would require a lot of adaptation (and, as you point out, leave behind stray deps when removed upstream). |
I had in mind but had never done, adding an enforcer rule that checked the contents of |
this probably also needs duplicating to the main jenkins parent pom which is used by things like |
wwwait what... https://issues.apache.org/jira/browse/MNG-7003 (https://issues.apache.org/jira/browse/MNG-5761) is the use of a bom in Maven useless when consuming a project that uses it for transitive dependencies 😱 so even if we did do this it would not work correctly |
apache/maven#1000 is interesting but it would be more interesting if for a given packaging you could pick a dependency manager…especially one which behaves like what |
yup. I guess this should be safe even with a different dependency tree when having multiple plugins in your IDE vs consuming a plugin dep from the repository as you would (should) have a failure from But I will need to check that it behaves correctly with plugin dependencies - I bet 💵💵 it won't which would be an issue. (all transitive dependencies from plugin X leak into plugin Y when it depends on X. |
Interesting, adds |
ass I thought - flattenMode all is no good as it promotes all transitive dependencies including those from other plugins which would completely mess with plugin BOM and hightly probably the PCT, as the plugins would be updated but you would get their old deps not the new ones from the transitive plugins https://repo.jenkins-ci.org/incrementals/org/jenkins-ci/plugins/github-api/1.303-419.vfca_9e79c9635/ note that short of getting |
Maybe just work around in |
Couple more places it's popped up in: |
Due to jenkinsci/plugin-pom#705 and https://issues.apache.org/jira/browse/MNG-7003 using dependencyManagement to manage the transitive dependencies is not a good idea if you are going to be consumed by something else. this keeps the dependencyManagement so we can manage the verions as one, but where we use a transitive dependency that has had its version managed we inline it into the dependencies
my understanding is different. any plugin that bundles a transitive dependency (not declared inline) whose version is defined by an entry in There does not need to be a conflict or different paths to the dependency - which is the very scary part. for example just add a dependency to okhttp from a plain project and compare the e.g.
produces
notice the 1.6.10 versions of kotlin from this means even if there are no conflicts if you ran |
so irrespective of the maven bug I believe it would be beneficial to publish the This would give parity with anything produced by My take on any fallout is that if it does arise whilst it could be surprise it will actually fix things and break workarounds that people have used rather than break something that was well setup and working as expected. flattening dependencies would lead to tedious occurrences where you need to exclude a tree of dependencies (one exclude becomes N and fragile) |
No? Is there a realistic example of a case where there is only a single path? I think you could construct one but it would be artificial—the normal reason to bother importing a BOM when not needed to align versions of direct dependencies would be that there are different paths to some transitive dep, with different versions. |
there are probably lots we do not know about - as upperBounds will only tells you when there is a conflict, not that a plugin version was "downgraded" realistic example (you do not need a BOM - just a regular dep inside a plugin A depends on library B plugin X depends on plugin A. inside Jenkins plugin X will see Library C at the newer version There is a single path to the dependency and as dependencyManagement is ignored plugin X will get the dependency version of C that is declared in library B's pom. |
https://issues.apache.org/jira/browse/MNG-7982 released in maven 4.0.0-alpha12 |
Jenkins and plugins versions report
Environment
ci.jenkins.io - N/AA plugin that is using incrementals/CD publishing has its pom mangled by the
maven-flatten-plugin
this flattening removes the
dependencyManagement
entries as can be seen between this repository file and this published artifactAs the dependencies on kotlin are transitive they are not included in the flattened pom, but are included in the hpi.
when the plugin is depended on by another plugin the result is the dependency manamgemtn is gone so you get the transitive version of the dependencies, not the version that the plugin was built with and bundled.
This not only causes errors for consumers - it also makes the behaviour of a build different in your IDE than when deployed - as in the IDE with workspace resolution the dependencies would be correct, but once released or in CI they would be different.
jenkinsci/github-api-plugin#200 (review)
What Operating System are you using (both controller, and any agents involved in the problem)?
N/A
Reproduction steps
jenkinsci/github-api-plugin#200 (review)
Expected Results
no enforcer error -
dependency:tree
would show the same versions of kotlin both in the okhttp-api plugin and in any other consumer of it that does not itself depend on kotlinActual Results
dependencyManagement
is stripped, downstream consumers get incorrect library versions.Anything else?
No response
The text was updated successfully, but these errors were encountered: