How do I obtain a fully resolved Model of a pom file?
This is basically a rephrasing of How can i programmaticaly build the effective model of a pom file?
I\'m b
Romain provided the good answer above, but it was using a deprecated class that was removed from maven 3.x The updated version is this :
@Parameter( defaultValue = "${project}", readonly = true )
private MavenProject project;
@Component
private RepositorySystem repositorySystem;
@Component
private ProjectBuilder mavenProjectBuilder;
@Parameter( defaultValue = "${session}", readonly = true )
private MavenSession session;
private MavenProject getMavenProject(String groupId, String artifactId, String version) throws ProjectBuildingException {
Artifact pomArtifact = repositorySystem.createProjectArtifact(groupId, artifactId, version);
ProjectBuildingResult build = mavenProjectBuilder.build(pomArtifact, session.getProjectBuildingRequest());
return build.getProject();
}
A working example is in the hierarchy-maven-plugin