aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGregory Amerson2011-05-27 15:25:36 (EDT)
committerjsievers2011-09-23 05:17:31 (EDT)
commit154b3d0cbbaef7a5d794d233a4166105935a2091 (patch)
treedcad318b7e725a924231697f87af5a90767a24e5
parent621843eaea012d4a09d4a7a847f5ce5f550fab7a (diff)
downloadorg.eclipse.tycho-154b3d0cbbaef7a5d794d233a4166105935a2091.zip
org.eclipse.tycho-154b3d0cbbaef7a5d794d233a4166105935a2091.tar.gz
org.eclipse.tycho-154b3d0cbbaef7a5d794d233a4166105935a2091.tar.bz2
bug#346926 Support associateSitesURL attribute in site.xml
-rw-r--r--tycho-metadata-model/src/main/java/org/eclipse/tycho/model/UpdateSite.java10
-rw-r--r--tycho-packaging-plugin/src/main/java/org/eclipse/tycho/packaging/UpdateSiteMojo.java8
-rw-r--r--tycho-packaging-plugin/src/test/java/org/eclipse/tycho/buildnumber/test/PackageUpdateSiteMojoTest.java32
3 files changed, 49 insertions, 1 deletions
diff --git a/tycho-metadata-model/src/main/java/org/eclipse/tycho/model/UpdateSite.java b/tycho-metadata-model/src/main/java/org/eclipse/tycho/model/UpdateSite.java
index 37106c4..ccd73c5 100644
--- a/tycho-metadata-model/src/main/java/org/eclipse/tycho/model/UpdateSite.java
+++ b/tycho-metadata-model/src/main/java/org/eclipse/tycho/model/UpdateSite.java
@@ -47,9 +47,15 @@ public class UpdateSite {
private final Document document;
+ private String associateSitesUrl;
+
public UpdateSite(Document document) {
this.document = document;
this.dom = document.getRootElement();
+
+ if (dom.getAttribute("associateSitesURL") != null) {
+ associateSitesUrl = dom.getAttributeValue("associateSitesURL");
+ }
}
public List<SiteFeatureRef> getFeatures() {
@@ -126,4 +132,8 @@ public class UpdateSite {
String pack200 = dom.getAttributeValue("pack200");
return "true".equals(pack200);
}
+
+ public String getAssociateSitesUrl() {
+ return associateSitesUrl;
+ }
}
diff --git a/tycho-packaging-plugin/src/main/java/org/eclipse/tycho/packaging/UpdateSiteMojo.java b/tycho-packaging-plugin/src/main/java/org/eclipse/tycho/packaging/UpdateSiteMojo.java
index 799c910..34f8134 100644
--- a/tycho-packaging-plugin/src/main/java/org/eclipse/tycho/packaging/UpdateSiteMojo.java
+++ b/tycho-packaging-plugin/src/main/java/org/eclipse/tycho/packaging/UpdateSiteMojo.java
@@ -83,6 +83,14 @@ public class UpdateSiteMojo extends AbstractTychoPackagingMojo {
File file = new File(target, "site.xml");
UpdateSite.write(site, file);
+
+ // Copy the associate sites file, if necessary
+ if (site.getAssociateSitesUrl() != null) {
+ File srcAssociateSitesFile = new File(basedir, site.getAssociateSitesUrl());
+ if (srcAssociateSitesFile.exists()) {
+ FileUtils.copyFile(srcAssociateSitesFile, new File(target + File.separator + site.getAssociateSitesUrl()));
+ }
+ }
} catch (Exception e) {
throw new MojoExecutionException(e.getMessage(), e);
}
diff --git a/tycho-packaging-plugin/src/test/java/org/eclipse/tycho/buildnumber/test/PackageUpdateSiteMojoTest.java b/tycho-packaging-plugin/src/test/java/org/eclipse/tycho/buildnumber/test/PackageUpdateSiteMojoTest.java
index 189d9d9..1d2ea9e 100644
--- a/tycho-packaging-plugin/src/test/java/org/eclipse/tycho/buildnumber/test/PackageUpdateSiteMojoTest.java
+++ b/tycho-packaging-plugin/src/test/java/org/eclipse/tycho/buildnumber/test/PackageUpdateSiteMojoTest.java
@@ -19,6 +19,7 @@ import java.util.zip.ZipFile;
import junit.framework.Assert;
import org.apache.maven.artifact.Artifact;
+import org.apache.maven.it.util.FileUtils;
import org.apache.maven.project.MavenProject;
import org.eclipse.tycho.packaging.PackageUpdateSiteMojo;
import org.eclipse.tycho.testing.AbstractTychoMojoTestCase;
@@ -48,7 +49,15 @@ public class PackageUpdateSiteMojoTest extends AbstractTychoMojoTestCase {
// org.eclipse.tycho:tycho-packaging-plugin:${project.version}:update-site,org.eclipse.tycho:tycho-p2-plugin:${project.version}:update-site-p2-metadata,
File siteFolder = new File(targetFolder, "site");
siteFolder.mkdirs();
- new File(siteFolder, "site.xml").createNewFile();
+ File siteXml = new File(siteFolder, "site.xml");
+ siteXml.createNewFile();
+ FileUtils.fileAppend(siteXml.getAbsolutePath(),
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><site associateSitesURL=\"associate-sites.xml\"></site>");
+ File associateSitesFile = new File(siteFolder, "associate-sites.xml");
+ FileUtils
+ .fileAppend(
+ associateSitesFile.getAbsolutePath(),
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><associateSites><associateSite url=\"http://download.eclipse.org/technology/m2e/updates/M\" label=\"m2e site\" /></associateSites>");
new File(siteFolder, "content.xml").createNewFile();
new File(siteFolder, "artifacts.xml").createNewFile();
@@ -86,6 +95,27 @@ public class PackageUpdateSiteMojoTest extends AbstractTychoMojoTestCase {
checkSiteZip();
}
+ public void testAssociateSitsURLSite() throws Exception {
+ setVariableValueToObject(packagemojo, "archiveSite", Boolean.TRUE);
+
+ packagemojo.execute();
+ checkSiteZip();
+
+ File assemblyZip = new File(targetFolder, "site_assembly.zip");
+ Assert.assertTrue(assemblyZip.exists());
+ List<Artifact> attachedArtifacts = project.getAttachedArtifacts();
+ Assert.assertTrue(attachedArtifacts.size() == 1);
+ Assert.assertTrue(attachedArtifacts.get(0).getFile().equals(assemblyZip));
+ Assert.assertTrue(attachedArtifacts.get(0).getClassifier().equals("assembly"));
+ Assert.assertTrue(attachedArtifacts.get(0).getType().equals("zip"));
+ ZipFile zip = new ZipFile(assemblyZip);
+ try {
+ assertNotNull(zip.getEntry("associate-sites.xml"));
+ } finally {
+ zip.close();
+ }
+ }
+
private void checkSiteZip() throws ZipException, IOException {
File resultzip = new File(targetFolder, "site.zip");
Assert.assertTrue(resultzip.exists());