Switch to CDO style build
diff --git a/releng/org.eclipse.graphiti.releng/build.xml b/releng/org.eclipse.graphiti.releng/build.xml
index 5e4654f..a22f0fd 100644
--- a/releng/org.eclipse.graphiti.releng/build.xml
+++ b/releng/org.eclipse.graphiti.releng/build.xml
@@ -1,168 +1,152 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!-- 
-Copyright (c) 2010 SAP 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
+<?xml version="1.0"?>
+<project name="CDO">
 
-Contributors:
-  Cloudsmith Inc - build.xml for Buckminster project
-  Martin Taal - changes for Teneo
-  Michael Wenz - changes Graphiti
+	<condition property="properties.file" value="build.properties" else="local.properties">
+		<isset property="server.build" />
+	</condition>
 
-The Teneo build.xml was used as a template for creating this file:
-http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.emf/org.eclipse.emf.teneo/releng/org.eclipse.emf.teneo.releng.buckminster/build.xml?root=Modeling_Project&view=log
+	<condition property="mspec.file" value="build.mspec" else="local.mspec">
+		<isset property="server.build" />
+	</condition>
 
-Some important parts have been copied from Buckminster's own build setup:
-http://dev.eclipse.org/viewsvn/index.cgi/trunk/org.eclipse.buckminster.releng/build.xml?root=Tools_BUCKMINSTER&view=markup
--->
-
-<project default="build.and.test" name="Graphiti Build and Test Run">
-	<!-- load properties and set timestamp for the build -->
+	<property file="${properties.file}" />
 	<property environment="env" />
 
-	<tstamp>
-		<format property="buildTimestamp" pattern="yyyyMMddHHmm" />
-	</tstamp>
-
-	<property file="buckminster.properties" />
-
-	<condition property="hudsonWorkSpacePath" value="${env.WORKSPACE}" else="${basedir}/../">
+	<condition property="build.root" value="${env.WORKSPACE}" else="${basedir}/../build">
 		<isset property="env.WORKSPACE" />
 	</condition>
 
-	<condition property="graphiti.update.site.type" value="${env.GRAPHITI_UPDATE_SITE_TYPE}" else="interim">
-		<isset property="env.GRAPHITI_UPDATE_SITE_TYPE" />
-	</condition>
-
-	<condition property="site.pack200" value="${env.SITE_PACK200}" else="false">
-		<isset property="env.SITE_PACK200" />
-	</condition>
-
-	<condition property="site.signing" value="${env.SITE_SIGNING}" else="false">
-		<isset property="env.SITE_SIGNING" />
-	</condition>
-
-	<condition property="buckminster.loglevel" value="${env.BUCKMINSTER_LOGLEVEL}" else="info">
+	<condition property="buckminster.loglevel" value="${env.BUCKMINSTER_LOGLEVEL}" else="INFO">
 		<isset property="env.BUCKMINSTER_LOGLEVEL" />
 	</condition>
 
-	<!-- Is used in buck.minster also -->
-	<condition property="build.type" value="${env.BUILDTYPE}" else="N">
-		<isset property="env.BUILDTYPE" />
-	</condition>
-
-	<condition property="graphiti.version" value="${env.VERSION}" else="0.7.0">
-		<isset property="env.VERSION" />
-	</condition>
-
 	<condition property="clean.tools" value="true">
 		<equals arg1="${env.CLEAN_TOOLS}" arg2="true" />
 	</condition>
 
-	<property name="buildsPath" location="${hudsonWorkSpacePath}/build" />
+	<condition property="clean.tp" value="true">
+		<equals arg1="${env.CLEAN_TP}" arg2="true" />
+	</condition>
 
-	<!--property name="rootPath" location="${buildsPath}/${build.type}${buildTimestamp}"/-->
-	<property name="rootPath" location="${buildsPath}" />
+	<condition property="clean.workspace" value="true">
+		<equals arg1="${env.CLEAN_WORKSPACE}" arg2="true" />
+	</condition>
 
-	<property name="buildRoot" location="${rootPath}/build" />
-	<property name="testRoot" location="${rootPath}/test" />
-	<property name="toolsPath" location="${rootPath}/tools" />
-	<property name="buildSitePath" location="${rootPath}/result/p2site" />
-	<property name="buildZipsPath" location="${rootPath}/result/zips" />
-	<property name="testResultsPath" location="${rootPath}/result/test" />
+	<condition property="clean.output" value="true">
+		<equals arg1="${env.CLEAN_OUTPUT}" arg2="true" />
+	</condition>
 
-	<property name="promoteUpdateSite" location="${graphiti.download.area}/updates/${graphiti.update.site.type}" />
-	<property name="promoteDropsLocation" location="${graphiti.download.area}/downloads/drops" />
+	<condition property="build.type" value="${env.BUILD_TYPE}" else="N">
+		<isset property="env.BUILD_TYPE" />
+	</condition>
 
