org.apache.maven.model.building.DefaultModelBuilder Java Examples
The following examples show how to use
org.apache.maven.model.building.DefaultModelBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MavenHelper.java From repairnator with MIT License | 6 votes |
public static Model readPomXml(File pomXml, String localMavenRepository) { ModelBuildingRequest req = new DefaultModelBuildingRequest(); req.setProcessPlugins(true); req.setPomFile(pomXml); req.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL); req.setModelResolver(new RepositoryModelResolver(localMavenRepository)); DefaultModelBuilder defaultModelBuilder = new DefaultModelBuilderFactory().newInstance(); // we try to build the model, and if we fail, we try to get the raw model try { ModelBuildingResult modelBuildingResult = defaultModelBuilder.build(req); return modelBuildingResult.getEffectiveModel(); } catch (ModelBuildingException e) { LOGGER.error("Error while building complete model. The raw model will be used. Error message: " + e.getMessage()); return defaultModelBuilder.buildRawModel(pomXml, ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL, true).get(); } }