during a Mojo execution, having the effective POM is really easy because Maven core has prepared everything for the Mojo: see help:effective-pom code [1]
when you're not in a Mojo execution, you'll have to do the job Maven did, using Maven Model Builder to build the effective model and Maven Resolver to resolve the individual pom.xml that are necessary [2] Running Maven in debug mode may be of great help to track calls... I know that I'd love to have a simplified code that only builds an effective POM, dropping all the plugins execution aspects of Maven (that also create effective POMs for many things), to focus more easily on 1 effective POM construction, but I never took time to do it: I'm sure this would ease debuging the dependenciesManagement issues that I cited a few days ago Perhaps the old "Maven App Engine" [3] is a good starting point, but it's not maintained for 10 years... Regards, Hervé [1] https://github.com/apache/maven-help-plugin/blob/master/src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java#L197 [2] https://maven.apache.org/ref/3.8.4/ https://maven.apache.org/ref/3.8.4/maven-model-builder/ [3] https://svn.apache.org/viewvc/maven/sandbox/trunk/mae/ Le jeudi 23 décembre 2021, 04:29:06 CET Matt Benson a écrit : > I was speaking in the context of e.g. a Maven plugin, lifecycle > participant, etc. in which a MavenProject with its Model properties would > be available. If you can do your work in such a context it would probably > be reasonably easy, or you could trace what Maven does to build these > objects and reproduce externally. Typically a given interface will have a > Default* implementation somewhere among Maven's classpath. > > Hope this helps, > Matt > > On Wed, Dec 22, 2021, 6:06 PM Sebastian Proksch <[email protected]> wrote: > > I am not sure what you are referring to when you say "runtime model", > > but I found the sister project "model-builder", which seems to allow > > the creation of an "effective model"... and I found an illustrative > > example on how to use that project on StackOverflow [1], and it seems > > that I got it working properly. Maybe I am missing the obvious, but I > > could not find any good tutorial or getting started guide for how to > > use either of the two libraries... so I am still not sure how close I > > am to the "canonical" way of applying these libraries. :) > > > > One thing that I was struggling with for a bit is the creation of a > > `MavenResolver` instance as there seems to be no default > > implementation that is easily usable. I found basic implementations of > > that interface in various OSS projects that I could successfully > > integrate... but I am still wondering if there is kind of an > > "official" implementation of a basic resolver that I could just > > include through a dependency (versus having to clone code into my own > > project). > > > > Thanks for your time and for maintaining these two projects, they made my > > day! > > > > best > > Sebastian > > > > [1] https://stackoverflow.com/a/47324851/3617482 > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [email protected] > > For additional commands, e-mail: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
