Search in sources :

Example 1 with VersionChange

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

the class BundleManifestManipulator method findVersionChangeForProject.

private VersionChange findVersionChangeForProject(ProjectMetadata project, VersionChangesDescriptor versionChangeContext) {
    MutableBundleManifest mf = getBundleManifest(project);
    VersionChange versionChangeForProject = versionChangeContext.findVersionChangeByArtifactId(mf.getSymbolicName());
    if (versionChangeForProject != null && versionChangeForProject.getVersion().equals(mf.getVersion())) {
        return versionChangeForProject;
    } else {
        return null;
    }
}
Also used : VersionChange(org.eclipse.tycho.versions.engine.VersionChange) PomVersionChange(org.eclipse.tycho.versions.engine.PomVersionChange) PackageVersionChange(org.eclipse.tycho.versions.engine.PackageVersionChange) MutableBundleManifest(org.eclipse.tycho.versions.bundle.MutableBundleManifest)

Example 2 with VersionChange

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

the class BundleManifestManipulator method updateBundleAndExportPackageVersions.

private void updateBundleAndExportPackageVersions(ProjectMetadata project, VersionChangesDescriptor versionChangeContext) {
    MutableBundleManifest mf = getBundleManifest(project);
    VersionChange versionChangeForProject = findVersionChangeForProject(project, versionChangeContext);
    if (versionChangeForProject != null) {
        logger.info("  META-INF/MANIFEST.MF//Bundle-Version: " + versionChangeForProject.getVersion() + " => " + versionChangeForProject.getNewVersion());
        mf.setVersion(versionChangeForProject.getNewVersion());
        Map<String, String> exportPackagesNewVersion = new HashMap<>();
        for (PackageVersionChange packageVersionChange : versionChangeContext.getPackageVersionChanges()) {
            if (packageVersionChange.getBundleSymbolicName().equals(mf.getSymbolicName())) {
                logger.info("  META-INF/MANIFEST.MF//Export-Package//" + packageVersionChange.getPackageName() + ";version: " + packageVersionChange.getVersion() + " => " + packageVersionChange.getNewVersion());
                exportPackagesNewVersion.put(packageVersionChange.getPackageName(), packageVersionChange.getNewVersion());
            }
        }
        mf.updateExportedPackageVersions(exportPackagesNewVersion);
    }
}
Also used : PackageVersionChange(org.eclipse.tycho.versions.engine.PackageVersionChange) VersionChange(org.eclipse.tycho.versions.engine.VersionChange) PomVersionChange(org.eclipse.tycho.versions.engine.PomVersionChange) PackageVersionChange(org.eclipse.tycho.versions.engine.PackageVersionChange) HashMap(java.util.HashMap) MutableBundleManifest(org.eclipse.tycho.versions.bundle.MutableBundleManifest)

Example 3 with VersionChange

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

the class P2iuXmlManipulator method applyChanges.

@Override
public void applyChanges(ProjectMetadata project, VersionChangesDescriptor versionChangeContext) {
    if (!isIu(project)) {
        return;
    }
    IU iu = getIU(project);
    VersionChange change = versionChangeContext.findVersionChangeByArtifactId(iu.getId());
    if (change != null && change.getVersion().equals(iu.getVersion())) {
        logger.info("  p2iu.xml//unit/@version: " + change.getVersion() + " => " + change.getNewVersion());
        iu.setVersion(change.getNewVersion());
        // version changed, so put the iu into the metadata so that the writeMetadata method can pick it up
        project.putMetadata(iu);
    }
}
Also used : VersionChange(org.eclipse.tycho.versions.engine.VersionChange) IU(org.eclipse.tycho.model.IU)

Example 4 with VersionChange

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

the class BundleManifestManipulator method updateFragmentHostVersion.

private void updateFragmentHostVersion(ProjectMetadata project, VersionChangesDescriptor versionChangeContext) {
    MutableBundleManifest mf = getBundleManifest(project);
    if (mf.isFragment()) {
        VersionChange versionChange = versionChangeContext.findVersionChangeByArtifactId(mf.getFragmentHostSymbolicName());
        if (versionChange != null) {
            String newVersionRange = versionChangeContext.getVersionRangeUpdateStrategy().computeNewVersionRange(mf.getFragmentHostVersion(), versionChange.getVersion(), versionChange.getNewVersion());
            logger.info("  META-INF/MANIFEST.MF//Fragment-Host//" + mf.getFragmentHostSymbolicName() + ";bundle-version: " + newVersionRange + " => " + newVersionRange);
            mf.setFragmentHostVersion(newVersionRange);
        }
    }
}
Also used : VersionChange(org.eclipse.tycho.versions.engine.VersionChange) PomVersionChange(org.eclipse.tycho.versions.engine.PomVersionChange) PackageVersionChange(org.eclipse.tycho.versions.engine.PackageVersionChange) MutableBundleManifest(org.eclipse.tycho.versions.bundle.MutableBundleManifest)

Example 5 with VersionChange

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

the class BundleManifestManipulator method computeExportedPackageChanges.

private Set<PackageVersionChange> computeExportedPackageChanges(ProjectMetadata project, VersionChangesDescriptor versionChangeContext) {
    VersionChange versionChangeForProject = findVersionChangeForProject(project, versionChangeContext);
    if (versionChangeForProject == null) {
        return Collections.emptySet();
    }
    MutableBundleManifest mf = getBundleManifest(project);
    // ignore ".qualifier" literals in package versions
    String versionToReplace = Versions.toBaseVersion(versionChangeForProject.getVersion());
    String newVersion = Versions.toBaseVersion(versionChangeForProject.getNewVersion());
    Set<PackageVersionChange> packageVersionChanges = new HashSet<>();
    for (Entry<String, String> exportedPackageVersion : mf.getExportedPackagesVersion().entrySet()) {
        String packageName = exportedPackageVersion.getKey();
        String packageVersion = exportedPackageVersion.getValue();
        if (packageVersion != null && packageVersion.equals(versionToReplace)) {
            packageVersionChanges.add(new PackageVersionChange(mf.getSymbolicName(), packageName, packageVersion, newVersion));
        }
    }
    return packageVersionChanges;
}
Also used : PackageVersionChange(org.eclipse.tycho.versions.engine.PackageVersionChange) VersionChange(org.eclipse.tycho.versions.engine.VersionChange) PomVersionChange(org.eclipse.tycho.versions.engine.PomVersionChange) PackageVersionChange(org.eclipse.tycho.versions.engine.PackageVersionChange) MutableBundleManifest(org.eclipse.tycho.versions.bundle.MutableBundleManifest) HashSet(java.util.HashSet)

Aggregations

VersionChange (org.eclipse.tycho.versions.engine.VersionChange)5 MutableBundleManifest (org.eclipse.tycho.versions.bundle.MutableBundleManifest)4 PackageVersionChange (org.eclipse.tycho.versions.engine.PackageVersionChange)4 PomVersionChange (org.eclipse.tycho.versions.engine.PomVersionChange)4 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 IU (org.eclipse.tycho.model.IU)1