-
-
Save zacker330/93b7ad8a253c609b5e5b075ba3e123d3 to your computer and use it in GitHub Desktop.
Creating a MavenProject from an ArtifactInfo inside a maven plugin.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected MavenProject buildProjectModel(ArtifactInfo artifactInfo) throws Exception { | |
try { | |
ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest(); | |
configuration.setLocalRepository( localRepository ); | |
configuration.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL ); | |
configuration.setProcessPlugins( false ); | |
configuration.setRepositoryMerging( ProjectBuildingRequest.RepositoryMerging.REQUEST_DOMINANT ); | |
Properties properties = new Properties( ); | |
for ( String key : session.getSystemProperties( ).keySet() ){ | |
properties.put( key, session.getSystemProperties().get(key) ); | |
} | |
configuration.setSystemProperties( properties ); | |
configuration.setRepositorySession( session ); | |
org.apache.maven.artifact.Artifact artifact = new org.apache.maven.artifact.DefaultArtifact( | |
artifactInfo.groupId, artifactInfo.artifactId,artifactInfo.version, | |
"compile", "", "", new DefaultArtifactHandler()); | |
MavenProject project = projectBuilder.build(artifact, configuration).getProject(); | |
return project; | |
} catch (Exception ex) { | |
getLog().error("error in buildProjectModel ", ex); | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment