How do I programmatically construct a MavenProject instance (not the current project) given its groupId, artifactId, version, etc?
UPDATE: I’m trying to create a patch for http://jira.codehaus.org/browse/MDEP-322. I believe the maven-dependency-plugin depends on Maven 2.x so I can’t use any Maven 3.x APIs.
How you would go about doing this depends on whether you want to construct the project from an artifact in your local repository or from a pom file on your hard drive. Either way, you’ll need to get a
ProjectBuilder, which you can do like so in a Mojo:If you want to build from an artifact in your local repo, you’ll also need:
Once you have that, you can construct a
MavenProjectfrom an artifact from your local repository:Or from a pom file: