Search in sources :

Example 1 with Profile

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

the class PomManipulator method applyPropertyChange.

public void applyPropertyChange(PomFile pom, String propertyName, String propertyValue) {
    changeProperties("  pom.xml//project/properties", pom.getProperties(), propertyName, propertyValue);
    for (Profile profile : pom.getProfiles()) {
        String pomPath = "  pom.xml//project/profiles/profile[ " + profile.getId() + " ]/properties";
        changeProperties(pomPath, profile.getProperties(), propertyName, propertyValue);
    }
}
Also used : Profile(org.eclipse.tycho.versions.pom.Profile)

Example 2 with Profile

use of org.eclipse.tycho.versions.pom.Profile 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)

Aggregations

Profile (org.eclipse.tycho.versions.pom.Profile)2 PomVersionChange (org.eclipse.tycho.versions.engine.PomVersionChange)1 GAV (org.eclipse.tycho.versions.pom.GAV)1 PomFile (org.eclipse.tycho.versions.pom.PomFile)1