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

flatten-vs-shade incompatibility #100

Closed
mkarg opened this issue Jun 28, 2019 · 11 comments · Fixed by #281
Closed

flatten-vs-shade incompatibility #100

mkarg opened this issue Jun 28, 2019 · 11 comments · Fixed by #281

Comments

@mkarg
Copy link

mkarg commented Jun 28, 2019

When using Flatten Maven Plugin in the same project with Maven Shade Plugin then the dependency reduced POM is not flattened.

One of both plugins must have a bug, but which one?

I noticed that the cause seems to be this line of the shade plugin:
Model model = project.getOriginalModel();
For test purposes I changed it to project.getModel() which fixes the problem (i. e. it now reduces the flattened POM), but imposes a new problem: This does not flatten the POM, it flattens the effective POM.

Any ideas appreciated, so I could track the original cause, and file the bug in the right tracker.

@ribasco
Copy link

ribasco commented Nov 23, 2019

I encountered the exact issue you described. I was able to fix this by simply changing the order of execution between shade and flatten. Just make sure flatten comes after shade. (See answer on StackOverflow)

@mohanraj-r
Copy link

mohanraj-r commented Mar 6, 2020

I encountered the exact issue you described. I was able to fix this by simply changing the order of execution between shade and flatten. Just make sure flatten comes after shade. (See answer on StackOverflow)

👍 Also had to change the phase to package for it to work

@mkarg
Copy link
Author

mkarg commented Apr 7, 2020

@olamy @khmarbaise Can you please comment your ideas on this issue? How shall we go on?

@bjacquemoud
Copy link

I encountered the exact issue you described.
I was able to fix this only by simply setting createDependencyReducedPom to false

Changing the order of execution between shade and flatten didn't work for me

The reduced pom is indeed not flattened but also I have noticed that there is a error with the generated reduced pom with the parents's relativePath

originally its ../weasis-parent/pom.xml
and it becomes ../../weasis-parent/pom.xml when reduced

@see https://i.stack.imgur.com/boolA.png

that's probably the reason why it cannot resolve the parents pom

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade (default) on project weasis-launcher: Error creating shaded jar: 1 problem was encountered while building the effective model for org.weasis.launcher:weasis-launcher:[unknown-version]
[ERROR] [FATAL] Non-resolvable parent POM for org.weasis.launcher:weasis-launcher:[unknown-version]: Could not transfer artifact org.weasis:weasis-parent:pom:${revision}${changelist} from/to hug-nexus-repo-proxy (http://..../repository/maven-public): Failed to transfer file: http://..../repository/maven-public/org/weasis/weasis-parent/$%7Brevision%7D$%7Bchangelist%7D/weasis-parent-$%7Brevision%7D$%7Bchangelist%7D.pom. Return code is: 400 , ReasonPhrase:Invalid repository path. and 'parent.relativePath' points at wrong local POM @ line 3, column 11
[ERROR]  for project org.weasis.launcher:weasis-launcher:[unknown-version] at ....

@mkarg
Copy link
Author

mkarg commented Dec 3, 2020

@olamy @khmarbaise Can you please comment your ideas on this issue? How shall we go on?

@raydac
Copy link

raydac commented Jun 5, 2021

@mkarg
I also get problems in work with flatten+shade, so that use uber-pom plugin to merge project tree

@alamar
Copy link

alamar commented Dec 29, 2021

Just make sure flatten comes after shade.

While there may be uses for that, shade will not reduce dependencies coming from parent POM in this case.

@gzm55
Copy link

gzm55 commented Apr 5, 2022

When using Flatten Maven Plugin in the same project with Maven Shade Plugin then the dependency reduced POM is not flattened.

One of both plugins must have a bug, but which one?

I noticed that the cause seems to be this line of the shade plugin: Model model = project.getOriginalModel(); For test purposes I changed it to project.getModel() which fixes the problem (i. e. it now reduces the flattened POM), but imposes a new problem: This does not flatten the POM, it flattens the effective POM.

Any ideas appreciated, so I could track the original cause, and file the bug in the right tracker.

Hi @mkarg , changing to project.getModel() will break MSHADE-185.

The root cause should be the inconsistent of project.getOriginalModel() and readModel(project.getFile()). So every plugin switching the pom file should also update original model to reflect the new pom file content. And flatten and shade plugins share the same problem.

The work around of run flatten in package phase does not work when enable useDependencyReducedPomInJar in the shade plugin, i.e., the pom in the shaded jar is not processed by the flatten plugin.

@wangliang181230
Copy link

I think flatten only needs to ensure that the POM generated by the shade is correct and available.

@yeroc
Copy link

yeroc commented Jul 5, 2022

Any chance the above PR will get reviewed? Assuming it does indeed fix the issue. I just got bitten by this but can't find a work around since I need to create a dependency-reduced pom at the same time.

@gzm55
Copy link

gzm55 commented Jul 5, 2022

Any chance the above PR will get reviewed? Assuming it does indeed fix the issue. I just got bitten by this but can't find a work around since I need to create a dependency-reduced pom at the same time.

either of these two pr would fix tie incompatibility issue:

#281
apache/maven-shade-plugin#129

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 a pull request may close this issue.

9 participants