1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

- Initial contribution of the nightly build framework.

This commit is contained in:
Doug Schaefer 2003-07-16 19:41:52 +00:00
parent b398594ee8
commit 55a837daad
14 changed files with 1138 additions and 0 deletions

View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/"/>
<classpathentry kind="lib" path="ftp.jar"/>
<classpathentry kind="src" path="/org.eclipse.core.resources"/>
<classpathentry kind="src" path="/org.eclipse.ui"/>
<classpathentry kind="src" path="/org.eclipse.core.runtime"/>
<classpathentry kind="src" path="/org.eclipse.team.cvs.core"/>
<classpathentry kind="src" path="/org.eclipse.team.core"/>
<classpathentry kind="src" path="/org.eclipse.pde.core"/>
<classpathentry kind="src" path="/org.eclipse.pde.ui"/>
<classpathentry kind="src" path="/org.eclipse.core.boot"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1 @@
bin

View file

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.cdt.releng</name>
<comment></comment>
<projects>
<project>org.eclipse.core.boot</project>
<project>org.eclipse.core.resources</project>
<project>org.eclipse.core.runtime</project>
<project>org.eclipse.pde.core</project>
<project>org.eclipse.pde.ui</project>
<project>org.eclipse.team.core</project>
<project>org.eclipse.team.cvs.core</project>
<project>org.eclipse.ui</project>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,455 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" indent="yes"/>
<xsl:decimal-format decimal-separator="." grouping-separator="," />
<xsl:template match="testsuites">
<HTML>
<HEAD>
<style type="text/css">
body {
font:normal 68% verdana,arial,helvetica;
color:#000000;
}
table tr td, table tr th {
font-size: 68%;
}
table.details tr th{
font-weight: bold;
text-align:left;
background:#a6caf0;
}
table.details tr td{
background:#eeeee0;
}
p {
line-height:1.5em;
margin-top:0.5em; margin-bottom:1.0em;
}
h1 {
margin: 0px 0px 5px; font: 165% verdana,arial,helvetica
}
h2 {
margin-top: 1em; margin-bottom: 0.5em; font: bold 125% verdana,arial,helvetica
}
h3 {
margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica
}
h4 {
margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
}
h5 {
margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
}
h6 {
margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
}
.Error {
font-weight:bold; color:red;
}
.Failure {
font-weight:bold; color:purple;
}
.Properties {
text-align:right;
}
</style>
<script language="JavaScript">
var TestCases = new Array();
var cur;
<xsl:for-each select="./testsuite">
<xsl:apply-templates select="properties"/>
</xsl:for-each>
</script>
<script language="JavaScript"><![CDATA[
function displayProperties (name) {
var win = window.open('','JUnitSystemProperties','scrollbars=1,resizable=1');
var doc = win.document.open();
doc.write("<html><head><title>Properties of " + name + "</title>");
doc.write("<style>")
doc.write("body {font:normal 68% verdana,arial,helvetica; color:#000000; }");
doc.write("table tr td, table tr th { font-size: 68%; }");
doc.write("table.properties { border-collapse:collapse; border-left:solid 1 #cccccc; border-top:solid 1 #cccccc; padding:5px; }");
doc.write("table.properties th { text-align:left; border-right:solid 1 #cccccc; border-bottom:solid 1 #cccccc; background-color:#eeeeee; }");
doc.write("table.properties td { font:normal; text-align:left; border-right:solid 1 #cccccc; border-bottom:solid 1 #cccccc; background-color:#fffffff; }");
doc.write("h3 { margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica }");
doc.write("</style>");
doc.write("</head><body>");
doc.write("<h3>Properties of " + name + "</h3>");
doc.write("<div align=\"right\"><a href=\"javascript:window.close();\">Close</a></div>");
doc.write("<table class='properties'>");
doc.write("<tr><th>Name</th><th>Value</th></tr>");
for (prop in TestCases[name]) {
doc.write("<tr><th>" + prop + "</th><td>" + TestCases[name][prop] + "</td></tr>");
}
doc.write("</table>");
doc.write("</body></html>");
doc.close();
win.focus();
}
]]>
</script>
</HEAD>
<body>
<a name="#top"></a>
<xsl:call-template name="pageHeader"/>
<!-- Summary part -->
<xsl:call-template name="summary"/>
<hr size="1" width="95%" align="left"/>
<!-- Package List part -->
<xsl:call-template name="packagelist"/>
<hr size="1" width="95%" align="left"/>
<!-- For each package create its part -->
<xsl:call-template name="packages"/>
<hr size="1" width="95%" align="left"/>
<!-- For each class create the part -->
<xsl:call-template name="classes"/>
</body>
</HTML>
</xsl:template>
<!-- ================================================================== -->
<!-- Write a list of all packages with an hyperlink to the anchor of -->
<!-- of the package name. -->
<!-- ================================================================== -->
<xsl:template name="packagelist">
<h2>Packages</h2>
Note: package statistics are not computed recursively, they only sum up all of its testsuites numbers.
<table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
<xsl:call-template name="testsuite.test.header"/>
<!-- list all packages recursively -->
<xsl:for-each select="./testsuite[not(./@package = preceding-sibling::testsuite/@package)]">
<xsl:sort select="@package"/>
<xsl:variable name="testsuites-in-package" select="/testsuites/testsuite[./@package = current()/@package]"/>
<xsl:variable name="testCount" select="sum($testsuites-in-package/@tests)"/>
<xsl:variable name="errorCount" select="sum($testsuites-in-package/@errors)"/>
<xsl:variable name="failureCount" select="sum($testsuites-in-package/@failures)"/>
<xsl:variable name="timeCount" select="sum($testsuites-in-package/@time)"/>
<!-- write a summary for the package -->
<tr valign="top">
<!-- set a nice color depending if there is an error/failure -->
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="$failureCount &gt; 0">Failure</xsl:when>
<xsl:when test="$errorCount &gt; 0">Error</xsl:when>
</xsl:choose>
</xsl:attribute>
<td><a href="#{@package}"><xsl:value-of select="@package"/></a></td>
<td><xsl:value-of select="$testCount"/></td>
<td><xsl:value-of select="$errorCount"/></td>
<td><xsl:value-of select="$failureCount"/></td>
<td>
<xsl:call-template name="display-time">
<xsl:with-param name="value" select="$timeCount"/>
</xsl:call-template>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<!-- ================================================================== -->
<!-- Write a package level report -->
<!-- It creates a table with values from the document: -->
<!-- Name | Tests | Errors | Failures | Time -->
<!-- ================================================================== -->
<xsl:template name="packages">
<!-- create an anchor to this package name -->
<xsl:for-each select="/testsuites/testsuite[not(./@package = preceding-sibling::testsuite/@package)]">
<xsl:sort select="@package"/>
<a name="#{@package}"></a>
<h3>Package <xsl:value-of select="@package"/></h3>
<table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
<xsl:call-template name="testsuite.test.header"/>
<!-- match the testsuites of this package -->
<xsl:apply-templates select="/testsuites/testsuite[./@package = current()/@package]" mode="print.test"/>
</table>
<a href="#top">Back to top</a>
<p/>
<p/>
</xsl:for-each>
</xsl:template>
<xsl:template name="classes">
<xsl:for-each select="testsuite">
<xsl:sort select="@name"/>
<!-- create an anchor to this class name -->
<a name="#{@name}"></a>
<h3>TestCase <xsl:value-of select="@name"/></h3>
<table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
<xsl:call-template name="testcase.test.header"/>
<!--
test can even not be started at all (failure to load the class)
so report the error directly
-->
<xsl:if test="./error">
<tr class="Error">
<td colspan="4"><xsl:apply-templates select="./error"/></td>
</tr>
</xsl:if>
<xsl:apply-templates select="./testcase" mode="print.test"/>
</table>
<div class="Properties">
<a>
<xsl:attribute name="href">javascript:displayProperties('<xsl:value-of select="@package"/>.<xsl:value-of select="@name"/>');</xsl:attribute>
Properties &gt;&gt;
</a>
</div>
<p/>
<a href="#top">Back to top</a>
</xsl:for-each>
</xsl:template>
<xsl:template name="summary">
<h2>Summary</h2>
<xsl:variable name="testCount" select="sum(testsuite/@tests)"/>
<xsl:variable name="errorCount" select="sum(testsuite/@errors)"/>
<xsl:variable name="failureCount" select="sum(testsuite/@failures)"/>
<xsl:variable name="timeCount" select="sum(testsuite/@time)"/>
<xsl:variable name="successRate" select="($testCount - $failureCount - $errorCount) div $testCount"/>
<table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
<tr valign="top">
<th>Tests</th>
<th>Failures</th>
<th>Errors</th>
<th>Success rate</th>
<th>Time</th>
</tr>
<tr valign="top">
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="$failureCount &gt; 0">Failure</xsl:when>
<xsl:when test="$errorCount &gt; 0">Error</xsl:when>
</xsl:choose>
</xsl:attribute>
<td><xsl:value-of select="$testCount"/></td>
<td><xsl:value-of select="$failureCount"/></td>
<td><xsl:value-of select="$errorCount"/></td>
<td>
<xsl:call-template name="display-percent">
<xsl:with-param name="value" select="$successRate"/>
</xsl:call-template>
</td>
<td>
<xsl:call-template name="display-time">
<xsl:with-param name="value" select="$timeCount"/>
</xsl:call-template>
</td>
</tr>
</table>
<table border="0" width="95%">
<tr>
<td style="text-align: justify;">
Note: <i>failures</i> are anticipated and checked for with assertions while <i>errors</i> are unanticipated.
</td>
</tr>
</table>
</xsl:template>
<!--
Write properties into a JavaScript data structure.
This is based on the original idea by Erik Hatcher (erik@hatcher.net)
-->
<xsl:template match="properties">
cur = TestCases['<xsl:value-of select="../@package"/>.<xsl:value-of select="../@name"/>'] = new Array();
<xsl:for-each select="property">
<xsl:sort select="@name"/>
cur['<xsl:value-of select="@name"/>'] = '<xsl:call-template name="JS-escape"><xsl:with-param name="string" select="@value"/></xsl:call-template>';
</xsl:for-each>
</xsl:template>
<!-- Page HEADER -->
<xsl:template name="pageHeader">
<h1>Unit Test Results</h1>
<table width="100%">
<tr>
<td align="left"></td>
<td align="right">Designed for use with <a href='http://www.junit.org'>JUnit</a> and <a href='http://jakarta.apache.org/ant'>Ant</a>.</td>
</tr>
</table>
<hr size="1"/>
</xsl:template>
<xsl:template match="testsuite" mode="header">
<tr valign="top">
<th width="80%">Name</th>
<th>Tests</th>
<th>Errors</th>
<th>Failures</th>
<th nowrap="nowrap">Time(s)</th>
</tr>
</xsl:template>
<!-- class header -->
<xsl:template name="testsuite.test.header">
<tr valign="top">
<th width="80%">Name</th>
<th>Tests</th>
<th>Errors</th>
<th>Failures</th>
<th nowrap="nowrap">Time(s)</th>
</tr>
</xsl:template>
<!-- method header -->
<xsl:template name="testcase.test.header">
<tr valign="top">
<th>Name</th>
<th>Status</th>
<th width="80%">Type</th>
<th nowrap="nowrap">Time(s)</th>
</tr>
</xsl:template>
<!-- class information -->
<xsl:template match="testsuite" mode="print.test">
<tr valign="top">
<!-- set a nice color depending if there is an error/failure -->
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="@failures[.&gt; 0]">Failure</xsl:when>
<xsl:when test="@errors[.&gt; 0]">Error</xsl:when>
</xsl:choose>
</xsl:attribute>
<!-- print testsuite information -->
<td><a href="#{@name}"><xsl:value-of select="@name"/></a></td>
<td><xsl:value-of select="@tests"/></td>
<td><xsl:value-of select="@errors"/></td>
<td><xsl:value-of select="@failures"/></td>
<td>
<xsl:call-template name="display-time">
<xsl:with-param name="value" select="@time"/>
</xsl:call-template>
</td>
</tr>
</xsl:template>
<xsl:template match="testcase" mode="print.test">
<tr valign="top">
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="failure | error">Error</xsl:when>
</xsl:choose>
</xsl:attribute>
<td><xsl:value-of select="@name"/></td>
<xsl:choose>
<xsl:when test="failure">
<td>Failure</td>
<td><xsl:apply-templates select="failure"/></td>
</xsl:when>
<xsl:when test="error">
<td>Error</td>
<td><xsl:apply-templates select="error"/></td>
</xsl:when>
<xsl:otherwise>
<td>Success</td>
<td></td>
</xsl:otherwise>
</xsl:choose>
<td>
<xsl:call-template name="display-time">
<xsl:with-param name="value" select="@time"/>
</xsl:call-template>
</td>
</tr>
</xsl:template>
<xsl:template match="failure">
<xsl:call-template name="display-failures"/>
</xsl:template>
<xsl:template match="error">
<xsl:call-template name="display-failures"/>
</xsl:template>
<!-- Style for the error and failure in the tescase template -->
<xsl:template name="display-failures">
<xsl:choose>
<xsl:when test="not(@message)">N/A</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@message"/>
</xsl:otherwise>
</xsl:choose>
<!-- display the stacktrace -->
<code>
<p/>
<xsl:call-template name="br-replace">
<xsl:with-param name="word" select="."/>
</xsl:call-template>
</code>
<!-- the later is better but might be problematic for non-21" monitors... -->
<!--pre><xsl:value-of select="."/></pre-->
</xsl:template>
<xsl:template name="JS-escape">
<xsl:param name="string"/>
<xsl:choose><!-- something isn't right here, basically all single quotes need to be replaced with backslash-single-quote
<xsl:when test="contains($string,'&apos;')">
<xsl:value-of select="substring-before($string,'&apos;')"/>
\&apos;
<xsl:call-template name="JS-escape">
<xsl:with-param name="string" select="substring-after($string,'&apos;')"/>
</xsl:call-template>
</xsl:when> -->
<xsl:when test="contains($string,'\')">
<xsl:value-of select="substring-before($string,'\')"/>\\<xsl:call-template name="JS-escape">
<xsl:with-param name="string" select="substring-after($string,'\')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$string"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!--
template that will convert a carriage return into a br tag
@param word the text from which to convert CR to BR tag
-->
<xsl:template name="br-replace">
<xsl:param name="word"/>
<xsl:choose>
<xsl:when test="contains($word,'&#xA;')">
<xsl:value-of select="substring-before($word,'&#xA;')"/>
<br/>
<xsl:call-template name="br-replace">
<xsl:with-param name="word" select="substring-after($word,'&#xA;')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$word"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="display-time">
<xsl:param name="value"/>
<xsl:value-of select="format-number($value,'0.000')"/>
</xsl:template>
<xsl:template name="display-percent">
<xsl:param name="value"/>
<xsl:value-of select="format-number($value,'0.00%')"/>
</xsl:template>
</xsl:stylesheet>

