private Model getPomModel ( String groupId , String artifactId , String version , File pom ) throws ArtifactResolutionException , ArtifactNotFoundException , IOException , XmlPullParserException { Model model = null ; // do we want to look in the reactor like the // project builder? Would require @aggregator goal // which causes problems in maven core right now // because we also need dependency resolution in // other // rules. (MNG-2277) // look in the location specified by pom first. boolean found = false ; try { model = readModel ( pom ) ; // i found a model, lets make sure it's the one // I want found = checkIfModelMatches ( groupId , artifactId , version , model ) ; } catch ( IOException e ) { // nothing here, but lets look in the repo // before giving up. } catch ( XmlPullParserException e ) { // nothing here, but lets look in the repo // before giving up. } // i didn't find it in the local file system, go // look in the repo if ( ! found ) { Artifact pomArtifact = factory . createArtifact ( groupId , artifactId , version , null , "pom" ) ; resolver . resolve ( pomArtifact , remoteRepositories , local ) ; model = readModel ( pomArtifact . getFile ( ) ) ; } return model ; }
This method gets the model for the defined artifact . Looks first in the filesystem then tries to get it from the repo .