maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andres Almiray <>
Subject Launching full Maven programmatically
Date Thu, 16 Apr 2020 10:54:59 GMT

I'm looking for a way to launch Maven programmatically in such a way that I
can get access to fully resolved Model and MavenProject instances, and not
just for a single project but also for all projects that belong to a

At first I used this code

try {
    FileReader reader = new FileReader(pom);
    MavenXpp3Reader mavenReader = new MavenXpp3Reader();
    return new MavenProject(;
} catch (Exception e) {
    throw new IllegalArgumentException(e);

But of course that's not enough. Next I tried using the maven-model-builder
APIs directly but not all references get resolved (such as parent POMs) as
a custom ModelResolver is required and the default one is not intended to
be used in standalone fashion.

Ideally I would call some sort of embeddable Maven API that can give me the
answers I seek, something like this

MavenProject project = EmbeddableMaven.launch(propsOrFlags).file(pomFile);

or alternatively something like

MavenReactor reactor = EmbeddableMaven.launch(propsOrFlags).file(pomFile);
for(MavenProject project : reactor.getProjects()) { /* do stuff */ }

Of course I'm making up these types and method names as I do not know if
something like this exist or not, hence why I'm asking here.

Thanks in advance.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message