From e029f5a078f92f5366a015207f49ac40e1f10860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Thu, 15 Aug 2024 20:29:23 +0200 Subject: [PATCH] Move MutableBundleManifest into the tycho-model module for reuse (cherry picked from commit 46d4640e051175a8a6f3d7fb5ccadd6797624cf2) --- .../org/eclipse/tycho/model/manifest}/ManifestAttribute.java | 2 +- .../eclipse/tycho/model/manifest}/MutableBundleManifest.java | 4 +--- .../eclipse/tycho/model/manifest}/MutableManifestElement.java | 2 +- .../org/eclipse/tycho/versions/bundle/MutableBndFile.java | 2 ++ .../org/eclipse/tycho/versions/engine/VersionUpdater.java | 2 +- .../versions/manipulation/BundleManifestManipulator.java | 4 ++-- .../tycho/versions/bundle/tests/ManifestAttributeTest.java | 2 +- .../versions/bundle/tests/MutableBundleManifestTest.java | 4 ++-- .../versions/bundle/tests/MutableManifestElementTest.java | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) rename {tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle => tycho-metadata-model/src/main/java/org/eclipse/tycho/model/manifest}/ManifestAttribute.java (98%) rename {tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle => tycho-metadata-model/src/main/java/org/eclipse/tycho/model/manifest}/MutableBundleManifest.java (98%) rename {tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle => tycho-metadata-model/src/main/java/org/eclipse/tycho/model/manifest}/MutableManifestElement.java (99%) diff --git a/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle/ManifestAttribute.java b/tycho-metadata-model/src/main/java/org/eclipse/tycho/model/manifest/ManifestAttribute.java similarity index 98% rename from tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle/ManifestAttribute.java rename to tycho-metadata-model/src/main/java/org/eclipse/tycho/model/manifest/ManifestAttribute.java index c0dccb9b57..2afb5ef4e5 100644 --- a/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle/ManifestAttribute.java +++ b/tycho-metadata-model/src/main/java/org/eclipse/tycho/model/manifest/ManifestAttribute.java @@ -11,7 +11,7 @@ * Sonatype Inc. - initial API and implementation * Sebastien Arod - add setter with {@link MutableManifestElement} *******************************************************************************/ -package org.eclipse.tycho.versions.bundle; +package org.eclipse.tycho.model.manifest; import java.io.IOException; import java.io.Writer; diff --git a/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle/MutableBundleManifest.java b/tycho-metadata-model/src/main/java/org/eclipse/tycho/model/manifest/MutableBundleManifest.java similarity index 98% rename from tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle/MutableBundleManifest.java rename to tycho-metadata-model/src/main/java/org/eclipse/tycho/model/manifest/MutableBundleManifest.java index e72ceaee35..a7789276ec 100644 --- a/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle/MutableBundleManifest.java +++ b/tycho-metadata-model/src/main/java/org/eclipse/tycho/model/manifest/MutableBundleManifest.java @@ -12,7 +12,7 @@ * Nepomuk Seiler - set export-package attribute implementation * Sebastien Arod - RequireBundle/FragmentHost/ImportPackage versions set/get *******************************************************************************/ -package org.eclipse.tycho.versions.bundle; +package org.eclipse.tycho.model.manifest; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; @@ -36,7 +36,6 @@ import java.util.function.Consumer; import org.eclipse.osgi.util.ManifestElement; -import org.eclipse.tycho.versions.engine.Versions; import org.osgi.framework.BundleException; import org.osgi.framework.Constants; @@ -191,7 +190,6 @@ public String getFragmentHostVersion() { } public void setFragmentHostVersion(String newVersion) { - newVersion = Versions.toBaseVersion(newVersion); List fragmentHostElements = parseHeaderForMutation(Constants.FRAGMENT_HOST); if (fragmentHostElements == null || fragmentHostElements.isEmpty()) { return; diff --git a/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle/MutableManifestElement.java b/tycho-metadata-model/src/main/java/org/eclipse/tycho/model/manifest/MutableManifestElement.java similarity index 99% rename from tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle/MutableManifestElement.java rename to tycho-metadata-model/src/main/java/org/eclipse/tycho/model/manifest/MutableManifestElement.java index 6adc9012ff..305f454078 100644 --- a/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle/MutableManifestElement.java +++ b/tycho-metadata-model/src/main/java/org/eclipse/tycho/model/manifest/MutableManifestElement.java @@ -10,7 +10,7 @@ * Contributors: * Sebastien Arod - Initial implementation *******************************************************************************/ -package org.eclipse.tycho.versions.bundle; +package org.eclipse.tycho.model.manifest; import java.util.ArrayList; import java.util.Arrays; diff --git a/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle/MutableBndFile.java b/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle/MutableBndFile.java index 2dc829ee12..e4ab12b40f 100644 --- a/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle/MutableBndFile.java +++ b/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle/MutableBndFile.java @@ -28,6 +28,8 @@ import java.util.List; import java.util.Objects; +import org.eclipse.tycho.model.manifest.MutableBundleManifest; + public class MutableBndFile { private final List bndLines = new ArrayList(); diff --git a/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/engine/VersionUpdater.java b/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/engine/VersionUpdater.java index 64af65d8ff..defe20f095 100644 --- a/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/engine/VersionUpdater.java +++ b/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/engine/VersionUpdater.java @@ -30,8 +30,8 @@ import org.eclipse.tycho.model.Feature; import org.eclipse.tycho.model.IU; import org.eclipse.tycho.model.ProductConfiguration; +import org.eclipse.tycho.model.manifest.MutableBundleManifest; import org.eclipse.tycho.versions.bundle.MutableBndFile; -import org.eclipse.tycho.versions.bundle.MutableBundleManifest; import org.eclipse.tycho.versions.pom.PomFile; import org.eclipse.tycho.versions.utils.ProductFileFilter; import org.osgi.framework.Constants; diff --git a/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/manipulation/BundleManifestManipulator.java b/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/manipulation/BundleManifestManipulator.java index 72a8ff13cd..1747fe9137 100644 --- a/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/manipulation/BundleManifestManipulator.java +++ b/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/manipulation/BundleManifestManipulator.java @@ -26,8 +26,8 @@ import org.codehaus.plexus.component.annotations.Component; import org.eclipse.tycho.TychoConstants; +import org.eclipse.tycho.model.manifest.MutableBundleManifest; import org.eclipse.tycho.versions.bundle.MutableBndFile; -import org.eclipse.tycho.versions.bundle.MutableBundleManifest; import org.eclipse.tycho.versions.engine.MetadataManipulator; import org.eclipse.tycho.versions.engine.PackageVersionChange; import org.eclipse.tycho.versions.engine.PomVersionChange; @@ -194,7 +194,7 @@ private void updateFragmentHostVersion(ProjectMetadata project, VersionChangesDe logger.info(" META-INF/MANIFEST.MF//Fragment-Host//" + mf.getFragmentHostSymbolicName() + ";bundle-version: " + newVersionRange + " => " + newVersionRange); - mf.setFragmentHostVersion(newVersionRange); + mf.setFragmentHostVersion(Versions.toBaseVersion(newVersionRange)); } } } diff --git a/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/bundle/tests/ManifestAttributeTest.java b/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/bundle/tests/ManifestAttributeTest.java index 4180b25f2a..a15e2932b9 100644 --- a/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/bundle/tests/ManifestAttributeTest.java +++ b/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/bundle/tests/ManifestAttributeTest.java @@ -17,7 +17,7 @@ import java.io.StringWriter; -import org.eclipse.tycho.versions.bundle.ManifestAttribute; +import org.eclipse.tycho.model.manifest.ManifestAttribute; import org.junit.Test; public class ManifestAttributeTest { diff --git a/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/bundle/tests/MutableBundleManifestTest.java b/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/bundle/tests/MutableBundleManifestTest.java index 26c3d59974..780efeda4b 100644 --- a/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/bundle/tests/MutableBundleManifestTest.java +++ b/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/bundle/tests/MutableBundleManifestTest.java @@ -21,8 +21,8 @@ import java.util.HashMap; import java.util.Map; -import org.eclipse.tycho.versions.bundle.ManifestAttribute; -import org.eclipse.tycho.versions.bundle.MutableBundleManifest; +import org.eclipse.tycho.model.manifest.ManifestAttribute; +import org.eclipse.tycho.model.manifest.MutableBundleManifest; import org.eclipse.tycho.versions.pom.tests.MutablePomFileTest; import org.junit.Assert; import org.junit.Test; diff --git a/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/bundle/tests/MutableManifestElementTest.java b/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/bundle/tests/MutableManifestElementTest.java index e3006a1227..9dfc85082a 100644 --- a/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/bundle/tests/MutableManifestElementTest.java +++ b/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/bundle/tests/MutableManifestElementTest.java @@ -8,7 +8,7 @@ import java.util.List; import java.util.Map; -import org.eclipse.tycho.versions.bundle.MutableManifestElement; +import org.eclipse.tycho.model.manifest.MutableManifestElement; import org.junit.Test; import org.osgi.framework.BundleException; import org.osgi.framework.Constants;