Search in sources :

Example 1 with PomVersionChange

use of org.eclipse.tycho.versions.engine.PomVersionChange in project tycho by eclipse.

the class BundleManifestManipulator method updateRequireBundleVersions.

private void updateRequireBundleVersions(ProjectMetadata project, VersionChangesDescriptor versionChangeContext) {
    MutableBundleManifest mf = getBundleManifest(project);
    Map<String, String> requiredBundleVersions = mf.getRequiredBundleVersions();
    Map<String, String> versionsToUpdate = new HashMap<>();
    for (PomVersionChange versionChange : versionChangeContext.getVersionChanges()) {
        String bundleSymbolicName = versionChange.getArtifactId();
        if (requiredBundleVersions.containsKey(bundleSymbolicName)) {
            String originalVersionRange = requiredBundleVersions.get(bundleSymbolicName);
            versionsToUpdate.put(bundleSymbolicName, versionChangeContext.getVersionRangeUpdateStrategy().computeNewVersionRange(originalVersionRange, versionChange.getVersion(), versionChange.getNewVersion()));
        }
    }
    mf.updateRequiredBundleVersions(versionsToUpdate);
}
Also used : HashMap(java.util.HashMap) MutableBundleManifest(org.eclipse.tycho.versions.bundle.MutableBundleManifest) PomVersionChange(org.eclipse.tycho.versions.engine.PomVersionChange)

Example 2 with PomVersionChange

use of org.eclipse.tycho.versions.engine.PomVersionChange in project tycho by eclipse.

the class FeatureXmlManipulator method applyChanges.

@Override
public void applyChanges(ProjectMetadata project, VersionChangesDescriptor versionChangeContext) {
    if (isFeature(project)) {
        Feature feature = getFeatureXml(project);
        for (PomVersionChange change : versionChangeContext.getVersionChanges()) {
            if (isFeature(change.getProject().getPackaging())) {
                if (change.getArtifactId().equals(feature.getId()) && change.getVersion().equals(feature.getVersion())) {
                    logger.info("  feature.xml//feature/@version: " + change.getVersion() + " => " + change.getNewVersion());
                    feature.setVersion(change.getNewVersion());
                }
                changeLicenseFeature(change, feature);
                // could be included feature
                changeIncludedFeatures(change, feature);
                changeRequiredFeatures(change, feature, versionChangeContext.getVersionRangeUpdateStrategy());
            } else if (isBundle(change.getProject())) {
                changeIncludedPlugins(change, feature);
                changeRequiredPlugins(change, feature, versionChangeContext.getVersionRangeUpdateStrategy());
            }
        }
    }
}
Also used : Feature(org.eclipse.tycho.model.Feature) PomVersionChange(org.eclipse.tycho.versions.engine.PomVersionChange)

Example 3 with PomVersionChange

use of org.eclipse.tycho.versions.engine.PomVersionChange 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 4 with PomVersionChange

use of org.eclipse.tycho.versions.engine.PomVersionChange 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 5 with PomVersionChange

use of org.eclipse.tycho.versions.engine.PomVersionChange in project tycho by eclipse.

the class SiteXmlManipulator method applyChanges.

@Override
public void applyChanges(ProjectMetadata project, VersionChangesDescriptor versionChangeContext) {
    if (isSite(project)) {
        for (PomVersionChange change : versionChangeContext.getVersionChanges()) {
            if (isFeature(change.getProject().getPackaging())) {
                UpdateSite site = getSiteXml(project);
                for (FeatureRef feature : site.getFeatures()) {
                    if (change.getArtifactId().equals(feature.getId()) && change.getVersion().equals(feature.getVersion())) {
                        logger.info("  site.xml//site/feature/@id=" + feature.getId() + "/@version: " + change.getVersion() + " => " + change.getNewVersion());
                        feature.setVersion(change.getNewVersion());
                        SiteFeatureRef siteFeature = (SiteFeatureRef) feature;
                        String oldUrl = siteFeature.getUrl();
                        String newUrl = rewriteFeatureUrl(oldUrl, change);
                        logger.info("  site.xml//site/feature/@id=" + feature.getId() + "/@url: " + oldUrl + " => " + newUrl);
                        siteFeature.setUrl(newUrl);
                    }
                }
            }
        }
    }
}
Also used : SiteFeatureRef(org.eclipse.tycho.model.UpdateSite.SiteFeatureRef) SiteFeatureRef(org.eclipse.tycho.model.UpdateSite.SiteFeatureRef) FeatureRef(org.eclipse.tycho.model.FeatureRef) UpdateSite(org.eclipse.tycho.model.UpdateSite) PomVersionChange(org.eclipse.tycho.versions.engine.PomVersionChange)

Aggregations

PomVersionChange (org.eclipse.tycho.versions.engine.PomVersionChange)5 GAV (org.eclipse.tycho.versions.pom.GAV)2 PomFile (org.eclipse.tycho.versions.pom.PomFile)2 HashMap (java.util.HashMap)1 Feature (org.eclipse.tycho.model.Feature)1 FeatureRef (org.eclipse.tycho.model.FeatureRef)1 UpdateSite (org.eclipse.tycho.model.UpdateSite)1 SiteFeatureRef (org.eclipse.tycho.model.UpdateSite.SiteFeatureRef)1 MutableBundleManifest (org.eclipse.tycho.versions.bundle.MutableBundleManifest)1 Profile (org.eclipse.tycho.versions.pom.Profile)1