-	<property name="buckminster.output.root" location="${rootPath}/output" />
-	<property name="buckminster.temp.root" location="${rootPath}/temp" />
+	<condition property="build.nightly" value="true">
+		<equals arg1="${build.type}" arg2="N" />
+	</condition>
 
-	<import file="ant_common.xml" />
+	<condition property="site.pack200" value="${env.SITE_PACK200}" else="true">
+		<isset property="env.SITE_PACK200" />
+	</condition>
 
-	<target name="build.and.test" depends="init, init.checks, install.buckminster">
-		<echo message=""/>
-		<echo message="=========================================================================================="/>
-		<echo message="Building" />
-		<ant dir="${basedir}/build" antfile="graphiti_build.xml" target="run" inheritRefs="true" />
+	<condition property="site.signing" value="false" else="true">
+		<isset property="build.nightly" />
+	</condition>
 
-		<echo message=""/>
-		<echo message="=========================================================================================="/>
-		<echo message="Testing" />
-		<ant dir="${basedir}/test" antfile="graphiti_test.xml" target="run" inheritRefs="true" />
-	</target>
+	<!-- Default properties intended to be overridden by entries in the above property file -->
+	<property name="tools" location="${build.root}/tools" />
+	<property name="result" location="${build.root}/result" />
+	<property name="workspace" location="${result}/workspace" />
+	<property name="targetPlatformPath" location="${result}/tp" />
+	<property name="buckminster.output.root" location="${result}/output" />
+	<property name="buckminster.temp.root" location="${result}/temp" />
+	<property name="site.p2.dir" location="${workspace}/_temp/org.eclipse.graphiti.site_1.0.0-eclipse.feature/site.p2" />
 
-	<target name="promote" depends="init.build.properties">
-		<echo message="Promoting build update site" />
-		<echo message="from ${buildSitePath}" />
-		<echo message="to ${promoteUpdateSite}" />
+	<!-- This macro executes the default application of an eclipse installation
+			 that resides in the folder ${buildtools}/@app -->
+	<macrodef name="eclipse.launch">
+		<attribute name="app" />
+		<element name="args" optional="true" />
+		<sequential>
+			<!-- We assume that the eclipse installation is beneath ${buildtools} -->
+			<property name="@{app}.deploy.dir" value="${tools}/@{app}" />
 
-		<delete dir="${promoteUpdateSite}" />
-		<mkdir dir="${promoteUpdateSite}"/>
-		<mkdir dir="${promoteUpdateSite}/plugins"/>
-		<mkdir dir="${promoteUpdateSite}/features"/>
-		
-		<copy todir="${promoteUpdateSite}">
-			<fileset dir="${buildSitePath}">
-				<include name="**/*" />
-				<include name="**" />
-			</fileset>
-		</copy>
+			<!-- Find the Eclipse launcher and assing its location to the @{app}.launcher property -->
+			<pathconvert property="@{app}.launcher">
+				<first count="1">
+					<sort>
+						<fileset dir="${@{app}.deploy.dir}/plugins" includes="**/org.eclipse.equinox.launcher_*.jar" />
+						<reverse xmlns="antlib:org.apache.tools.ant.types.resources.comparators">
+							<date />
+						</reverse>
+					</sort>
+				</first>
+			</pathconvert>
 
-		<mkdir dir="${promoteDropsLocation}"/>
-		<mkdir dir="${promoteDropsLocation}/${graphiti.version}"/>
-		<mkdir dir="${promoteDropsLocation}/${graphiti.version}/${build.type}${buildTimestamp}"/>		
-		<copy todir="${promoteDropsLocation}/${graphiti.version}/${build.type}${buildTimestamp}">
-			<fileset dir="${buildZipsPath}">
-				<include name="*.zip" />
-			</fileset>
-		</copy>
-	</target>
+			<!-- Launch the eclipse application -->
+			<java fork="true" jar="${@{app}.launcher}" dir="${@{app}.deploy.dir}" failonerror="true">
+				<!-- Uncomment to debug <jvmarg value="-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=y"/> -->
+				<args />
+			</java>
+		</sequential>
+	</macrodef>
 
