-
Notifications
You must be signed in to change notification settings - Fork 11
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
Use maven embedder #68
Draft
fabapp2
wants to merge
76
commits into
spring-projects:main
Choose a base branch
from
fabapp2:use-maven-embedder
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Comparing the results of MavenRewriteProjectParser (using OR to large extend) and RewriteProjectParser surfaced that the classpath lacks dependencies (jars) when parsing with MavenRewriteProjectParser. The custom implementation has them. This is probably a bug in MavenCli because the javadoc say that it should work.
They are not resolved with MavenCli for multi-module projects
* Bump Maven to 3.9.3 * Remove shrinkwrap
fabapp2
force-pushed
the
use-maven-embedder
branch
from
March 22, 2024 12:58
4de042b
to
4244f98
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What needs to be done?
Spike to figure out how to replace the custom Maven parsing with something more solid.
Why does it need to be done?
The parsing of Maven projects is implemented with (naive) custom code that parses trivial and most common Maven projects. But, it has many limitations compared to Maven's parsing capabilities.
Attempting to remove these limitations would require a reimplementation of Maven's parsing logic which is not feasible.
Requirements
Path
s to the jars on the classpath, these can change depending on e.g. profile settingsMavenSession
.MavenSession
is accessible through MavenExecutionListener
sExecutionListener
s can be registered on theMavenExecutionRequest
ExecutionListener
and retrieve the session when the build is finished.Options
Different options exist to execute Maven goals from Java code.
These are the options I am aware of and have looked into:
Invoker
M2_HOME
orMAVEN_HOME
to point to a Maven installMavenCli
.MavenSession
,MavenProject
, and others and to registerExecutionListener
sMETA-INF/maven/extension.xml
, or (preferably) in a central location${maven.home}/lib/ext
.EmbeddedMaven
class that allows executing Maven goals. It defines awithMavenInvoker
method that takes aorg.apache.maven.shared.invoker.InvocationRequest
. This code does what's required (it seems)PropagateExecutionContextMojo
makes me think if the approach could work for the current problem as well.Solution
None of the solutions above fulfill the requirements.
But, the
MavenCli
has everything required to start a Maven build from within the same JVM process.It hides the access to the
MavenExecutionResult
.I created a shameless copy of the
MavenCli
and provide the listener through this implementation.This guarantees that the build is as close as possible to what Maven does with the
EmbeddedMaven
.WIP
Check if OpenRewrite's build plugin code can be incorporated as is to reuse as much of their logic as possible.
Solve ClassLoader conflicts with
ClassWorld
running in a Spring Boot application 🤞