View file

@ -0,0 +1,4 @@
source.releng.jar = src/
bin.includes = plugin.xml,\
*.jar,\
releng.jar

View file

@ -0,0 +1,16 @@
#
# The main build script
# - The assumption is that the scripts start off in the root directory
# of the eclipse install doing the build
#
if [ -n "$CDT_ROOT" ]; then cd $CDT_ROOT; fi
for i in dobuild doinstall dotest
do
if ! $i
then
echo $i failed
exit 1
fi
done

View file

@ -0,0 +1,19 @@
#
# Main build script
# - the following environment variables need to be set
# - $CDT_USER - the username to use on the eclipse download machine
# - $CDT_PASSWD - the password for that account
#
#
# Run Build
#
if [ -z "$CDT_USER" ]
then
echo CDT_USER environment variable not set
exit 1
fi
./eclipse -nosplash -application org.eclipse.cdt.releng.build \
-vmargs -Dcdt.build.user=$CDT_USER -Dcdt.build.passwd=$CDT_PASSWD

View file

@ -0,0 +1,32 @@
#
# Set up test environment
# - the assumption is that the necessary zip files are in a zip file
# in the eclipse install
#
rm -fr testspace
mkdir testspace
cd testspace
unzip -qq ../zip/eclipse-SDK-2.1.1-linux-gtk.zip
cd eclipse/plugins
unzip -qq ../../../zip/org.eclipse.test_2.1.0.zip
unzip -qq ../../../zip/org.eclipse.ant.optional.junit_2.1.0.zip
cd ..
export BUILD_SITE=../../workspace/build.site
for d in plugins features
do
for i in $BUILD_SITE/$d/*
do
export DEST=$d/`echo $i | sed -e s:$BUILD_SITE/$d/:: -e s/.jar//`
mkdir $DEST
cd $DEST
jar xf $i
cd ../..
done
done
# Back up to the top dir
cd ../..

View file

@ -0,0 +1,28 @@
#
# Run Tests
#
export RESULTS=`pwd`/results
rm -fr $RESULTS
mkdir $RESULTS
cd testspace/eclipse
# TODO - add in the rest of the test plugins
export PLUGINS='org.eclipse.cdt.core.tests'
for i in $PLUGINS
do
./eclipse -nosplash -application org.eclipse.ant.core.antRunner \
-f plugins/$i*/test.xml -Declipse-home=`pwd` \
-Dorg.eclipse.test=org.eclipse.test_2.1.0\
-Dos=linux -Dws=gtk -Darch=x86
mv $i*.xml $RESULTS
done
cd $RESULTS
for i in $PLUGINS
do
xsltproc ../workspace/org.eclipse.cdt.releng/JUNIT.XSL $i.xml > $i.html
done
cd ..

