Howdy. Thanks for your fast reply.
Yes, I am using a copy of MavenCli from 'maven-embedder:3.9.6' to execute Maven goals and access the MavenSession before completion. I probably overloaded my email, sorry. The described issues are irrelevant to my experiments, I could reproduce them with plain 'maven-embedder:3.9.1'. What I am doing... I need the Maven session as I want to instantiate and run this method of a Maven plugin, which takes MavenProject as argument https://github.com/fabapp2/rewrite-maven-plugin/blob/83d184ea9ffe3046429f16c91aa56a9610bae832/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java#L129 and use the returned 'List<SourceFile>' (the AST) in application code outside of a Maven plugin and process. I shamelessly copied the code from MavenCli and made it work for my needs (listen to ExecutionEvents). https://github.com/fabapp2/spring-rewrite-commons/blob/4de042b2aa7fbbbde12f3c4214386925eabe7e31/spring-rewrite-commons-maven-embedder/src/main/java/org/springframework/rewrite/embedder/MavenExecutor.java#L122 and hacked/opened up access to the MavenSession like this: https://github.com/fabapp2/spring-rewrite-commons/blob/9a6265272f178197f2c4ec20b8df574d97ae5acc/spring-rewrite-commons-maven-embedder/src/test/java/org/springframework/rewrite/embedder/MavenExecutorTests.java#L112 Thus asking if there's maybe a better, more official way to achieve this. Otherwise, that's the best I have. ;) On Mon, Feb 26, 2024 at 4:11 PM Tamás Cservenák <[email protected]> wrote: > > Howdy, > > just to be clear (as your phrasing is a bit unusual)... > Are we talking about some Maven extension? > As if in plugin, you can just inject Maven Session, no need for embedder or > what not... > > T > > On Mon, Feb 26, 2024 at 1:54 PM Fabian Krueger > <[email protected]> wrote: > > > Dear Maven Developers, > > > > first of all, thank you for your work on Maven! > > Secondly, I apologize in advance in case this is not the appropriate > > channel or I miss something. > > > > I am using maven-embedder 3.9.6 and tweaked a copy of MavenCli to > > access the MavenSession and retrieve runtime information from a Maven > > plugin. > > > > I am doing this because I need access to objects created inside the > > plugin from a Java application through access to the MavenSession. > > > > I experienced two issues while debugging and comparing with Maven > > Invoker and the Maven command line. > > > > Before adding issues I wanted to contact you and see if > > a) MavenEmbedder is still under active development (I've seen this > > asked the bug tracker before)? > > b) A better way exists to achieve my goal? (Preferably without copying > > and adjusting Maven code) > > c) You are maybe already aware of the issues? (I didn't find them in > > the bug tracker) > > > > Depending on your reply I'd happily add an issue with all the > > information I have. > > > > Here are the issues I am facing: > > > > 1. When running "mvn clean package" through MavenCli on a multi-module > > project, the call to "mavenProject.getCompileClasspathElements()" does > > not return the jars, > > but only the path to target/classes. When debugging the same with > > Maven's Invoker the paths to jars are provided. > > > > 2. When running "mvn clean package" through MavenCli on (the fairly > > large) Spring Cloud Data Flow project > > (https://github.com/spring-cloud/spring-cloud-dataflow), > > using tag: “v2.10.2” it fails because it misses a class > > 'DataAccessException' which is required by a plugin. My naive > > understanding of the error message makes me think > > if a parent ClassLoader wasn't passed to ClassWorld? Here's the > > relevant stacktrace: > > > > 15:54:10.385 [main] ERROR org.apache.maven.cli.MavenCli -- Failed to > > execute goal > > org.springframework.cloud:spring-cloud-dataflow-apps-metadata-plugin:1.0.4:aggregate-metadata > > (aggregate-metadata) on project > > spring-cloud-dataflow-single-step-batch-job: > > Execution aggregate-metadata of goal > > > > org.springframework.cloud:spring-cloud-dataflow-apps-metadata-plugin:1.0.4:aggregate-metadata > > failed: > > A required class was missing while executing > > > > org.springframework.cloud:spring-cloud-dataflow-apps-metadata-plugin:1.0.4:aggregate-metadata: > > org/springframework/dao/DataAccessException > > > > > > and further down: > > import: Entry[import from realm ClassRealm[maven.api, parent: null]] > > Does "parent: null" indicate a missing parent classlaoder for > > ClassWorld resulting in the cnf? > > > > Thank you in advance! > > > > Best, > > Fabian Krüger > > > > -- > > This electronic communication and the information and any files > > transmitted > > with it, or attached to it, are confidential and are intended solely for > > the use of the individual or entity to whom it is addressed and may > > contain > > information that is confidential, legally privileged, protected by privacy > > laws, or otherwise restricted from disclosure to anyone else. If you are > > not the intended recipient or the person responsible for delivering the > > e-mail to the intended recipient, you are hereby notified that any use, > > copying, distributing, dissemination, forwarding, printing, or copying of > > this e-mail is strictly prohibited. If you received this e-mail in error, > > please return the e-mail to the sender, delete it from your computer, and > > destroy any printed copy of it. > > -- This electronic communication and the information and any files transmitted with it, or attached to it, are confidential and are intended solely for the use of the individual or entity to whom it is addressed and may contain information that is confidential, legally privileged, protected by privacy laws, or otherwise restricted from disclosure to anyone else. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, you are hereby notified that any use, copying, distributing, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited. If you received this e-mail in error, please return the e-mail to the sender, delete it from your computer, and destroy any printed copy of it. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
