summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorBeat Strasser2011-05-04 18:04:49 (EDT)
committer jsievers2011-09-23 05:17:40 (EDT)
commit18782f6db7a9688464f11f34bdbbbc5a2d538901 (patch)
treec551b62cc7035944a2791ec68585470d8fcca78a
parent4f5afc94d81401ab2a6004d68e92d723f161d662 (diff)
downloadorg.eclipse.tycho-18782f6db7a9688464f11f34bdbbbc5a2d538901.zip
org.eclipse.tycho-18782f6db7a9688464f11f34bdbbbc5a2d538901.tar.gz
org.eclipse.tycho-18782f6db7a9688464f11f34bdbbbc5a2d538901.tar.bz2
341745 tycho-versions-plugin changes feature url in site.xml
-rw-r--r--tycho-release/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/manipulation/SiteXmlManipulator.java17
-rw-r--r--tycho-release/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/manipulation/SiteXmlManipulatorTest.java35
-rw-r--r--tycho-release/tycho-versions-plugin/src/test/resources/projects/multimodule/site/site.xml2
-rw-r--r--tycho-release/tycho-versions-plugin/src/test/resources/projects/multimodule/site/site.xml_expected2
4 files changed, 52 insertions, 4 deletions
diff --git a/tycho-release/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/manipulation/SiteXmlManipulator.java b/tycho-release/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/manipulation/SiteXmlManipulator.java
index 655ac7a..e3b9b02 100644
--- a/tycho-release/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/manipulation/SiteXmlManipulator.java
+++ b/tycho-release/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/manipulation/SiteXmlManipulator.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Sonatype Inc. - initial API and implementation
+ * Beat Strasser (Inventage AG) - preserve feature url in site.xml
*******************************************************************************/
package org.eclipse.tycho.versions.manipulation;
@@ -38,14 +39,26 @@ public class SiteXmlManipulator extends AbstractMetadataManipulator {
logger.info(" site.xml//site/feature/@id=" + feature.getId() + "/@version: "
+ change.getVersion() + " => " + change.getNewVersion());
feature.setVersion(change.getNewVersion());
- String newUrl = feature.getId() + "_" + change.getNewVersion();
- ((SiteFeatureRef) feature).setUrl(newUrl);
+
+ SiteFeatureRef siteFeature = (SiteFeatureRef) feature;
+ String oldUrl = siteFeature.getUrl();
+ String newUrl = rewriteFeatureUrl(oldUrl, change);
+ logger.info(" site.xml//site/feature/@id=" + feature.getId() + "/@url: " + oldUrl + " => "
+ + newUrl);
+ siteFeature.setUrl(newUrl);
}
}
}
}
}
+ String rewriteFeatureUrl(String url, VersionChange change) {
+ if (url != null) {
+ return url.replaceAll("\\Q" + change.getVersion() + "\\E", change.getNewVersion());
+ }
+ return null;
+ }
+
private UpdateSite getSiteXml(ProjectMetadata project) {
UpdateSite site = project.getMetadata(UpdateSite.class);
if (site == null) {
diff --git a/tycho-release/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/manipulation/SiteXmlManipulatorTest.java b/tycho-release/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/manipulation/SiteXmlManipulatorTest.java
new file mode 100644
index 0000000..bb158fa
--- /dev/null
+++ b/tycho-release/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/manipulation/SiteXmlManipulatorTest.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Inventage AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Beat Strasser (Inventage AG) - preserve feature url in site.xml
+ *******************************************************************************/
+package org.eclipse.tycho.versions.manipulation;
+
+import junit.framework.TestCase;
+
+import org.eclipse.tycho.versions.engine.VersionChange;
+
+public class SiteXmlManipulatorTest extends TestCase {
+
+ public void testFeatureUrlRewriting() {
+ assertFeatureUrlRewriting("features/id_NEW.jar", "features/id_1.2.3.jar", "1.2.3");
+ assertFeatureUrlRewriting("features/id_NEW.jar", "features/id_1.2.3.qualifier.jar", "1.2.3.qualifier");
+ assertFeatureUrlRewriting("features/id_NEW.jar", "features/id_1.2.3.201009091500.jar", "1.2.3.201009091500");
+ assertFeatureUrlRewriting("features/id_1x2x3.jar", "features/id_1x2x3.jar", "1.2.3");
+ assertFeatureUrlRewriting("features/id-NEW.jar", "features/id-1.2.3.jar", "1.2.3");
+ assertFeatureUrlRewriting("id/NEW/id-NEW.jar", "id/1.2.3/id-1.2.3.jar", "1.2.3");
+ assertFeatureUrlRewriting("id_NEW.jar", "id_1.2.3.jar", "1.2.3");
+ assertFeatureUrlRewriting("id_NEW", "id_1.2.3", "1.2.3");
+ }
+
+ private void assertFeatureUrlRewriting(String expectedUrl, String oldUrl, String oldVersion) {
+ assertEquals(expectedUrl,
+ new SiteXmlManipulator().rewriteFeatureUrl(oldUrl, new VersionChange(null, oldVersion, "NEW")));
+ }
+
+}
diff --git a/tycho-release/tycho-versions-plugin/src/test/resources/projects/multimodule/site/site.xml b/tycho-release/tycho-versions-plugin/src/test/resources/projects/multimodule/site/site.xml
index a70fd71..bf6e92f 100644
--- a/tycho-release/tycho-versions-plugin/src/test/resources/projects/multimodule/site/site.xml
+++ b/tycho-release/tycho-versions-plugin/src/test/resources/projects/multimodule/site/site.xml
@@ -1,3 +1,3 @@
<site>
- <feature id="feature01" url="feature01_1.0.0.qualifier" version="1.0.0.qualifier"/>
+ <feature id="feature01" url="features/feature01_1.0.0.qualifier.jar" version="1.0.0.qualifier"/>
</site> \ No newline at end of file
diff --git a/tycho-release/tycho-versions-plugin/src/test/resources/projects/multimodule/site/site.xml_expected b/tycho-release/tycho-versions-plugin/src/test/resources/projects/multimodule/site/site.xml_expected
index 406bb46..5280828 100644
--- a/tycho-release/tycho-versions-plugin/src/test/resources/projects/multimodule/site/site.xml_expected
+++ b/tycho-release/tycho-versions-plugin/src/test/resources/projects/multimodule/site/site.xml_expected
@@ -1,3 +1,3 @@
<site>
- <feature id="feature01" url="feature01_1.0.1.qualifier" version="1.0.1.qualifier"/>
+ <feature id="feature01" url="features/feature01_1.0.1.qualifier.jar" version="1.0.1.qualifier"/>
</site> \ No newline at end of file