-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
#3725 - jetty-maven-plugin - WAR overlay dependencies not resolved from maven reactor #3858
Conversation
jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java
Outdated
Show resolved
Hide resolved
jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java
Outdated
Show resolved
Hide resolved
jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java
Outdated
Show resolved
Hide resolved
jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java
Outdated
Show resolved
Hide resolved
Hi @mironbalcerzak, I've left a couple of initial comments in the code, but we will discuss more of course. A couple of comments also here:
I think we're going to need to honour the include/excludes for projects that are in the reactor. You will probably need a class similar to the SelectiveJarResource that handles the inclusions/exclusions. This is going to get very complicated if the the dependency war has itself overlays.
We shouldn't need to do that, maven should ensure that everything in the reactor has all the transitive dependencies correctly resolved, shouldn't it? |
Hi @janbartel
No problem at all! Thanks for letting me work on that - it's nice (and fresh?) change from everyday work :)
I will handle it naturally - this PR is more of a proof-of-concept for the core issue - and I agree, I was already playing around with SelectiveJarResource, it should be possible to achieve what we need.
It totally should, and it does - apologies, I phrased it not clear enough. have a great day! -- mb |
Hhhmmm, shouldn't the include/exclude statements ensure that only 1 of those webapps is including the common jar? Otherwise having the common jar more than once shows up an error in the project configuration, no? |
Isn't it overcomplicating? As far as I understand what you suggested, we would need to firstly extract names of JARs from each overlay (artifact would be present in ${m2_repo} - so we wouldn't have access to dependency graph through maven, then configure exclude/include of SelectiveJarResource in a "smart way". The solution with single WEB-INF/lib for all overlays, we would not bother with that at all. JARs would just overwrite one another, or maybe silently skip (I need to check what exactly SelectiveJarResource.copyTo() does) ...or do you mean, while configuring of "overlays" at the plugin level? in pom.xml? It certainly would make things easy, but does anyone ever do that? From personal experience I can tell that people are just adding things in to pom.xml and it "somehow" works - unless it does not, then time and effort is spent to make it work... 🤐 |
my main concern is a lot of changes and the lack of test. If there is a test project you can probably transform it to an it test? |
yes definitely. If any issue with maven-invoker-plugin please let me know I can have a look at fixing it. |
@olamy, @janbartel - is there any particular reason why nested zip files are not supported? What I mean is:
I need it - and if you've got nothing against it, i'd like to deliver it too. -mb |
We use java.net.URLConnection to access these kinds of resources. The existence of nested jar resources is a packaging smell, and not recommended. Perhaps you want to look at alternative packaging ... |
@joakime - thanks for swift answer. It's not a smell when we think of WAR files. But to achieve it, I had to tweak slightly jdk internals ( Code-wise it's custom Handler that delegates to native logic if no nesting is detected and is invoked as new URL(url, spec, Handler) in JarResource - so, it's pretty much seemless. Is this approach something you guys would like to see or not really? If not, what is your suggestion for said use case? "uber-WARs" or "live-jetty-war" is not a solution. |
I caution the use of URLStreamHandler in a WebApp / Servlet environment. See Issues #1448 and #3700 for our fights with URLStreamHandler. |
Yup - that's why I am not particularly happy of what I did there. Have you got any other solution? Or should I stick with what I've done and let you guys review it once I finish and push? |
@mironbalcerzak I'm not really keen to merge such changes without any test... |
@olamy - tests will surely come. firstly I want to finish the feature development - this PR is not close to be in merging state just yet. I've opened it so you guys can see what I am doing and review right away as it's quite a big change to jetty-maven-plugin. |
@mironbalcerzak first let me say I've just got off a very long international flight, so jetlag is addling my brain. So, I'm having trouble understanding exactly what we're doing here. I thought you wanted to be able to use webapps that are overlay dependencies straight from the reactor, without requiring that they are built first, then unpacked? If that's the case, then I expect to see you applying the overlay rules to the contents of the reactor, rather than to the contents of the built and unpacked war files. I don't understand your question about using static resources packed inside dependency webapps - these will be in the reactor and therefore not packed. Any dependency webapps that are not in the reactor will be handled by the current, unchanged code. Where am I misunderstanding what you want to do? |
@janbartel - you are correct - however, as I am refactoring "here and there", I've found a way to skip "unpacking" phase for artifacts not present in maven reactor - and dealing with them right from m2_repo :) |
Neither the JVM classloader nor the jsp engine can deal with classes and resources packed into wars, hence the unpacking. Pursuing something like that would be a whole other dimension of difficult, so I suggest this PR sticks just to the original premise. |
c2d62d3
to
6c6bbb0
Compare
@janbartel thanks for your comment =) You've got a point - i will finish this PR as soon as I can and eventually prepare more in the future. |
@mironbalcerzak wow there are a huge number of changes in this PR! Too many changes to be able to be considered for a stable release like 9.4.x, so I think you'll have to base these changes off jetty-10.0.x instead. Also, instead of rewriting a lot of the jetty maven plugin code, I wonder could you look at providing more utility classes and methods that can be called? I ask because I am working on a total rewrite of the jetty maven plugin universe for jetty-10.0.x which would make it exceedingly difficult to merge your new code, even if we shared a common base of jetty-10.0.x. Making your changes in additional classes that can be called either from the existing jetty-10.0.x plugin code, or from the new refactored code would be easier to deal with. I get the feeling that these changes are still experimental, right? |
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.
See also my comment on the conversation tab.
...-plugin/src/main/java/org/eclipse/jetty/maven/plugin/classloader/MavenWebappClassloader.java
Show resolved
Hide resolved
jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/utils/OverlayUtils.java
Show resolved
Hide resolved
jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java
Show resolved
Hide resolved
jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/utils/ResourceUtils.java
Show resolved
Hide resolved
Hey @janbartel - thanks for keeping an eye on the thread 👍
Not that many if you take a look at what's done. Mostly refactored, repackaged and moved to utility classes the existing logic from jetty:run goal. I didn't check what's in jetty-10.0.x branch so not sure if it's possible to rebase it there.
Which logic am I duplicating? I thought I already removed a lot of duplicates... :)
Well - no, not anymore :) i still need to fix the broken tests and tidy up the codebase that I introduced. Plugin behaves (almost) as expected in my testing scenario (as said - one more commit to sort all out). Do you use hangouts/skype (i prefer hangouts - my ID is the email that I sign-off my commits with)? I think it would be a whole lot easier to explain what's done, and what I hoped to achieve. Cheers,
|
There are numerous changes to existing method signatures and field types, which is a no-no for a point release, which is why I'm saying it needs to be in a major release like jetty-10. The jetty-10.0.x branch as far as the jetty maven plugin should be very similar to the jetty-9.4.x branch, so it should be possible to reapply your changes to a jetty-10.0.x base.
I'm not saying you are duplicating code, I'm saying that the code you're writing is tightly bound into the JettyRunMojo/AbstractJettyMojo. Given the massive re-write I'm doing in this branch: https://github.com/eclipse/jetty.project/tree/jetty-10.0.x-1743-refactor-maven-plugin-redux it would be really difficult to work out how to incorporate it. If you compartmentalized your code a bit into some helper classes then these classes (with a very clear and well-documented api :) ) would be easier to re-use.
I'd like to see more comments in the code - there's a lot of code and a heck of a lot of lines moved around, it makes it very difficult to evaluate. I'm not seeing the type of code I was expecting to see, so I need some more comments to show what it is you're doing. And yes, we definitely are going to need some it tests for this. |
hey @janbartel,
Alright. I will move it there (10.x.x branch). Meanwhile, some code has been moved out of JettyRunMojo to seperate service class, meant only for setting "dependencies" up. Should be easier to reuse.
Which part is not clear? I'd rather refactor it to the state that code is "just readable", without need for comments. I am not a fan of "if something was hard to develop, shouldn't be easy to read" sayin ;) |
32abdf9
to
78c892d
Compare
hey @olamy, i've pushed a fair number of integration tests - please take a look (jetty-run-mojo-overlays-it) when you get a chance, and tell me what you think. Plugin is not behaving as expected in one corner case (will fix it in next commit). |
78c892d
to
0206b89
Compare
…m maven Signed-off-by: Miron Balcerzak <[email protected]>
cf51bb3
to
07d94a2
Compare
Hi @janbartel - hope all's good. I haven't heard from you in a while. I am slightly confused. Is there any work needed to be done on my behalf? Or we call a day and should I just drop any further development? Have a good day -mb |
// ======================================================================== | ||
// | ||
|
||
package org.mca.jetty.common; |
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.
wrong package
// ======================================================================== | ||
// | ||
|
||
package org.mca.jetty.common; |
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.
wrong package
almost all it tests are failing now... |
// ======================================================================== | ||
// | ||
|
||
package org.mca.jetty.common; |
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.
wrong package
// ======================================================================== | ||
// | ||
|
||
package org.mca.jetty.moduleA; |
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.
wrong package
// ======================================================================== | ||
// | ||
|
||
package org.mca.jetty.moduleA; |
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.
wrong package
// ======================================================================== | ||
// | ||
|
||
package org.mca.jetty.moduleA; |
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.
wrong package
// ======================================================================== | ||
// | ||
|
||
package org.mca.jetty.moduleB; |
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.
wrong package
// ======================================================================== | ||
// | ||
|
||
package org.mca.jetty.overlay; |
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.
wrong package
// ======================================================================== | ||
// | ||
|
||
package org.mca.jetty.moduleC; |
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.
wrong package
@mironbalcerzak sorry for the silence, been trying to land the big refactor of the plugins for jetty-10.0.x. As I mentioned before, the changes proposed here are extensive, and thus not appropriate for jetty-9, this would have to be in jetty-10. Preferably, you'd base your work off the branch for the plugin refactor, which is https://github.com/eclipse/jetty.project/tree/jetty-10.0.x-1743-refactor-maven-plugin-redux . Thinking about it some more, that refactor is a work-in-progress, so it might be much easier to wait until it is finalized and checked in to jetty-10.0.x branch - so you're not trying to work on something that is a moving target. I'm hoping to get a PR incorporated within the next 2 weeks. |
@janbartel no problem at all! that's a good idea - i will wait until it's finished. have a great day & all the best, |
@mironbalcerzak ok great! I'm still working on the refactor, but it's going very well. Feel free to take a look at the branch to start getting familiar with the new code. I'll close this PR for now. |
Signed-off-by: Miron Balcerzak [email protected]
Howdy!
How are you? Hope you are doing all fine.
As the things are at the moment, this PR is not ready for merge just yet. It's more for code-review and comments on what else needs to be done. So....
Base project structure
https://github.com/mironbalcerzak/gist-jetty-maven-plugin-w-overlay
What's done?
What's not done? (for now)
More research needs to be done on my side, whether it's possible to create a
org.eclipse.jetty.util.resource.Resource
that will handletargetPath
,exclusion
,inclusion
"on-the-fly", instead of extracting to jetty_overlays.Nice to have / Proposals
How to test?
git clone https://github.com/mironbalcerzak/gist-jetty-maven-plugin-w-overlay ${PROJECT}
localhost:8080
Test Case No.1
Executing jetty-maven-plugin on base dir of a multi-module project to create overlaid war of few WARs
cd ${PROJECT}
mvn deploy -Poverlay
Test Case No.2
Executing jetty-maven-plugin in one of the nested directories, to trigger "partial" handling of modules.
cd ${PROJECT}/overlay2
mvn deploy -PoverlayNested
Test Case No.3
In scenario when there are no modules available, all war files are extracted to "jetty_overlays" as it is done now.
What are your thoughts? Is there anything that I should consider in addition to what I've already mentioned in "what's not done" section?
Thanks for your time and have a great day! :)
-- mb