Search in sources :

Example 16 with MutableBundleManifest

use of org.eclipse.tycho.versions.bundle.MutableBundleManifest in project tycho by eclipse.

the class MutableBundleManifestTest method updateRequiredBundleVersions.

@Test
public void updateRequiredBundleVersions() throws IOException {
    MutableBundleManifest mf = getManifest("/manifests/updateRequiredBundleVersions.mf");
    Map<String, String> requiredBundleVersionChanges = new HashMap<>();
    requiredBundleVersionChanges.put("bundle1", "1.0.1");
    requiredBundleVersionChanges.put("bundle2", "1.1.1");
    mf.updateRequiredBundleVersions(requiredBundleVersionChanges);
    assertContents(mf, "/manifests/updateRequiredBundleVersions.mf_expected");
}
Also used : HashMap(java.util.HashMap) MutableBundleManifest(org.eclipse.tycho.versions.bundle.MutableBundleManifest) MutablePomFileTest(org.eclipse.tycho.versions.pom.tests.MutablePomFileTest) Test(org.junit.Test)

Example 17 with MutableBundleManifest

use of org.eclipse.tycho.versions.bundle.MutableBundleManifest 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 18 with MutableBundleManifest

use of org.eclipse.tycho.versions.bundle.MutableBundleManifest 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 19 with MutableBundleManifest

use of org.eclipse.tycho.versions.bundle.MutableBundleManifest 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)19 MutablePomFileTest (org.eclipse.tycho.versions.pom.tests.MutablePomFileTest)11 Test (org.junit.Test)11 HashMap (java.util.HashMap)8 PackageVersionChange (org.eclipse.tycho.versions.engine.PackageVersionChange)5 PomVersionChange (org.eclipse.tycho.versions.engine.PomVersionChange)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 InputStream (java.io.InputStream)4 VersionChange (org.eclipse.tycho.versions.engine.VersionChange)4 File (java.io.File)1 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 ManifestAttribute (org.eclipse.tycho.versions.bundle.ManifestAttribute)1