Search in sources :

Example 1 with PackageVersionChange

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

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

Example 3 with PackageVersionChange

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

the class BundleManifestManipulator method updateImportPackageVersions.

private void updateImportPackageVersions(ProjectMetadata project, VersionChangesDescriptor versionChangeContext) {
    MutableBundleManifest mf = getBundleManifest(project);
    Map<String, String> importedPackageNewVersions = new HashMap<>();
    for (Entry<String, String> importPackageVersions : mf.getImportPackagesVersions().entrySet()) {
        String packageName = importPackageVersions.getKey();
        String importVersionRange = importPackageVersions.getValue();
        if (importVersionRange != null) {
            PackageVersionChange versionChange = versionChangeContext.findPackageVersionChange(packageName);
            if (versionChange != null) {
                String newVersionRange = versionChangeContext.getVersionRangeUpdateStrategy().computeNewVersionRange(importVersionRange, versionChange.getVersion(), versionChange.getNewVersion());
                logger.info("  META-INF/MANIFEST.MF//Import-Package//" + packageName + ";version: " + importVersionRange + " => " + newVersionRange);
                importedPackageNewVersions.put(packageName, newVersionRange);
            }
        }
    }
    mf.updateImportedPackageVersions(importedPackageNewVersions);
}
Also used : PackageVersionChange(org.eclipse.tycho.versions.engine.PackageVersionChange) HashMap(java.util.HashMap) MutableBundleManifest(org.eclipse.tycho.versions.bundle.MutableBundleManifest)

Aggregations

MutableBundleManifest (org.eclipse.tycho.versions.bundle.MutableBundleManifest)3 PackageVersionChange (org.eclipse.tycho.versions.engine.PackageVersionChange)3 HashMap (java.util.HashMap)2 PomVersionChange (org.eclipse.tycho.versions.engine.PomVersionChange)2 VersionChange (org.eclipse.tycho.versions.engine.VersionChange)2 HashSet (java.util.HashSet)1