Binary file not shown.

View file

@ -0,0 +1,7 @@
<html>
<body>
Hi there.
</body>
</html>

View file

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin
id="org.eclipse.cdt.releng"
name="Releng Plug-in"
version="1.0.0"
provider-name="IBM Rational Software"
class="org.eclipse.cdt.releng.RelengPlugin">
<runtime>
<library name="releng.jar"/>
<library name="ftp.jar"/>
</runtime>
<requires>
<import plugin="org.eclipse.core.resources"/>
<import plugin="org.eclipse.ui"/>
<import plugin="org.eclipse.core.runtime"/>
<import plugin="org.eclipse.team.cvs.core"/>
<import plugin="org.eclipse.team.core"/>
<import plugin="org.eclipse.pde.core"/>
<import plugin="org.eclipse.pde.ui"/>
</requires>
<extension
id="build"
name="CDT Build"
point="org.eclipse.core.runtime.applications">
<application>
<run
class="org.eclipse.cdt.releng.DoBuild">
</run>
</application>
</extension>
</plugin>

View file

@ -0,0 +1,427 @@
package org.eclipse.cdt.releng;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.eclipse.core.boot.IPlatformRunnable;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.pde.core.plugin.IFragment;
import org.eclipse.pde.core.plugin.IPlugin;
import org.eclipse.pde.internal.core.feature.WorkspaceFeatureModel;
import org.eclipse.pde.internal.core.ifeature.IFeature;
import org.eclipse.pde.internal.core.ifeature.IFeatureChild;
import org.eclipse.pde.internal.core.ifeature.IFeatureImport;
import org.eclipse.pde.internal.core.ifeature.IFeaturePlugin;
import org.eclipse.pde.internal.core.isite.ISite;
import org.eclipse.pde.internal.core.isite.ISiteBuild;
import org.eclipse.pde.internal.core.isite.ISiteBuildFeature;
import org.eclipse.pde.internal.core.isite.ISiteCategory;
import org.eclipse.pde.internal.core.isite.ISiteCategoryDefinition;
import org.eclipse.pde.internal.core.isite.ISiteFeature;
import org.eclipse.pde.internal.core.isite.ISiteModelFactory;
import org.eclipse.pde.internal.core.plugin.WorkspaceFragmentModel;
import org.eclipse.pde.internal.core.plugin.WorkspacePluginModel;
import org.eclipse.pde.internal.core.site.WorkspaceSiteBuildModel;
import org.eclipse.pde.internal.core.site.WorkspaceSiteModel;
import org.eclipse.pde.internal.ui.editor.site.FeatureBuildOperation;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSTag;
import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import com.enterprisedt.net.ftp.FTPClient;
import com.enterprisedt.net.ftp.FTPConnectMode;
import com.enterprisedt.net.ftp.FTPException;
import com.enterprisedt.net.ftp.FTPTransferType;
/**
* @see IPlatformRunnable
*/
public class DoBuild implements IPlatformRunnable {
private IWorkspace workspace;
private String version;
private IProgressMonitor monitor;
private static String locstr = ":pserver:anonymous@dev.eclipse.org:/home/tools";
private static final String ftpHost = "download.eclipse.org";
private static final String ftpPath = "cdt/updates/builds/1.2";
private static final String ftpUser = System.getProperty("cdt.build.user");
private static final String ftpPassword = System.getProperty("cdt.build.passwd");
private static final String[] plugins = {
// Code
"org.eclipse.cdt.core",
"org.eclipse.cdt.core.tests",
"org.eclipse.cdt.ui",
"org.eclipse.cdt.ui.tests",
"org.eclipse.cdt.debug.core",
"org.eclipse.cdt.debug.ui",
"org.eclipse.cdt.debug.ui.tests",
"org.eclipse.cdt.debug.mi.core",
"org.eclipse.cdt.debug.mi.ui",
"org.eclipse.cdt.launch",
// Docs
"org.eclipse.cdt.doc.user",
// Features
"org.eclipse.cdt",
"org.eclipse.cdt.linux.gtk",
"org.eclipse.cdt.linux.motif",
"org.eclipse.cdt.qnx.photon",
"org.eclipse.cdt.solaris.motif",
"org.eclipse.cdt.win32",
"org.eclipse.cdt.source",
"org.eclipse.cdt.testing"
};
private static final String[] fragments = {
"org.eclipse.cdt.core.linux",
"org.eclipse.cdt.core.qnx",
"org.eclipse.cdt.core.solaris",
"org.eclipse.cdt.core.win32",
};
private static final String[] featureProjects = {
"org.eclipse.cdt-feature",
"org.eclipse.cdt.linux.gtk-feature",
"org.eclipse.cdt.linux.motif-feature",
"org.eclipse.cdt.qnx.photon-feature",
"org.eclipse.cdt.solaris.motif-feature",
"org.eclipse.cdt.win32-feature",
"org.eclipse.cdt.source-feature",
"org.eclipse.cdt.testing-feature"
};
private static final String[] buildFeatures = {
"org.eclipse.cdt",
"org.eclipse.cdt.linux.gtk",
"org.eclipse.cdt.linux.motif",
"org.eclipse.cdt.qnx.photon",
"org.eclipse.cdt.solaris.motif",
"org.eclipse.cdt.win32",
"org.eclipse.cdt.source",
"org.eclipse.cdt.testing"
};
private static final boolean[] externalFeatures = {
false, //"org.eclipse.cdt"
true, //"org.eclipse.cdt.linux.gtk"
true, //"org.eclipse.cdt.linux.motif"
true, //"org.eclipse.cdt.qnx.photon"
true, //"org.eclipse.cdt.solaris.motif"
true, //"org.eclipse.cdt.win32"
true, //"org.eclipse.cdt.source"
true, //"org.eclipse.cdt.testing"
};
private static String[] projects;
static {
// Create the projects array
projects = new String[plugins.length + fragments.length + featureProjects.length];
System.arraycopy(plugins, 0, projects, 0, plugins.length);
int i = plugins.length;
System.arraycopy(fragments, 0, projects, i, fragments.length);
i += fragments.length;
System.arraycopy(featureProjects, 0, projects, i, featureProjects.length);
}
/**
* @see IPlatformRunnable#run
*/
public Object run(Object args) throws Exception {
long start = System.currentTimeMillis();
workspace = ResourcesPlugin.getWorkspace();
monitor = new NullProgressMonitor();
deleteOldProjects();
downloadNewProjects();
downloadUpdateSite();
updateVersions();
buildUpdateSite();
uploadUpdateSite();
long time = System.currentTimeMillis() - start;
long minutes = time / 60000;
time -= minutes * 60000;
long seconds = time / 1000;
time -= seconds * 1000;
System.out.println("Done: "
+ minutes + ":" + (seconds < 10 ? "0" : "") + seconds
+ "." + time);
return null;
}
private void deleteOldProjects() throws CoreException {
System.out.println("Deleting old projects");
for (int i = 0; i < projects.length; ++i) {
IProject project = workspace.getRoot().getProject(projects[i]);
if (project.exists()) {
project.delete(false, monitor);
}
}
}
private void downloadNewProjects() throws CVSException, TeamException {
// Download the new projects
ICVSRepositoryLocation location = CVSRepositoryLocation.fromString(locstr);
for (int i = 0; i < projects.length; ++i) {
System.out.println("Downloading " + projects[i]);
CVSWorkspaceRoot.checkout(
location,
null,
projects[i],
CVSTag.DEFAULT,
monitor);
}
}
private void downloadUpdateSite() throws IOException, CoreException, FTPException {
System.out.println("Downloading update site");
// Find and create the local location to download to
IProject buildSite = workspace.getRoot().getProject("build.site");
// Download from the FTP site
FTPClient ftp = new FTPClient(ftpHost);
ftp.setConnectMode(FTPConnectMode.ACTIVE);
ftp.login(ftpUser, ftpPassword);
ftp.chdir(ftpPath);
IFile file = buildSite.getFile("version.xml");
OutputStream stream = new FileOutputStream(file.getRawLocation().toOSString());
ftp.get(stream, "version.xml");
stream.close();
file = buildSite.getFile("site.xml");
stream = new FileOutputStream(file.getRawLocation().toOSString());
ftp.get(stream, "site.xml");
stream.close();
IFolder folder = buildSite.getFolder(".sitebuild");
file = folder.getFile("sitebuild.xml");
stream = new FileOutputStream(file.getRawLocation().toOSString());
ftp.chdir(".sitebuild");
ftp.get(stream, "sitebuild.xml");
stream.close();
ftp.quit();
buildSite.refreshLocal(IResource.DEPTH_INFINITE, monitor);
}
private void updateVersions() throws Exception {
System.out.println("Setting versions");
// Get and increment the version
IProject siteProject = workspace.getRoot().getProject("build.site");
IFile versionFile = siteProject.getFile("version.xml");
versionFile.refreshLocal(IResource.DEPTH_ONE, monitor);
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = builderFactory.newDocumentBuilder();
Document versionDoc = builder.parse(versionFile.getContents());
Element versionElem = versionDoc.getDocumentElement();
String versionId = versionElem.getAttribute("id");
String buildNum = versionElem.getAttribute("build");
buildNum = String.valueOf(Integer.decode(buildNum).intValue() + 1);
versionElem.setAttribute("build", buildNum);
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
File versionResult = new File(versionFile.getRawLocation().toOSString());
transformer.transform(new DOMSource(versionDoc), new StreamResult(versionResult));
versionFile.refreshLocal(IResource.DEPTH_ONE, monitor);
version = versionId + "." + buildNum;
System.out.println("Version: " + version);
// Go through the projects and update the version info
for (int i = 0; i < plugins.length; ++i) {
IProject project = workspace.getRoot().getProject(plugins[i]);
IFile pluginxml = project.getFile("plugin.xml");
pluginxml.refreshLocal(IResource.DEPTH_ONE, monitor);
WorkspacePluginModel pluginModel = new WorkspacePluginModel(pluginxml);
pluginModel.load();
IPlugin plugin = pluginModel.getPlugin();
plugin.setVersion(version);
pluginModel.save();
pluginxml.refreshLocal(IResource.DEPTH_ONE, monitor);
}
for (int i = 0; i < fragments.length; ++i) {
IProject project = workspace.getRoot().getProject(fragments[i]);
IFile fragmentxml = project.getFile("fragment.xml");
fragmentxml.refreshLocal(IResource.DEPTH_ONE, monitor);
WorkspaceFragmentModel fragmentModel = new WorkspaceFragmentModel(fragmentxml);
fragmentModel.load();
IFragment fragment = fragmentModel.getFragment();
fragment.setVersion(version);
fragment.setPluginVersion(version);
fragmentModel.save();
fragmentxml.refreshLocal(IResource.DEPTH_ONE, monitor);
}
for (int i = 0; i < featureProjects.length; ++i) {
IProject project = workspace.getRoot().getProject(featureProjects[i]);
IFile featurexml = project.getFile("feature.xml");
featurexml.refreshLocal(IResource.DEPTH_ONE, monitor);
WorkspaceFeatureModel featureModel = new WorkspaceFeatureModel(featurexml);
featureModel.load();
IFeature feature = featureModel.getFeature();
feature.setVersion(version);
IFeaturePlugin[] plugins = feature.getPlugins();
for (int j = 0; j < plugins.length; ++j)
if (plugins[j].getId().startsWith("org.eclipse.cdt"))
plugins[j].setVersion(version);
IFeatureChild[] children = feature.getIncludedFeatures();
for (int j = 0; j < children.length; ++j)
if (children[j].getId().startsWith("org.eclipse.cdt"))
children[j].setVersion(version);
IFeatureImport[] imports = feature.getImports();
for (int j = 0; j < imports.length; ++j)
if (imports[j].getId().startsWith("org.eclipse.cdt"))
imports[j].setVersion(version);
featureModel.save();
featurexml.refreshLocal(IResource.DEPTH_ONE, monitor);
}
}
private void buildUpdateSite() throws Exception {
System.out.println("Seting up build site");
// Get the models set up.
IProject siteProject = workspace.getRoot().getProject("build.site");
IFile siteFile = siteProject.getFile("site.xml");
siteFile.refreshLocal(IResource.DEPTH_ONE, monitor);
WorkspaceSiteModel siteModel = new WorkspaceSiteModel(siteFile);
siteModel.load();
ISiteModelFactory siteModelFactory = siteModel.getFactory();
ISite site = siteModel.getSite();
IFile siteBuildFile = siteProject.getFile(".sitebuild/sitebuild.xml");
siteBuildFile.refreshLocal(IResource.DEPTH_ONE, monitor);
WorkspaceSiteBuildModel buildModel = new WorkspaceSiteBuildModel(siteBuildFile);
buildModel.load();
ISiteBuild siteBuild = buildModel.getSiteBuild();
// Add in the features
ISiteCategoryDefinition categoryDef = siteModelFactory.createCategoryDefinition();
String categoryName = "CDT Build " + version;
categoryDef.setLabel(categoryName);
categoryDef.setName(categoryName);
site.addCategoryDefinitions(new ISiteCategoryDefinition[] {categoryDef});
ArrayList buildList = new ArrayList();
ArrayList externalList = new ArrayList();
for (int i = 0; i < buildFeatures.length; ++i) {
ISiteBuildFeature buildFeature = buildModel.createFeature();
buildFeature.setId(buildFeatures[i]);
buildFeature.setVersion(version);
buildList.add(buildFeature);
if (externalFeatures[i]) {
ISiteFeature feature = siteModelFactory.createFeature();
feature.setId(buildFeatures[i]);
feature.setVersion(version);
feature.setURL("features/" + buildFeatures[i] + "_" + version + ".jar");
ISiteCategory category = siteModelFactory.createCategory(feature);
category.setName(categoryName);
feature.addCategories(new ISiteCategory[] {category});
externalList.add(feature);
}
}
siteBuild.addFeatures((ISiteBuildFeature[])buildList.toArray(new ISiteBuildFeature[buildList.size()]));
site.addFeatures((ISiteFeature[])externalList.toArray(new ISiteFeature[externalList.size()]));
// Save the models
siteModel.save();
siteFile.refreshLocal(IResource.DEPTH_ONE, monitor);
buildModel.save();
siteBuildFile.refreshLocal(IResource.DEPTH_ONE, monitor);
// Do the build
System.out.println("Building");
FeatureBuildOperation op
= new FeatureBuildOperation(
buildList, null, true, true);
op.run(monitor);
}
private void uploadUpdateSite() throws Exception {
System.out.println("Uploading to site");
IProject buildSite = workspace.getRoot().getProject("build.site");
buildSite.refreshLocal(IResource.DEPTH_INFINITE, monitor);
// Open the ftp site
FTPClient ftp = new FTPClient(ftpHost);
ftp.setConnectMode(FTPConnectMode.ACTIVE);
ftp.login(ftpUser, ftpPassword);
ftp.setType(FTPTransferType.BINARY);
ftp.chdir(ftpPath);
IFile file = buildSite.getFile("version.xml");
ftp.put(file.getContents(), "version.xml");
file = buildSite.getFile("site.xml");
ftp.put(file.getContents(), "site.xml");
IFolder folder = buildSite.getFolder(".sitebuild");
ftp.chdir(".sitebuild");
file = folder.getFile("sitebuild.xml");
ftp.put(file.getContents(), "sitebuild.xml");
folder = buildSite.getFolder("plugins");
ftp.chdir("../plugins");
for (int i = 0; i < plugins.length; ++i) {
String name = plugins[i] + "_" + version + ".jar";
System.out.println("Uploading plugin: " + name);
file = folder.getFile(name);
ftp.put(file.getContents(), name);
}
for (int i = 0; i < fragments.length; ++i) {
String name = fragments[i] + "_" + version + ".jar";
System.out.println("Uploading fragment: " + name);
file = folder.getFile(name);
ftp.put(file.getContents(), name);
}
folder = buildSite.getFolder("features");
ftp.chdir("../features");
for (int i = 0; i < buildFeatures.length; ++i) {
String name = buildFeatures[i] + "_" + version + ".jar";
System.out.println("Uploading feature: " + name);
file = folder.getFile(name);
ftp.put(file.getContents(), name);
}
ftp.quit();
}
}

