Search in sources :

Example 1 with MutableBundleManifest

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

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

the class BundleManifestManipulator method getBundleManifest.

private MutableBundleManifest getBundleManifest(ProjectMetadata project) {
    MutableBundleManifest mf = project.getMetadata(MutableBundleManifest.class);
    if (mf == null) {
        File file = getManifestFile(project);
        try {
            mf = MutableBundleManifest.read(file);
        } catch (IOException e) {
            throw new IllegalArgumentException("Could not parse bundle manifest " + file, e);
        }
        project.putMetadata(mf);
    }
    return mf;
}
Also used : MutableBundleManifest(org.eclipse.tycho.versions.bundle.MutableBundleManifest) IOException(java.io.IOException) File(java.io.File)

Example 3 with MutableBundleManifest

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

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

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

the class MutableBundleManifestTest method updateImportedPackageVersions.

@Test
public void updateImportedPackageVersions() throws IOException {
    MutableBundleManifest mf = getManifest("/manifests/updateImportedPackageVersions.mf");
    Map<String, String> importPackageVersionChanges = new HashMap<>();
    importPackageVersionChanges.put("com.package1", "1.0.1");
    importPackageVersionChanges.put("com.package2", "1.1.1");
    mf.updateImportedPackageVersions(importPackageVersionChanges);
    assertContents(mf, "/manifests/updateImportedPackageVersions.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)

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