TUSCANY-3860: Build updatesite contents for site-publish as part of the distribution output

git-svn-id: https://svn.apache.org/repos/asf/tuscany/sca-java-1.x/trunk@1098346 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/distribution/src/main/assembly/updatesite.xml b/distribution/src/main/assembly/updatesite.xml
index c44807c..39e9b47 100644
--- a/distribution/src/main/assembly/updatesite.xml
+++ b/distribution/src/main/assembly/updatesite.xml
@@ -33,6 +33,7 @@
 			<outputDirectory></outputDirectory>

             <excludes>

                 <exclude>tuscany-sca-${tuscany.version}-updatesite/LICENSE</exclude>

+                <exclude>tuscany-sca-${tuscany.version}-updatesite-publish/LICENSE</exclude>

                 <exclude>tuscany-sca-${tuscany.version}-updatesite/features/*</exclude>

             </excludes>

 		</fileSet>

@@ -43,5 +44,12 @@
                 <include>LICENSE</include>

             </includes>

         </fileSet>

+        <fileSet>

+            <directory>src/main/release/bin</directory>

+            <outputDirectory>tuscany-sca-${tuscany.version}-updatesite-publish</outputDirectory>

+            <includes>

+                <include>LICENSE</include>

+            </includes>

+        </fileSet>

 	</fileSets>

 </assembly>

diff --git a/tools/eclipse/site/updatesite/filtered-resources/.htaccess b/tools/eclipse/site/updatesite/filtered-resources/.htaccess
new file mode 100644
index 0000000..b237565
--- /dev/null
+++ b/tools/eclipse/site/updatesite/filtered-resources/.htaccess
@@ -0,0 +1,6 @@
+RewriteEngine on
+
+RewriteBase /updatesite/java/sca/${pom.version}
+
+RewriteRule ^site.xml$ site--xml.cgi [L]
+
diff --git a/tools/eclipse/site/updatesite/filtered-resources/site--xml.html b/tools/eclipse/site/updatesite/filtered-resources/site--xml.html
new file mode 100644
index 0000000..d3aea23
--- /dev/null
+++ b/tools/eclipse/site/updatesite/filtered-resources/site--xml.html
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+-->
+<site>
+   <description url="http://tuscany.apache.org">
+      Apache Tuscany SCA Eclipse Tools
+   </description>
+   
+   <feature id="org.apache.tuscany.sca.feature.core" version="${tuscany.eclipse.version}"
+      url="[preferred]/tuscany/java/sca/${pom.version}/tuscany-sca-${pom.version}-updatesite/features/org.apache.tuscany.sca.feature.core-${pom.version}.jar">
+      <category name="Apache Tuscany SCA Eclipse Tools"/>
+   </feature>
+   
+   <archive path="plugins/org.apache.tuscany.sca.core_${tuscany.eclipse.version}.jar"
+      url="[preferred]/tuscany/java/sca/${pom.version}/tuscany-sca-${pom.version}-updatesite/plugins/org.apache.tuscany.sca.core_${tuscany.eclipse.version}.jar"/>
+
+   <category-def name="Apache Tuscany SCA Eclipse Tools" label="Apache Tuscany SCA Eclipse Tools">
+      <description>
+         The Apache Tuscany SCA Eclipse Tools category contains all features related to Apache Tuscany SCA.
+      </description>
+   </category-def>
+</site>
diff --git a/tools/eclipse/site/updatesite/filtered-resources/src/main/assembly/updatesite.xml b/tools/eclipse/site/updatesite/filtered-resources/src/main/assembly/updatesite.xml
index b681a1b..1cc2651 100644
--- a/tools/eclipse/site/updatesite/filtered-resources/src/main/assembly/updatesite.xml
+++ b/tools/eclipse/site/updatesite/filtered-resources/src/main/assembly/updatesite.xml
@@ -26,7 +26,7 @@
 
     <fileSets>
         <fileSet>
-            <directory>target/classes</directory>
+            <directory>.</directory>
             <outputDirectory>tuscany-sca-${tuscany.version}-updatesite</outputDirectory>
             <includes>
                 <include>LICENSE</include>
@@ -34,6 +34,19 @@
                 <include>site.xml</include>
             </includes>
         </fileSet>
+        <fileSet>
+            <directory>.</directory>
+            <outputDirectory>tuscany-sca-${tuscany.version}-updatesite-publish</outputDirectory>
+            <includes>
+                <include>LICENSE</include>
+                <include>NOTICE</include>
+                <include>.htaccess</include>
+                <include>index.html</include>
+                <include>site--xml.cgi</include>
+                <include>site--xml.html</include>
+                <include>web/**</include>
+            </includes>
+        </fileSet>
     </fileSets>
         
     <files>
diff --git a/tools/eclipse/site/updatesite/index.html b/tools/eclipse/site/updatesite/index.html
new file mode 100644
index 0000000..fe3fb11
--- /dev/null
+++ b/tools/eclipse/site/updatesite/index.html
@@ -0,0 +1,60 @@
+<html>
+<head>
+<title>tuscany-updatesite</title>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<style>@import url("web/site.css");</style>
+<script type="text/javascript">
+	var returnval = 0;
+	var stylesheet, xmlFile, cache, doc;
+	function init(){
+		// NSCP 7.1+ / Mozilla 1.4.1+ / Safari
+		// Use the standard DOM Level 2 technique, if it is supported
+		if (document.implementation && document.implementation.createDocument) {
+			xmlFile = document.implementation.createDocument("", "", null);
+			stylesheet = document.implementation.createDocument("", "", null);
+			if (xmlFile.load){
+				xmlFile.load("site.xml");
+				stylesheet.load("web/site.xsl");
+			} else {
+				alert("Document could not be loaded by browser.");
+			}
+			xmlFile.addEventListener("load", transform, false);
+			stylesheet.addEventListener("load", transform, false);
+		}
+		//IE 6.0+ solution
+		else if (window.ActiveXObject) {
+			xmlFile = new ActiveXObject("msxml2.DOMDocument.3.0");
+			xmlFile.async = false;
+			xmlFile.load("site.xml");
+			stylesheet = new ActiveXObject("msxml2.FreeThreadedDOMDocument.3.0");
+			stylesheet.async = false;
+			stylesheet.load("web/site.xsl");
+			cache = new ActiveXObject("msxml2.XSLTemplate.3.0");
+			cache.stylesheet = stylesheet;
+			transformData();
+		}
+	}
+	// separate transformation function for IE 6.0+
+	function transformData(){
+		var processor = cache.createProcessor();
+		processor.input = xmlFile;
+		processor.transform();
+		data.innerHTML = processor.output;
+	}
+	// separate transformation function for NSCP 7.1+ and Mozilla 1.4.1+ 
+	function transform(){
+		returnval+=1;
+		if (returnval==2){
+			var processor = new XSLTProcessor();
+			processor.importStylesheet(stylesheet); 
+			doc = processor.transformToDocument(xmlFile);
+			document.getElementById("data").innerHTML = doc.documentElement.innerHTML;
+		}
+	}
+</script>
+</head>
+<body onload="init();">
+<!--[insert static HTML here]-->
+<div id="data"><!-- this is where the transformed data goes --></div>
+</body>
+</html>
diff --git a/tools/eclipse/site/updatesite/pom.xml b/tools/eclipse/site/updatesite/pom.xml
index bba3728..a9c69d9 100644
--- a/tools/eclipse/site/updatesite/pom.xml
+++ b/tools/eclipse/site/updatesite/pom.xml
@@ -51,16 +51,12 @@
             <filter>${basedir}/../../target/filter.properties</filter>
         </filters>
 
+        <!-- No need to copy resources because the assembly plugin gets them from basedir -->
         <resources>
             <resource>
                 <directory>${basedir}</directory>
                 <excludes>
-                    <exclude>src/**</exclude>
-                    <exclude>**/.*/**</exclude>
-                    <exclude>pom.xml</exclude>
-                    <exclude>build.*</exclude>
-                    <exclude>filtered-resources/**</exclude>
-                    <exclude>target/**</exclude>
+                    <exclude>**/*</exclude>
                 </excludes>
             </resource>
         </resources>
