public static Model loadPOM ( String pomPath , String localRepo , Collection < RemoteRepository > repositories ) throws ProjectException { RepositoryClient repoClient = new RepositoryClient ( localRepo ) ; NaetherModelResolver resolver = new NaetherModelResolver ( repoClient , repositories ) ; ModelBuildingRequest req = new DefaultModelBuildingRequest ( ) ; req . setProcessPlugins ( false ) ; req . setPomFile ( new File ( pomPath ) ) ; req . setModelResolver ( resolver ) ; req . setValidationLevel ( ModelBuildingRequest . VALIDATION_LEVEL_MINIMAL ) ; DefaultModelBuilder builder = ( new DefaultModelBuilderFactory ( ) ) . newInstance ( ) ; try { return builder . build ( req ) . getEffectiveModel ( ) ; } catch ( ModelBuildingException e ) { throw new ProjectException ( "Failed to build project from pom" , e ) ; } }
Load Maven pom