use of org.apache.maven.model.Parent in project unleash-maven-plugin by shillner.
the class PomUtilTest method testSetParentVersion.
@Test
public void testSetParentVersion() throws Exception {
URL url = getClass().getResource(getClass().getSimpleName() + "/pom1.xml");
File source;
try {
source = new File(url.toURI());
} catch (URISyntaxException e) {
source = new File(url.getPath());
}
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document document = builder.parse(source);
Model model = new Model();
model.setGroupId("com.itemis.maven.plugins");
model.setArtifactId("test-project-1");
model.setVersion("1");
Parent parent = new Parent();
parent.setGroupId("com.itemis");
parent.setArtifactId("org-parent");
parent.setVersion("1");
model.setParent(parent);
String newVersion = "2";
PomUtil.setParentVersion(model, document, newVersion);
Assert.assertEquals(newVersion, getNode(document.getDocumentElement(), "parent/version").getTextContent());
Assert.assertEquals(newVersion, model.getParent().getVersion());
}
use of org.apache.maven.model.Parent in project unleash-maven-plugin by shillner.
the class SetNextDevVersion method setParentVersion.
private void setParentVersion(MavenProject project, Document document) {
Parent parent = project.getModel().getParent();
if (parent != null) {
Map<ReleasePhase, ArtifactCoordinates> coordinatesByPhase = this.metadata.getArtifactCoordinatesByPhase(parent.getGroupId(), parent.getArtifactId());
ArtifactCoordinates oldCoordinates = coordinatesByPhase.get(ReleasePhase.RELEASE);
ArtifactCoordinates newCoordinates = coordinatesByPhase.get(ReleasePhase.POST_RELEASE);
// for it
if (newCoordinates != null) {
this.log.debug("\t\tUpdate of parent version of module '" + project.getGroupId() + ":" + project.getArtifact() + "' [" + oldCoordinates.getVersion() + " => " + newCoordinates.getVersion() + "]");
PomUtil.setParentVersion(project.getModel(), document, newCoordinates.getVersion());
}
}
}
use of org.apache.maven.model.Parent in project unleash-maven-plugin by shillner.
the class SetReleaseVersions method setParentVersion.
private void setParentVersion(MavenProject project, Document document) {
Parent parent = project.getModel().getParent();
if (parent != null) {
Map<ReleasePhase, ArtifactCoordinates> coordinatesByPhase = this.metadata.getArtifactCoordinatesByPhase(parent.getGroupId(), parent.getArtifactId());
ArtifactCoordinates oldCoordinates = coordinatesByPhase.get(ReleasePhase.PRE_RELEASE);
ArtifactCoordinates newCoordinates = coordinatesByPhase.get(ReleasePhase.RELEASE);
// for it
if (newCoordinates != null) {
this.log.debug("\tUpdate of parent version of module '" + project.getGroupId() + ":" + project.getArtifact() + "' [" + oldCoordinates.getVersion() + " => " + newCoordinates.getVersion() + "]");
PomUtil.setParentVersion(project.getModel(), document, newCoordinates.getVersion());
}
}
}
use of org.apache.maven.model.Parent in project maven-plugins by apache.
the class InstallMojo method copyParentPoms.
/**
* Installs all parent POMs of the specified POM file that are available in the local repository.
*
* @param pomFile The path to the POM file whose parents should be installed, must not be <code>null</code>.
* @throws MojoExecutionException If any (existing) parent POM could not be installed.
*/
private void copyParentPoms(File pomFile) throws MojoExecutionException {
Model model = PomUtils.loadPom(pomFile);
Parent parent = model.getParent();
if (parent != null) {
copyParentPoms(parent.getGroupId(), parent.getArtifactId(), parent.getVersion());
}
}
use of org.apache.maven.model.Parent in project maven-plugins by apache.
the class DeployFileMojoUnitTest method setUp.
public void setUp() {
Model pomModel = new Model();
pomModel.setPackaging(null);
parent = new Parent();
parent.setGroupId("parentGroup");
parent.setArtifactId("parentArtifact");
parent.setVersion("parentVersion");
mojo = new MockDeployFileMojo(pomModel);
}
Aggregations