> Hi all, > > I'm looking to write some tooling that integrates with maven by > programatically interrogating the build to get, for example, a list of > projects, their transitive dependencies, etc. What I don't want to do is > reimplement maven - I don't want to parse the pom file myself and resolve > dependencies myself. So I'd like to programatically instantiate maven and > ask it questions about the structure and state of the build. > > The main entry point into Maven seems to be MavenCli, but its public > method, doMain(), simply returns an integer return code, which is no use > for programmatic interrogation. So, in order to programatically > interrogate a maven build, eg get the list of projects, resolve the > dependencies etc, I think I have to completely copy most of the code in > MavenCli, which is a lot of code including a lot of implementation detail > that seems like something that tooling shouldn't have to be concerned with, > and is potentially quite fragile to future changes in Maven. So far I've > done this and it's at least partially working, but it just feels so wrong. > Is there any simpler/safer way to do this? > > I guess I could create a maven plugin that captured the state that I want > to return back to my tooling in a static variable after submitting an > execution request to MavenCli that executed a task provided by the plugin, > but that seems like a very hacky way of doing things - is there any API > that would allow me to simply ask maven for a fully initialized plexus > container, for example? How do other tools do this kind of integration, eg > Eclipse or IntelliJ?
I think, you are looking for Maven Embedder. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
