use of org.apache.maven.model.Parent in project maven-archetype by apache.
the class DefaultPomManager method addParent.
public void addParent(File pom, File parentPom) throws IOException, XmlPullParserException {
Model generatedModel = readPom(pom);
if (null != generatedModel.getParent()) {
getLogger().info("Parent element not overwritten in " + pom);
return;
}
Model parentModel = readPom(parentPom);
Parent parent = new Parent();
parent.setGroupId(parentModel.getGroupId());
if (parent.getGroupId() == null) {
parent.setGroupId(parentModel.getParent().getGroupId());
}
parent.setArtifactId(parentModel.getArtifactId());
parent.setVersion(parentModel.getVersion());
if (parent.getVersion() == null) {
parent.setVersion(parentModel.getParent().getVersion());
}
generatedModel.setParent(parent);
writePom(generatedModel, pom, pom);
}
Aggregations