-	<target name="clean.all">
-		<echo message="Removing previous build" />
-		<delete dir="${rootPath}" quiet="true" />
-	</target>
+	<macrodef name="buckminster">
+		<attribute name="command" />
+		<attribute name="workspace" default="${workspace}" />
+		<element name="globargs" optional="true" />
+		<element name="cmdargs" optional="true" />
+		<sequential>
+			<eclipse.launch app="buckminster">
+				<args>
+					<jvmarg value="-Dbugfix.288796=true" />
+					<jvmarg value="-Xmx1024m" />
+					<arg value="-data" />
+					<arg value="@{workspace}" />
+					<arg value="--loglevel" />
+					<arg value="${buckminster.loglevel}" />
+					<arg value="--displaystacktrace" />
+					<globargs />
+					<arg value="@{command}" />
+					<arg value="-P" />
+					<arg value="${properties.tmp}" />
+					<cmdargs />
+				</args>
+			</eclipse.launch>
+		</sequential>
+	</macrodef>
 
 	<target name="init.clean.tools" if="clean.tools">
-		<delete dir="${toolsPath}" failonerror="true" quiet="true" />
+		<antcall target="clean.tools" />
 	</target>
 
-	<target name="init.checks" depends="init.clean.tools">
-		<available file="${toolsPath}/director/director" property="director.exists" />
-		<available file="${toolsPath}/buckminster/buckminster" property="buckminster.exists" />
+	<target name="init.clean.tp" if="clean.tp">
+		<antcall target="clean.tp" />
 	</target>
 
-	<target name="init" depends="clean.all">
+	<target name="init.clean.workspace" if="clean.workspace">
+		<antcall target="clean.workspace" />
+	</target>
 
-		<echo message="Creating main directories" />
-		<echo message="rootPath: ${rootPath}" />
-		<echo message="buildRoot: ${buildRoot}" />
-		<echo message="testRoot: ${testRoot}" />
-		<echo message="buildSitePath: ${buildSitePath}" />
-		<echo message="buildZipsPath: ${buildZipsPath}" />
-		<echo message="testResultsPath: ${testResultsPath}" />
-		<mkdir dir="${rootPath}" />
-		<mkdir dir="${buildRoot}" />
-		<mkdir dir="${testRoot}" />
-		<mkdir dir="${toolsPath}" />
-		<mkdir dir="${buildSitePath}" />
-		<mkdir dir="${buildZipsPath}" />
-		<mkdir dir="${testResultsPath}" />
-		<mkdir dir="${testResultsPath}/output" />
+	<target name="init.clean.output" if="clean.output">
+		<antcall target="clean.output" />
+	</target>
 
+	<target name="init.checks" depends="init.clean.tools,init.clean.tp,init.clean.workspace,init.clean.output">
+		<echo message="Sourcing ${properties.file}" />
 		<available file="${tools}/director/director" property="director.exists" />
 		<available file="${tools}/buckminster/buckminster" property="buckminster.exists" />
-
 	</target>
 
 	<target name="get.director" unless="director.exists">
 		<echo message="Fetching headless director application" />
-		<tempfile destdir="${java.io.tmpdir}" prefix="director-" suffix=".zip" property="director.zip" deleteonexit="true" />
-		<get src="${director.url}" dest="${director.zip}" />
+		<tempfile destdir="${java.io.tmpdir}"
+		          prefix="director-"
+		          suffix=".zip"
+		          property="director.zip"
+		          deleteonexit="true" />
+		<get src="${eclipse.downloads}/${director.path}" dest="${director.zip}" />
 		<mkdir dir="${tools}" />
-		<unzip src="${director.zip}" dest="${toolsPath}" />
+		<unzip src="${director.zip}" dest="${tools}" />
 		<delete file="${director.zip}" />
 	</target>
 
@@ -171,11 +155,14 @@
 		<eclipse.launch app="director">
 			<args>
 				<jvmarg value="-Declipse.p2.mirrors=false" />
-				<!--jvmarg value="-Dorg.eclipse.update.jarprocessor.pack200=${org.eclipse.update.jarprocessor.pack200}" /-->
+				<!--
+				Hudson Ant property: org.eclipse.update.jarprocessor.pack200=/shared/common/ibm-java2-ppc-50/jre/bin
+				<jvmarg value="-Dorg.eclipse.update.jarprocessor.pack200=${org.eclipse.update.jarprocessor.pack200}" />
+				-->
 				<arg value="-r" />
-				<arg value="${buckminster.p2.site}" />
+				<arg value="${eclipse.downloads}/${bm.headless.path}" />
 				<arg value="-d" />
-				<arg value="${toolsPath}/buckminster" />
+				<arg value="${tools}/buckminster" />
 				<arg value="-p" />
 				<arg value="Buckminster" />
 				<arg value="-i" />
@@ -192,10 +179,18 @@
 		</eclipse.launch>
 	</target>
 
+	<target name="init.workspace" unless="workspace.exists">
+		<mkdir dir="${workspace}" />
+	</target>
+
 	<target name="init.build.properties">
