List of usage examples for org.apache.maven.project.validation DefaultModelValidator DefaultModelValidator
DefaultModelValidator
From source file:org.codehaus.mojo.pomtools.wrapper.custom.ProjectWrapper.java
License:Apache License
public ProjectValidationResult validateModel(Model model) { try {//from w w w .ja v a2 s.co m return new ProjectValidationResult(this, new DefaultModelValidator().validate(model)); } catch (Exception e) { throw new PomToolsRTException(e); } }
From source file:org.codehaus.mojo.stage2.MetadataMerger.java
License:Apache License
private Model fromPomFile(final File pom) throws IOException { final XmlStreamReader xmlReader = ReaderFactory.newXmlReader(pom); final Model model; try {/* w ww . jav a 2s .c o m*/ model = new MavenXpp3Reader().read(xmlReader); } catch (XmlPullParserException e) { throw new IOException("Could not create model from " + pom, e); } finally { xmlReader.close(); } final Parent parent = model.getParent(); String groupId = model.getGroupId() == null ? parent.getGroupId() : model.getGroupId(); String artifactId = model.getArtifactId(); String version = model.getVersion() == null ? parent.getVersion() : model.getVersion(); String packaging = model.getPackaging(); final Model newModel = generateModel(groupId, artifactId, version, packaging); System.err.println("XXXXX" + newModel); ModelValidator validator = new DefaultModelValidator(); System.err.println("YYYY" + validator); ModelValidationResult validationResult = validator.validate(newModel); if (validationResult.getMessageCount() > 0) { throw new IOException(validationResult.toString()); } return newModel; }