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;
}
}
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;
}
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);
}
}
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);
}
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");
}
Aggregations