aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNepomuk Seiler2012-08-27 15:04:08 (EDT)
committerTobias Oberlies2013-09-25 03:40:36 (EDT)
commitc68fc0217ea118cbfc7152246b4cafe770e205d0 (patch)
treeb43dcbcc8a3869a2e111b0ca9c740d95cd5b48a7
parent638b5e630b5ed89d4aab3119ee1533d3c9b19aff (diff)
downloadorg.eclipse.tycho-c68fc0217ea118cbfc7152246b4cafe770e205d0.zip
org.eclipse.tycho-c68fc0217ea118cbfc7152246b4cafe770e205d0.tar.gz
org.eclipse.tycho-c68fc0217ea118cbfc7152246b4cafe770e205d0.tar.bz2
387809 make tycho-versions:set-version update exported packagesrefs/changes/42/7442/4
- Implemented feature enhancement: Update the version attribute of exported packages when updating the version of a bundle. - Unit test are running. Bug 387809 tycho-versions:update-exported-packages Change-Id: Ia2795de6ad8e465436ef9ae13d4918b7addd62b5 Signed-off-by: Nepomuk Seiler <nepomuk.seiler@googlemail.com>
-rw-r--r--tycho-release/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle/MutableBundleManifest.java10
-rw-r--r--tycho-release/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/manipulation/BundleManifestManipulator.java3
-rw-r--r--tycho-release/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/bundle/tests/MutableBundleManifestTest.java8
-rw-r--r--tycho-release/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/engine/tests/VersionsEngineTest.java11
-rw-r--r--tycho-release/tycho-versions-plugin/src/test/resources/manifests/setExportedPackage.mf10
-rw-r--r--tycho-release/tycho-versions-plugin/src/test/resources/manifests/setExportedPackage.mf_expected9
-rw-r--r--tycho-release/tycho-versions-plugin/src/test/resources/projects/exportpackage/META-INF/MANIFEST.MF9
-rw-r--r--tycho-release/tycho-versions-plugin/src/test/resources/projects/exportpackage/META-INF/MANIFEST.MF_expected8
-rw-r--r--tycho-release/tycho-versions-plugin/src/test/resources/projects/exportpackage/pom.xml9
-rw-r--r--tycho-release/tycho-versions-plugin/src/test/resources/projects/exportpackage/pom.xml_expected9
10 files changed, 86 insertions, 0 deletions
diff --git a/tycho-release/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle/MutableBundleManifest.java b/tycho-release/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle/MutableBundleManifest.java
index cb25843..f0833e9 100644
--- a/tycho-release/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle/MutableBundleManifest.java
+++ b/tycho-release/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle/MutableBundleManifest.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Sonatype Inc. - initial API and implementation
+ * Nepomuk Seiler - set export-package attribute implementation
*******************************************************************************/
package org.eclipse.tycho.versions.bundle;
@@ -195,4 +196,13 @@ public class MutableBundleManifest {
}
}
+ public void setExportedPackageVersion(String version) {
+ ManifestAttribute attr = getAttribute(Constants.EXPORT_PACKAGE);
+ if (attr == null)
+ return;
+
+ String newExportedPackage = attr.getValue().replaceAll("(version=)\"(.*?)\"", "$1\"" + version + "\"") //Replacing all version fields
+ .replaceAll(".qualifier", ""); // Removing all .qualifier
+ attr.set(Constants.EXPORT_PACKAGE, newExportedPackage);
+ }
}
diff --git a/tycho-release/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/manipulation/BundleManifestManipulator.java b/tycho-release/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/manipulation/BundleManifestManipulator.java
index 86ea705..bfb984f 100644
--- a/tycho-release/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/manipulation/BundleManifestManipulator.java
+++ b/tycho-release/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/manipulation/BundleManifestManipulator.java
@@ -35,6 +35,9 @@ public class BundleManifestManipulator extends AbstractMetadataManipulator {
+ change.getNewVersion());
mf.setVersion(change.getNewVersion());
+ logger.info(" Setting export-package version: " + change.getVersion() + " => "
+ + change.getNewVersion().replace(".qualifier", ""));
+ mf.setExportedPackageVersion(change.getNewVersion());
}
}
diff --git a/tycho-release/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/bundle/tests/MutableBundleManifestTest.java b/tycho-release/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/bundle/tests/MutableBundleManifestTest.java
index dd27ee2..896bfef 100644
--- a/tycho-release/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/bundle/tests/MutableBundleManifestTest.java
+++ b/tycho-release/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/bundle/tests/MutableBundleManifestTest.java
@@ -51,6 +51,14 @@ public class MutableBundleManifestTest {
}
@Test
+ public void setExportedVersion() throws Exception {
+ MutableBundleManifest mf = getManifest("/manifests/setExportedPackage.mf");
+
+ mf.setExportedPackageVersion("1.0.1.qualifier");
+ assertContents(mf, "/manifests/setExportedPackage.mf_expected");
+ }
+
+ @Test
public void addAttribute() throws Exception {
MutableBundleManifest mf = getManifest("/manifests/addheader.mf");
mf.add(new ManifestAttribute("header", "value"));
diff --git a/tycho-release/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/engine/tests/VersionsEngineTest.java b/tycho-release/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/engine/tests/VersionsEngineTest.java
index d2ea823..4be1f3d 100644
--- a/tycho-release/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/engine/tests/VersionsEngineTest.java
+++ b/tycho-release/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/engine/tests/VersionsEngineTest.java
@@ -31,6 +31,17 @@ public class VersionsEngineTest extends AbstractVersionChangeTest {
assertBundleManifest(basedir);
}
+ public void testExportPackage() throws Exception {
+ File basedir = TestUtil.getBasedir("projects/exportpackage");
+
+ VersionsEngine engine = newEngine(basedir);
+ engine.addVersionChange("exportpackage", "1.0.1.qualifier");
+ engine.apply();
+
+ assertPom(basedir);
+ assertBundleManifest(basedir);
+ }
+
public void testMultimodule() throws Exception {
File basedir = TestUtil.getBasedir("projects/multimodule");
diff --git a/tycho-release/tycho-versions-plugin/src/test/resources/manifests/setExportedPackage.mf b/tycho-release/tycho-versions-plugin/src/test/resources/manifests/setExportedPackage.mf
new file mode 100644
index 0000000..af19afc
--- /dev/null
+++ b/tycho-release/tycho-versions-plugin/src/test/resources/manifests/setExportedPackage.mf
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Bundle01
+Bundle-SymbolicName: TYCHO0214
+ versionChange.bundle01
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.eclipse.tycho;version="1.0.0",
+ org.eclipse.tycho.test;version="1.0.0",
+ org.eclipse.tycho.core;version="1.0.0" \ No newline at end of file
diff --git a/tycho-release/tycho-versions-plugin/src/test/resources/manifests/setExportedPackage.mf_expected b/tycho-release/tycho-versions-plugin/src/test/resources/manifests/setExportedPackage.mf_expected
new file mode 100644
index 0000000..8593366
--- /dev/null
+++ b/tycho-release/tycho-versions-plugin/src/test/resources/manifests/setExportedPackage.mf_expected
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Bundle01
+Bundle-SymbolicName: TYCHO0214
+ versionChange.bundle01
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.eclipse.tycho;version="1.0.1",org.eclipse.tycho.te
+ st;version="1.0.1",org.eclipse.tycho.core;version="1.0.1"
diff --git a/tycho-release/tycho-versions-plugin/src/test/resources/projects/exportpackage/META-INF/MANIFEST.MF b/tycho-release/tycho-versions-plugin/src/test/resources/projects/exportpackage/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..6bb9e2d
--- /dev/null
+++ b/tycho-release/tycho-versions-plugin/src/test/resources/projects/exportpackage/META-INF/MANIFEST.MF
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-Version: 1.0.0.qualifier
+Bundle-Name: exportpackage
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: exportpackage
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.eclipse.tycho;version="1.0.0",
+ org.eclipse.tycho.test;version="1.0.0",
+ org.eclipse.tycho.core;version="1.0.0"
diff --git a/tycho-release/tycho-versions-plugin/src/test/resources/projects/exportpackage/META-INF/MANIFEST.MF_expected b/tycho-release/tycho-versions-plugin/src/test/resources/projects/exportpackage/META-INF/MANIFEST.MF_expected
new file mode 100644
index 0000000..9c18509
--- /dev/null
+++ b/tycho-release/tycho-versions-plugin/src/test/resources/projects/exportpackage/META-INF/MANIFEST.MF_expected
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Bundle-Version: 1.0.1.qualifier
+Bundle-Name: exportpackage
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: exportpackage
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.eclipse.tycho;version="1.0.1",org.eclipse.tycho.te
+ st;version="1.0.1",org.eclipse.tycho.core;version="1.0.1"
diff --git a/tycho-release/tycho-versions-plugin/src/test/resources/projects/exportpackage/pom.xml b/tycho-release/tycho-versions-plugin/src/test/resources/projects/exportpackage/pom.xml
new file mode 100644
index 0000000..9f0fd69
--- /dev/null
+++ b/tycho-release/tycho-versions-plugin/src/test/resources/projects/exportpackage/pom.xml
@@ -0,0 +1,9 @@
+<project>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>exportpackage</groupId>
+ <artifactId>exportpackage</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+
+</project> \ No newline at end of file
diff --git a/tycho-release/tycho-versions-plugin/src/test/resources/projects/exportpackage/pom.xml_expected b/tycho-release/tycho-versions-plugin/src/test/resources/projects/exportpackage/pom.xml_expected
new file mode 100644
index 0000000..6d8e5e0
--- /dev/null
+++ b/tycho-release/tycho-versions-plugin/src/test/resources/projects/exportpackage/pom.xml_expected
@@ -0,0 +1,9 @@
+<project>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>exportpackage</groupId>
+ <artifactId>exportpackage</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+
+</project> \ No newline at end of file