View file

@ -0,0 +1,63 @@
package org.eclipse.cdt.releng;
import org.eclipse.ui.plugin.*;
import org.eclipse.core.runtime.*;
import org.eclipse.core.resources.*;
import java.util.*;
/**
* The main plugin class to be used in the desktop.
*/
public class RelengPlugin extends AbstractUIPlugin {
//The shared instance.
private static RelengPlugin plugin;
//Resource bundle.
private ResourceBundle resourceBundle;
/**
* The constructor.
*/
public RelengPlugin(IPluginDescriptor descriptor) {
super(descriptor);
plugin = this;
try {
resourceBundle= ResourceBundle.getBundle("org.eclipse.cdt.releng.RelengPluginResources");
} catch (MissingResourceException x) {
resourceBundle = null;
}
}
/**
* Returns the shared instance.
*/
public static RelengPlugin getDefault() {
return plugin;
}
/**
* Returns the workspace instance.
*/
public static IWorkspace getWorkspace() {
return ResourcesPlugin.getWorkspace();
}
/**
* Returns the string from the plugin's resource bundle,
* or 'key' if not found.
*/
public static String getResourceString(String key) {
ResourceBundle bundle= RelengPlugin.getDefault().getResourceBundle();
try {
return bundle.getString(key);
} catch (MissingResourceException e) {
return key;
}
}
/**
* Returns the plugin's resource bundle,
*/
public ResourceBundle getResourceBundle() {
return resourceBundle;
}
}