Search in sources :

Example 1 with PomFile

use of org.eclipse.tycho.versions.pom.PomFile in project unleash-maven-plugin by shillner.

the class AbstractTychoVersionsStep method adaptProjectMetadataWithNewVersions.

private void adaptProjectMetadataWithNewVersions() {
    // this needs to be done in order to make the changes reversible
    // if the metadata is not adapted reverting the changes wouldn't be possible for pom-less builds since the metadata
    // is initialized only once before the build starts
    this.metadataReader.getProjects().forEach(data -> {
        PomFile pom = data.getMetadata(PomFile.class);
        Map<ReleasePhase, ArtifactCoordinates> coordinatesByPhase = this.metadata.getArtifactCoordinatesByPhase(pom.getGroupId(), pom.getArtifactId());
        String version = coordinatesByPhase.get(currentReleasePhase()).getVersion();
        pom.setVersion(version);
    });
}
Also used : PomFile(org.eclipse.tycho.versions.pom.PomFile) ReleasePhase(com.itemis.maven.plugins.unleash.ReleasePhase) ArtifactCoordinates(com.itemis.maven.aether.ArtifactCoordinates) ProjectToString(com.itemis.maven.plugins.unleash.util.functions.ProjectToString)

Example 2 with PomFile

use of org.eclipse.tycho.versions.pom.PomFile in project tycho by eclipse.

the class MutablePomFileTest method testCompileMessage.

@Test(expected = XMLParseException.class)
public void testCompileMessage() throws Exception {
    File pomFile = null;
    try {
        URL url = getClass().getResource("/poms/compilemessage.xml");
        pomFile = new File(url.toURI());
        PomFile.read(pomFile, true);
    } catch (Exception pe) {
        Assert.assertEquals("This Pom " + pomFile.getAbsolutePath() + " is in the Wrong Format", pe.getMessage());
        throw pe;
    }
}
Also used : PomFile(org.eclipse.tycho.versions.pom.PomFile) File(java.io.File) URL(java.net.URL) IOException(java.io.IOException) XMLParseException(de.pdark.decentxml.XMLParseException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Test(org.junit.Test)

Example 3 with PomFile

use of org.eclipse.tycho.versions.pom.PomFile in project tycho by eclipse.

the class VersionsEngine method addPropertyChange.

public void addPropertyChange(String artifactId, String propertyName, String propertyValue) throws IOException {
    PomFile pom = getMutablePom(artifactId);
    propertyChanges.add(new PropertyChange(pom, propertyName, propertyValue));
}
Also used : PomFile(org.eclipse.tycho.versions.pom.PomFile)

Example 4 with PomFile

use of org.eclipse.tycho.versions.pom.PomFile in project tycho by eclipse.

the class PomManipulator method applyChanges.

@Override
public void applyChanges(ProjectMetadata project, VersionChangesDescriptor versionChangeContext) {
    PomFile pom = project.getMetadata(PomFile.class);
    // e.g. not for polyglot pom files
    if (!pom.isMutable()) {
        return;
    }
    for (PomVersionChange change : versionChangeContext.getVersionChanges()) {
        String version = Versions.toMavenVersion(change.getVersion());
        String newVersion = Versions.toMavenVersion(change.getNewVersion());
        if (isGavEquals(pom, change)) {
            logger.info("  pom.xml//project/version: " + version + " => " + newVersion);
            pom.setVersion(newVersion);
        } else {
            GAV parent = pom.getParent();
            if (parent != null && isGavEquals(parent, change)) {
                logger.info("  pom.xml//project/parent/version: " + version + " => " + newVersion);
                parent.setVersion(newVersion);
            }
        }
        // 
        // Dependencies and entries inside dependencyManagement sections are not
        // OSGI related. Nevertheless it might happen that dependencies like this
        // does occur inside OSGI related project. Hence we must be able to handle
        // it.
        // 
        changeDependencies("  pom.xml//project/dependencies", pom.getDependencies(), change, version, newVersion);
        changeDependencyManagement("  pom.xml//project/dependencyManagement", pom.getDependencyManagement(), change, version, newVersion);
        changeBuild("  pom.xml//project/build", pom.getBuild(), change, version, newVersion);
        for (Profile profile : pom.getProfiles()) {
            String profileId = profile.getId() != null ? profile.getId() : "<null>";
            String pomPath = "  pom.xml//project/profiles/profile[ " + profileId + " ]";
            changeDependencies(pomPath + "/dependencies", profile.getDependencies(), change, version, newVersion);
            changeDependencyManagement(pomPath + "/dependencyManagement", profile.getDependencyManagement(), change, version, newVersion);
            changeBuild(pomPath + "/build", profile.getBuild(), change, version, newVersion);
        }
    }
}
Also used : PomFile(org.eclipse.tycho.versions.pom.PomFile) GAV(org.eclipse.tycho.versions.pom.GAV) PomVersionChange(org.eclipse.tycho.versions.engine.PomVersionChange) Profile(org.eclipse.tycho.versions.pom.Profile)

Example 5 with PomFile

use of org.eclipse.tycho.versions.pom.PomFile in project tycho by eclipse.

the class PomManipulator method addMoreChanges.

@Override
public boolean addMoreChanges(ProjectMetadata project, VersionChangesDescriptor versionChangeContext) {
    PomFile pom = project.getMetadata(PomFile.class);
    GAV parent = pom.getParent();
    boolean moreChanges = false;
    for (PomVersionChange change : versionChangeContext.getVersionChanges()) {
        if (parent != null && isGavEquals(parent, change)) {
            if (isVersionEquals(pom.getVersion(), change.getVersion())) {
                moreChanges |= versionChangeContext.addVersionChange(new PomVersionChange(pom, change.getVersion(), change.getNewVersion()));
            }
        }
    }
    return moreChanges;
}
Also used : PomFile(org.eclipse.tycho.versions.pom.PomFile) GAV(org.eclipse.tycho.versions.pom.GAV) PomVersionChange(org.eclipse.tycho.versions.engine.PomVersionChange)

Aggregations

PomFile (org.eclipse.tycho.versions.pom.PomFile)10 File (java.io.File)4 PomVersionChange (org.eclipse.tycho.versions.engine.PomVersionChange)2 GAV (org.eclipse.tycho.versions.pom.GAV)2 ArtifactCoordinates (com.itemis.maven.aether.ArtifactCoordinates)1 ReleasePhase (com.itemis.maven.plugins.unleash.ReleasePhase)1 ProjectToString (com.itemis.maven.plugins.unleash.util.functions.ProjectToString)1 XMLParseException (de.pdark.decentxml.XMLParseException)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 PomManipulator (org.eclipse.tycho.versions.manipulation.PomManipulator)1 Profile (org.eclipse.tycho.versions.pom.Profile)1 ProductFileFilter (org.eclipse.tycho.versions.utils.ProductFileFilter)1 Test (org.junit.Test)1