@@ -121,6 +117,8 @@
                             <includes>
                                 <include>site.xml</include>
                                 <include>NOTICE</include>
+                                <include>.htaccess</include>
+                                <include>site--xml.html</include>
                                 <include>src/**</include>
                             </includes>
                         </fileset>
diff --git a/tools/eclipse/site/updatesite/site--xml.cgi b/tools/eclipse/site/updatesite/site--xml.cgi
new file mode 100644
index 0000000..5fd64f0
--- /dev/null
+++ b/tools/eclipse/site/updatesite/site--xml.cgi
@@ -0,0 +1,6 @@
+#!/bin/sh
+# Wrapper script around mirrors.cgi script
+# (we must change to that directory in order for python to pick up the
+#  python includes correctly)
+cd /www/www.apache.org/dyn/mirrors
+/www/www.apache.org/dyn/mirrors/mirrors.cgi $* 
diff --git a/tools/eclipse/site/updatesite/web/site.css b/tools/eclipse/site/updatesite/web/site.css
new file mode 100644
index 0000000..62c6f9f
--- /dev/null
+++ b/tools/eclipse/site/updatesite/web/site.css
@@ -0,0 +1,12 @@
+<STYLE type="text/css">
+td.spacer {padding-bottom: 10px; padding-top: 10px;}
+.title { font-family: sans-serif; color: #99AACC;}
+.bodyText { font-family: sans-serif; font-size: 9pt; color:#000000;  }
+.sub-header { font-family: sans-serif; font-style: normal; font-weight: bold; font-size: 9pt; color: white;}
+.log-text {font-family: sans-serif; font-style: normal; font-weight: lighter; font-size: 8pt; color:black;}
+.big-header { font-family: sans-serif; font-style: normal; font-weight: bold; font-size: 9pt; color: white; border-top:10px solid white;}
+.light-row {background:#FFFFFF}
+.dark-row {background:#EEEEFF}
+.header {background:#99AADD}
+#indent {word-wrap : break-word;width :300px;text-indent:10px;}
+</STYLE>
diff --git a/tools/eclipse/site/updatesite/web/site.xsl b/tools/eclipse/site/updatesite/web/site.xsl
new file mode 100644
index 0000000..05fb686
--- /dev/null
+++ b/tools/eclipse/site/updatesite/web/site.xsl
@@ -0,0 +1,214 @@
+<xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:msxsl="urn:schemas-microsoft-com:xslt">
+<xsl:output method="html" encoding="UTF-8"/>
+<xsl:key name="cat" match="category" use="@name"/>
+<xsl:template match="/">
+<xsl:for-each select="site">
+	<html>
+	<head>
+	<title>tuscany-updatesite</title>
+	<style>@import url("web/site.css");</style>
+	</head>
+	<body>
+	<h1 class="title">tuscany-updatesite</h1>
+	<p class="bodyText"><xsl:value-of select="description"/></p>
+	<table width="100%" border="0" cellspacing="1" cellpadding="2">
+	<xsl:for-each select="category-def">
+		<xsl:sort select="@label" order="ascending" case-order="upper-first"/>
+		<xsl:sort select="@name" order="ascending" case-order="upper-first"/>
+	<xsl:if test="count(key('cat',@name)) != 0">
+			<tr class="header">
+				<td class="sub-header" width="30%">
+					<xsl:value-of select="@name"/>
+				</td>
+				<td class="sub-header" width="70%">
+					<xsl:value-of select="@label"/>
+				</td>
+			</tr>
+			<xsl:for-each select="key('cat',@name)">
+			<xsl:sort select="ancestor::feature//@version" order="ascending"/>
+			<xsl:sort select="ancestor::feature//@id" order="ascending" case-order="upper-first"/>
+			<tr>
+				<xsl:choose>
+				<xsl:when test="(position() mod 2 = 1)">
+					<xsl:attribute name="class">dark-row</xsl:attribute>
+				</xsl:when>
+				<xsl:otherwise>
+					<xsl:attribute name="class">light-row</xsl:attribute>
+				</xsl:otherwise>
+				</xsl:choose>
+				<td class="log-text" id="indent">
+						<xsl:choose>
+						<xsl:when test="ancestor::feature//@label">
+							<a href="{ancestor::feature//@url}"><xsl:value-of select="ancestor::feature//@label"/></a>
+							<br/>
+							<div id="indent">
+							(<xsl:value-of select="ancestor::feature//@id"/> - <xsl:value-of select="ancestor::feature//@version"/>)
+							</div>
+						</xsl:when>
+						<xsl:otherwise>
+						<a href="{ancestor::feature//@url}"><xsl:value-of select="ancestor::feature//@id"/> - <xsl:value-of select="ancestor::feature//@version"/></a>
+						</xsl:otherwise>
+						</xsl:choose>
+						<br />
+				</td>
+				<td>
+					<table>
+						<xsl:if test="ancestor::feature//@os">
+							<tr><td class="log-text" id="indent">Operating Systems:</td>
+							<td class="log-text" id="indent"><xsl:value-of select="ancestor::feature//@os"/></td>
+							</tr>
+						</xsl:if>
+						<xsl:if test="ancestor::feature//@ws">
+							<tr><td class="log-text" id="indent">Windows Systems:</td>
+							<td class="log-text" id="indent"><xsl:value-of select="ancestor::feature//@ws"/></td>
+							</tr>
+						</xsl:if>
+						<xsl:if test="ancestor::feature//@nl">
+							<tr><td class="log-text" id="indent">Languages:</td>
+							<td class="log-text" id="indent"><xsl:value-of select="ancestor::feature//@nl"/></td>
+							</tr>
+						</xsl:if>
+						<xsl:if test="ancestor::feature//@arch">
+							<tr><td class="log-text" id="indent">Architecture:</td>
+							<td class="log-text" id="indent"><xsl:value-of select="ancestor::feature//@arch"/></td>
+							</tr>
+						</xsl:if>
+					</table>
+				</td>
+			</tr>
+			</xsl:for-each>
+			<tr><td class="spacer"><br/></td><td class="spacer"><br/></td></tr>
+		</xsl:if>
+	</xsl:for-each>
+	<xsl:if test="count(feature)  &gt; count(feature/category)">
+	<tr class="header">
+		<td class="sub-header" colspan="2">
+		Uncategorized
+		</td>
+	</tr>
+	</xsl:if>
+	<xsl:choose>
+	<xsl:when test="function-available('msxsl:node-set')">
+	   <xsl:variable name="rtf-nodes">
+		<xsl:for-each select="feature[not(category)]">
+			<xsl:sort select="@id" order="ascending" case-order="upper-first"/>
+			<xsl:sort select="@version" order="ascending" />
+			<xsl:value-of select="."/>
+			<xsl:copy-of select="." />
+		</xsl:for-each>
+	   </xsl:variable>
+	   <xsl:variable name="myNodeSet" select="msxsl:node-set($rtf-nodes)/*"/>
+	<xsl:for-each select="$myNodeSet">
+	<tr>
+		<xsl:choose>
+		<xsl:when test="position() mod 2 = 1">
+		<xsl:attribute name="class">dark-row</xsl:attribute>
+		</xsl:when>
+		<xsl:otherwise>
+		<xsl:attribute name="class">light-row</xsl:attribute>
+		</xsl:otherwise>
+		</xsl:choose>
+		<td class="log-text" id="indent">
+			<xsl:choose>
+			<xsl:when test="@label">
+				<a href="{@url}"><xsl:value-of select="@label"/></a>
+				<br />
+				<div id="indent">
+				(<xsl:value-of select="@id"/> - <xsl:value-of select="@version"/>)
+				</div>
+			</xsl:when>
+			<xsl:otherwise>
+				<a href="{@url}"><xsl:value-of select="@id"/> - <xsl:value-of select="@version"/></a>
+			</xsl:otherwise>
+			</xsl:choose>
+			<br /><br />
+		</td>
+		<td>
+			<table>
+				<xsl:if test="@os">
+					<tr><td class="log-text" id="indent">Operating Systems:</td>
+					<td class="log-text" id="indent"><xsl:value-of select="@os"/></td>
+					</tr>
+				</xsl:if>
+				<xsl:if test="@ws">
+					<tr><td class="log-text" id="indent">Windows Systems:</td>
+					<td class="log-text" id="indent"><xsl:value-of select="@ws"/></td>
+					</tr>
+				</xsl:if>
+				<xsl:if test="@nl">
+					<tr><td class="log-text" id="indent">Languages:</td>
+					<td class="log-text" id="indent"><xsl:value-of select="@nl"/></td>
+					</tr>
+				</xsl:if>
+				<xsl:if test="@arch">
+					<tr><td class="log-text" id="indent">Architecture:</td>
+					<td class="log-text" id="indent"><xsl:value-of select="@arch"/></td>
+					</tr>
+				</xsl:if>
+			</table>
+		</td>
+	</tr>
+	</xsl:for-each>
+	</xsl:when>
+	<xsl:otherwise>
+	<xsl:for-each select="feature[not(category)]">
+	<xsl:sort select="@id" order="ascending" case-order="upper-first"/>
+	<xsl:sort select="@version" order="ascending" />
+	<tr>
+		<xsl:choose>
+		<xsl:when test="count(preceding-sibling::feature[not(category)]) mod 2 = 1">
+		<xsl:attribute name="class">dark-row</xsl:attribute>
+		</xsl:when>
+		<xsl:otherwise>
+		<xsl:attribute name="class">light-row</xsl:attribute>
+		</xsl:otherwise>
+		</xsl:choose>
+		<td class="log-text" id="indent">
+			<xsl:choose>
+			<xsl:when test="@label">
+				<a href="{@url}"><xsl:value-of select="@label"/></a>
+				<br />
+				<div id="indent">
+				(<xsl:value-of select="@id"/> - <xsl:value-of select="@version"/>)
+				</div>
+			</xsl:when>
+			<xsl:otherwise>
+				<a href="{@url}"><xsl:value-of select="@id"/> - <xsl:value-of select="@version"/></a>
+			</xsl:otherwise>
+			</xsl:choose>
+			<br /><br />
+		</td>
+		<td>
+			<table>
+				<xsl:if test="@os">
+					<tr><td class="log-text" id="indent">Operating Systems:</td>
+					<td class="log-text" id="indent"><xsl:value-of select="@os"/></td>
+					</tr>
+				</xsl:if>
+				<xsl:if test="@ws">
+					<tr><td class="log-text" id="indent">Windows Systems:</td>
+					<td class="log-text" id="indent"><xsl:value-of select="@ws"/></td>
+					</tr>
+				</xsl:if>
+				<xsl:if test="@nl">
+					<tr><td class="log-text" id="indent">Languages:</td>
+					<td class="log-text" id="indent"><xsl:value-of select="@nl"/></td>
+					</tr>
+				</xsl:if>
+				<xsl:if test="@arch">
+					<tr><td class="log-text" id="indent">Architecture:</td>
+					<td class="log-text" id="indent"><xsl:value-of select="@arch"/></td>
+					</tr>
+				</xsl:if>
+			</table>
+		</td>
+	</tr>
+	</xsl:for-each>
+	</xsl:otherwise>
+	</xsl:choose>
+	</table>
+	</body>
+	</html>
+</xsl:for-each>
+</xsl:template>
+</xsl:stylesheet>