Search in sources :

Example 1 with GAV

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

the class PomManipulator method changeDependencies.

protected void changeDependencies(String pomPath, List<GAV> dependencies, PomVersionChange change, String version, String newVersion) {
    for (GAV dependency : dependencies) {
        if (isGavEquals(dependency, change)) {
            logger.info(pomPath + "/dependency/[ " + dependency.getGroupId() + ":" + dependency.getArtifactId() + " ] " + version + " => " + newVersion);
            dependency.setVersion(newVersion);
        }
    }
}
Also used : GAV(org.eclipse.tycho.versions.pom.GAV)

Example 2 with GAV

use of org.eclipse.tycho.versions.pom.GAV 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 3 with GAV

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

Example 4 with GAV

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

the class PomManipulator method changePlugins.

// change version of list of GAV in a plugin
private void changePlugins(String pomPath, GAV pluginGAV, PomVersionChange change, String version, String newVersion, String subPath, List<GAV> gavs) {
    for (GAV targetArtifact : gavs) {
        if (isGavEquals(targetArtifact, change)) {
            logger.info(pomPath + "/[ " + pluginGAV.getGroupId() + ":" + pluginGAV.getArtifactId() + " ] " + subPath + "[ " + targetArtifact.getGroupId() + ":" + targetArtifact.getArtifactId() + " ] " + version + " => " + newVersion);
            targetArtifact.setVersion(newVersion);
        }
    }
}
Also used : GAV(org.eclipse.tycho.versions.pom.GAV)

Example 5 with GAV

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

the class PomManipulator method changePlugins.

private void changePlugins(String pomPath, List<Plugin> plugins, PomVersionChange change, String version, String newVersion) {
    for (Plugin plugin : plugins) {
        GAV pluginGAV = plugin.getGAV();
        if (isPluginGavEquals(pluginGAV, change)) {
            logger.info(pomPath + "/[ " + pluginGAV.getGroupId() + ":" + pluginGAV.getArtifactId() + " ] " + version + " => " + newVersion);
            pluginGAV.setVersion(newVersion);
        }
        changePlugins(pomPath, pluginGAV, change, version, newVersion, "/dependencies/dependency/", plugin.getDependencies());
        changePlugins(pomPath, pluginGAV, change, version, newVersion, "/configuration/target/artifact/", plugin.getTargetArtifacts());
    }
}
Also used : GAV(org.eclipse.tycho.versions.pom.GAV) Plugin(org.eclipse.tycho.versions.pom.Plugin)

Aggregations

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