@Test public void testGetMavenModel() { File javaParserPom = new File("./src/test/resources/pom-examples/javaparser-pom.xml"); File tempM2 = Files.createTempDir(); Model model = MavenHelper.readPomXml(javaParserPom, tempM2.getAbsolutePath()); assertNotNull(model); assertEquals(8, model.getModules().size()); }
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(); 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(); } }
MavenHelper { 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(); 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(); } } }
MavenHelper { 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(); 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(); } } MavenHelper(String pomFile, String goal, Properties properties, String name, ProjectInspector inspector);  MavenHelper(String pomFile, String goal, Properties properties, String name, ProjectInspector inspector, boolean skipCheckstyle); }
MavenHelper { 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(); 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(); } } MavenHelper(String pomFile, String goal, Properties properties, String name, ProjectInspector inspector);  MavenHelper(String pomFile, String goal, Properties properties, String name, ProjectInspector inspector, boolean skipCheckstyle); String getGoal(); String getPomFile(); Properties getProperties(); String getName(); ProjectInspector getInspector(); InvocationOutputHandler getErrorHandler(); InvocationOutputHandler getOutputHandler(); void updateLastOutputDate(); void setErrorHandler(InvocationOutputHandler errorHandler); void setOutputHandler(InvocationOutputHandler outputHandler); static Model readPomXml(File pomXml, String localMavenRepository); int run(); }
MavenHelper { 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(); 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(); } } MavenHelper(String pomFile, String goal, Properties properties, String name, ProjectInspector inspector);  MavenHelper(String pomFile, String goal, Properties properties, String name, ProjectInspector inspector, boolean skipCheckstyle); String getGoal(); String getPomFile(); Properties getProperties(); String getName(); ProjectInspector getInspector(); InvocationOutputHandler getErrorHandler(); InvocationOutputHandler getOutputHandler(); void updateLastOutputDate(); void setErrorHandler(InvocationOutputHandler errorHandler); void setOutputHandler(InvocationOutputHandler outputHandler); static Model readPomXml(File pomXml, String localMavenRepository); int run(); static final int MAVEN_SUCCESS; static final int MAVEN_ERROR; static final String SKIP_TEST_PROPERTY; }