-		<!-- Echo relevant properties to a temporary file so that Buckminster can read them
-		  -->
-		<tempfile destdir="${java.io.tmpdir}" prefix="build-" suffix=".properties" deleteonexit="true" property="properties.tmp" />
+		<!-- Echo relevant properties to a temporary file so that Buckminster can read them -->
+		<tempfile destdir="${java.io.tmpdir}"
+		          prefix="build-"
+		          suffix=".properties"
+		          deleteonexit="true"
+		          property="properties.tmp" />
+		<echo message="Properties file is: ${properties.tmp}" />
 		<echoproperties destfile="${properties.tmp}">
 			<!-- We don't want these. basedir in particular will cause problems if passed explicitly -->
 			<propertyset negate="true">
@@ -212,4 +207,105 @@
 			</propertyset>
 		</echoproperties>
 	</target>
+
+	<target name="provision" depends="init.checks,init.workspace,install.buckminster,init.build.properties">
+		<echo message="Importing projects into workspace ${workspace} and binaries into target platform ${targetPlatformPath}" />
+		<buckminster command="setpref">
+			<cmdargs>
+				<arg value="targetPlatformPath=${targetPlatformPath}" />
+			</cmdargs>
+		</buckminster>
+
+		<buckminster command="import">
+			<cmdargs>
+				<arg value="-P" />
+				<arg value="${basedir}/${properties.file}" />
+				<arg value="${basedir}/${mspec.file}" />
+			</cmdargs>
+		</buckminster>
+	</target>
+
+	<target name="site.p2" depends="provision">
+		<echo message="Building all projects in workspace ${workspace}" />
+		<buckminster command="build">
+			<cmdargs>
+				<arg value="--thorough" />
+			</cmdargs>
+		</buckminster>
+
+		<echo message="Performing org.eclipse.graphiti.site#site.p2" />
+		<buckminster command="perform">
+			<cmdargs>
+				<arg value="org.eclipse.graphiti.site#site.p2" />
+			</cmdargs>
+		</buckminster>
+
+		<echo message="Creating human readable index.html" />
+		<unzip src="${site.p2.dir}/content.jar" dest="${site.p2.dir}" />
+		<xslt style="xsl/content2html.xsl" in="${site.p2.dir}/content.xml" out="${site.p2.dir}/index.html" />
+		<xslt style="xsl/content2xml.xsl" in="${site.p2.dir}/content.xml" out="${site.p2.dir}/index.xml" />
+		<delete file="${site.p2.dir}/content.xml" />
+	</target>
+
+	<target name="test" depends="site.p2">
+		<echo message="Running JUnit tests for Graphiti" />
+		<buckminster command="emma">
+			<cmdargs>
+				<arg value="-l" />
+				<arg value="org.eclipse.graphiti.tests/AllJunitTests.launch" />
+				<arg value="-o" />
+				<arg value="${result}/testReportJunitGraphiti.xml" />
+				<arg value="--terseXML" />
+				<arg value="--flatXML" />
+				<arg value="--xml" />
+				<arg value="${result}/coverageReportJunitGraphiti.xml" />
+			</cmdargs>
+		</buckminster>
+		<echo message="Running JUnit tests for GraphitiUI" />
+		<buckminster command="emma">
+			<cmdargs>
+				<arg value="-l" />
+				<arg value="org.eclipse.graphiti.ui.tests/AllJunitUiTests.launch" />
+				<arg value="-o" />
+				<arg value="${result}/testReportJunitGraphitiUi.xml" />
+				<arg value="--terseXML" />
+				<arg value="--flatXML" />
+				<arg value="--xml" />
+				<arg value="${result}/coverageReportJunitGraphitiUi.xml" />
+			</cmdargs>
+		</buckminster>
+	</target>
+
+	<target name="promote.sites" depends="provision">
+		<echo message="Building all projects in workspace ${workspace}" />
+		<buckminster command="build" />
+
+		<echo message="Performing org.eclipse.graphiti.releng#promote" />
+		<buckminster command="perform">
+			<cmdargs>
+				<arg value="org.eclipse.graphiti.releng#promote" />
+			</cmdargs>
+		</buckminster>
+	</target>
+
+	<target name="clean.tools">
+		<delete dir="${tools}/director" failonerror="true" quiet="true" />
+		<delete dir="${tools}/buckminster" failonerror="true" quiet="true" />
+	</target>
+
+	<target name="clean.tp">
+		<delete dir="${targetPlatformPath}" failonerror="true" quiet="true" />
+	</target>
+
+	<target name="clean.workspace">
+		<delete dir="${workspace}" failonerror="true" quiet="true" />
+	</target>
+
+	<target name="clean.output">
+		<delete dir="${buckminster.output.root}" failonerror="true" quiet="true" />
+		<delete dir="${buckminster.temp.root}" failonerror="true" quiet="true" />
+	</target>
+
+	<target name="clean.all" depends="clean.tools,clean.workspace,clean.tp,clean.output" />
+
 </project>