Index: build/tycho-plugins/generate-site-xml/.classpath
===================================================================
--- build/tycho-plugins/generate-site-xml/.classpath	(revision 0)
+++ build/tycho-plugins/generate-site-xml/.classpath	(revision 0)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src/main/java">
+		<attributes>
+			<attribute name="optional" value="true"/>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="src" output="target/test-classes" path="src/test/java">
+		<attributes>
+			<attribute name="optional" value="true"/>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>
Index: build/tycho-plugins/generate-site-xml/.project
===================================================================
--- build/tycho-plugins/generate-site-xml/.project	(revision 0)
+++ build/tycho-plugins/generate-site-xml/.project	(revision 0)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>generate-site-xml</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.m2e.core.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.eclipse.m2e.core.maven2Nature</nature>
+	</natures>
+</projectDescription>
Index: build/tycho-plugins/generate-site-xml/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- build/tycho-plugins/generate-site-xml/.settings/org.eclipse.jdt.core.prefs	(revision 0)
+++ build/tycho-plugins/generate-site-xml/.settings/org.eclipse.jdt.core.prefs	(revision 0)
@@ -0,0 +1,5 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.5
Index: build/tycho-plugins/generate-site-xml/.settings/org.eclipse.m2e.core.prefs
===================================================================
--- build/tycho-plugins/generate-site-xml/.settings/org.eclipse.m2e.core.prefs	(revision 0)
+++ build/tycho-plugins/generate-site-xml/.settings/org.eclipse.m2e.core.prefs	(revision 0)
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
Index: build/tycho-plugins/generate-site-xml/pom.xml
===================================================================
--- build/tycho-plugins/generate-site-xml/pom.xml	(revision 0)
+++ build/tycho-plugins/generate-site-xml/pom.xml	(revision 0)
@@ -0,0 +1,51 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.jboss.tools.tycho</groupId>
+  <artifactId>generate-site-xml</artifactId>
+  <packaging>maven-plugin</packaging>
+  <version>0.0.1-SNAPSHOT</version>
+  <parent>
+  	<groupId>org.jboss.tools</groupId>
+  	<artifactId>org.jboss.tools.parent.pom</artifactId>
+  	<relativePath>../../parent/pom.xml</relativePath>
+  	<version>0.0.3-SNAPSHOT</version>
+  </parent>
+  <name>Mojo to Generate site.xml for eclipse-repository</name>
+  
+ <dependencies>
+		<dependency>
+			<groupId>org.eclipse.tycho</groupId>
+			<artifactId>tycho-p2-facade</artifactId>
+			<version>${tychoVersion}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.eclipse.tycho</groupId>
+			<artifactId>tycho-packaging-plugin</artifactId>
+			<version>${tychoVersion}</version>
+		</dependency>
+		
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>4.8.2</version>
+			<scope>test</scope>
+		</dependency>
+  </dependencies>
+  
+  <repositories>
+  	<repository>
+  		<id>central</id>
+  		<url>http://repo1.maven.org/maven2</url>
+  		<layout>default</layout>
+  		<releases><enabled>true</enabled></releases>
+  	</repository>
+  </repositories>
+  <pluginRepositories>
+  	<pluginRepository>
+  		<id>central-plugin</id>
+  		<url>http://repo1.maven.org/maven2</url>
+  	</pluginRepository>
+  </pluginRepositories>
+
+</project>
Index: build/tycho-plugins/generate-site-xml/src/main/java/org/jboss/tools/tycho/sitegenerator/GenerateSiteXmlMojo.java
===================================================================
--- build/tycho-plugins/generate-site-xml/src/main/java/org/jboss/tools/tycho/sitegenerator/GenerateSiteXmlMojo.java	(revision 0)
+++ build/tycho-plugins/generate-site-xml/src/main/java/org/jboss/tools/tycho/sitegenerator/GenerateSiteXmlMojo.java	(revision 0)
@@ -0,0 +1,149 @@
+package org.jboss.tools.tycho.sitegenerator;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipException;
+import java.util.zip.ZipFile;
+import java.util.zip.ZipOutputStream;
+
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.IOUtil;
+import org.eclipse.tycho.ArtifactKey;
+import org.eclipse.tycho.ReactorProject;
+import org.eclipse.tycho.core.ArtifactDependencyVisitor;
+import org.eclipse.tycho.core.FeatureDescription;
+import org.eclipse.tycho.core.osgitools.EclipseRepositoryProject;
+import org.eclipse.tycho.model.FeatureRef;
+import org.eclipse.tycho.model.UpdateSite;
+import org.eclipse.tycho.model.UpdateSite.SiteFeatureRef;
+import org.eclipse.tycho.packaging.AbstractTychoPackagingMojo;
+import org.eclipse.tycho.packaging.UpdateSiteAssembler;
+
+/**
+ * Goal which touches a timestamp file.
+ *
+ * @goal generate-site-xml
+ * 
+ * @phase package
+ */
+public class GenerateSiteXmlMojo extends AbstractTychoPackagingMojo {
+	/**
+     * @parameter expression="${session}"
+     * @readonly
+     */
+    private MavenSession session;
+
+    /**
+     * @parameter expression="${project}"
+     * @readonly
+     */
+    private MavenProject project;
+
+    public void execute() throws MojoExecutionException
+    {
+    	 if (!ArtifactKey.TYPE_ECLIPSE_REPOSITORY.equals(project.getPackaging())) {
+             return;
+         }
+
+        File categoryFile = new File(project.getBasedir(), "category.xml");
+        getLog().info(categoryFile.getAbsolutePath());
+        if (!categoryFile.isFile()) {
+        	throw new MojoExecutionException("Missing 'category.xml file'");
+        }
+        
+		UpdateSite site = null;
+		try {
+			site = UpdateSite.read(categoryFile);
+		} catch (IOException ex) {
+			throw new MojoExecutionException("Could not read 'category.xml' file", ex);
+		}
+		new EclipseRepositoryProject().getDependencyWalker(project).traverseUpdateSite(site, new ArtifactDependencyVisitor() {
+            @Override
+            public boolean visitFeature(FeatureDescription feature) {
+                FeatureRef featureRef = feature.getFeatureRef();
+                String id = featureRef.getId();
+                ReactorProject otherProject = feature.getMavenProject();
+                String version;
+                if (otherProject != null) {
+                    version = otherProject.getExpandedVersion();
+                } else {
+                    version = feature.getKey().getVersion();
+                }
+                String url = UpdateSiteAssembler.FEATURES_DIR + id + "_" + version + ".jar";
+                ((SiteFeatureRef) featureRef).setUrl(url);
+                featureRef.setVersion(version);
+                return false; // don't traverse included features
+            }
+        });
+        File outputSiteXml = new File(project.getBasedir(), "target/repository/site.xml");
+        getLog().debug("Output directory: " + outputSiteXml);
+        try {
+        	 if (!outputSiteXml.exists()) {
+             	outputSiteXml.createNewFile();
+             }
+        	UpdateSite.write(site, outputSiteXml);
+        	getLog().info("Output is in " + outputSiteXml.getAbsolutePath());
+        } catch (IOException ex) {
+        	ex.printStackTrace();
+        	throw new MojoExecutionException("Could not write site.xml to '" + outputSiteXml.getAbsolutePath() + "'", ex);
+        }
+        
+        try {
+        	appendFileToRepositoryZio(outputSiteXml);
+        } catch (Exception ex) {
+        	throw new MojoExecutionException("Error occured while adding 'site.xml' to repository.zip", ex);
+        }
+    }
+
+	private void appendFileToRepositoryZio(File outputSiteXml) throws ZipException, IOException, FileNotFoundException {
+		File srcRepository = new File(project.getBasedir(), "target/repository.zip");
+		ZipFile srcRepositoryZip = new ZipFile(srcRepository);
+		File targetReporitory = new File(project.getBasedir(), "target/repository_sitexml.zip");
+        ZipOutputStream targetRepositoryOut = new ZipOutputStream(new FileOutputStream(targetReporitory));
+        Enumeration<? extends ZipEntry> entries = srcRepositoryZip.entries();
+        while (entries.hasMoreElements()) {
+        	ZipEntry current = entries.nextElement();
+        	InputStream src = srcRepositoryZip.getInputStream(current);
+        	ZipEntry copy = new ZipEntry(current.getName());
+        	targetRepositoryOut.putNextEntry(copy);
+        	IOUtil.copy(src, targetRepositoryOut);
+        	targetRepositoryOut.closeEntry();
+        }
+        srcRepositoryZip.close();
+        
+        ZipEntry siteXmlEntry = new ZipEntry(outputSiteXml.getName());
+        FileInputStream in = new FileInputStream(outputSiteXml);
+        targetRepositoryOut.putNextEntry(siteXmlEntry);
+        IOUtil.copy(in, targetRepositoryOut);
+        targetRepositoryOut.closeEntry();
+        in.close();
+        targetRepositoryOut.close();
+        
+        srcRepository.delete();
+        targetReporitory.renameTo(srcRepository);
+	}
+}
