Search in sources :

Example 21 with Parent

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());
}
Also used : DocumentBuilder(javax.xml.parsers.DocumentBuilder) Parent(org.apache.maven.model.Parent) Model(org.apache.maven.model.Model) URISyntaxException(java.net.URISyntaxException) Document(org.w3c.dom.Document) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Example 22 with Parent

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());
        }
    }
}
Also used : Parent(org.apache.maven.model.Parent) ReleasePhase(com.itemis.maven.plugins.unleash.ReleasePhase) ArtifactCoordinates(com.itemis.maven.aether.ArtifactCoordinates)

Example 23 with Parent

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());
        }
    }
}
Also used : Parent(org.apache.maven.model.Parent) ReleasePhase(com.itemis.maven.plugins.unleash.ReleasePhase) ArtifactCoordinates(com.itemis.maven.aether.ArtifactCoordinates)

Example 24 with Parent

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());
    }
}
Also used : Parent(org.apache.maven.model.Parent) Model(org.apache.maven.model.Model)

Example 25 with Parent

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);
}
Also used : Parent(org.apache.maven.model.Parent) Model(org.apache.maven.model.Model)

Aggregations

Parent (org.apache.maven.model.Parent)26 Model (org.apache.maven.model.Model)13 Build (org.apache.maven.model.Build)5 File (java.io.File)4 Properties (java.util.Properties)4 Test (org.junit.Test)4 Artifact (org.apache.maven.artifact.Artifact)3 Dependency (org.apache.maven.model.Dependency)3 SimpleProjectVersionRef (org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef)3 ArtifactCoordinates (com.itemis.maven.aether.ArtifactCoordinates)2 ReleasePhase (com.itemis.maven.plugins.unleash.ReleasePhase)2 THashMap (gnu.trove.THashMap)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 DependencyManagement (org.apache.maven.model.DependencyManagement)2 ProjectVersionRef (org.commonjava.maven.atlas.ident.ref.ProjectVersionRef)2 MavenKey (org.eclipse.che.maven.data.MavenKey)2 MavenModel (org.eclipse.che.maven.data.MavenModel)2