[110090] Port the performance scripts to the new WTP build infrastructure
diff --git a/releng.wtpbuilder/distribution/wtp.perf/build.xml b/releng.wtpbuilder/distribution/wtp.perf/build.xml
new file mode 100644
index 0000000..5ff006e
--- /dev/null
+++ b/releng.wtpbuilder/distribution/wtp.perf/build.xml
@@ -0,0 +1,175 @@
+<project default="main" basedir=".">
+
+	<!--
+	Required inputs:
+	
+	build.home
+	releng.tag
+	buildType
+	buildId
+	date
+	time
+	wtp.dir [optional]
+	perf.target [optional]
+	-->
+	
+	<target name="main">
+		<property file="${build.home}/releng.wtpbuilder/build.properties"/>
+		<property name="wtp.perf" value="${build.home}/releng.wtpbuilder/distribution/wtp.perf"/>
+		<property name="perfRoot" value="${wtp.perf}/perfRoot"/>
+		<mkdir dir="${perfRoot}"/>
+		<antcall target="getReleng"/>
+		<property file="${perfRoot}/releng/maps/dependencies.properties"/>
+		<antcall target="run"/>
+		<delete dir="${perfRoot}"/>
+	</target>
+
+	<target name="getReleng">
+		<cvs
+			cvsRoot=":pserver:anonymous@dev.eclipse.org:/home/webtools"
+			package="releng"
+			dest="${perfRoot}"
+			command="export"
+			tag="${releng.tag}"
+		/>
+	</target>
+
+	<target name="setup">
+		<delete dir="${perfRoot}/eclipse"/>
+		<property name="local.cache.dir" value="${build.home}/${build.local.repository}"/>
+		<property name="install.destination" value="${perfRoot}"/>
+		<mkdir dir="${local.cache.dir}"/>
+		<mkdir dir="${install.destination}"/>
+		<antcall target="getAndInstall">
+			<param name="groupId" value="eclipse" />
+			<param name="clean" value="true" />
+		</antcall>
+		<antcall target="getAndInstall">
+			<param name="groupId" value="eclipseTestFramework" />
+			<param name="clean" value="true" />
+		</antcall>
+		<antcall target="getAndInstall">
+			<param name="groupId" value="emf" />
+			<param name="clean" value="true" />
+		</antcall>
+		<antcall target="getAndInstall">
+			<param name="groupId" value="gef" />
+			<param name="clean" value="true" />
+		</antcall>
+		<antcall target="getAndInstall">
+			<param name="groupId" value="jem" />
+			<param name="clean" value="true" />
+		</antcall>
+		<antcall target="getAndInstall">
+			<param name="groupId" value="tomcat.5" />
+		</antcall>
+		<antcall target="getAndInstall">
+			<param name="groupId" value="tomcat.4" />
+		</antcall>
+		<antcall target="getAndInstall">
+			<param name="groupId" value="jonas.4" />
+		</antcall>
+		<antcall target="getAndInstall">
+			<param name="groupId" value="oagis.release" />
+		</antcall>
+		<antcall target="getAndInstall">
+			<param name="groupId" value="oagis.wsdl" />
+		</antcall>
+		<antcall target="getAndInstall">
+			<param name="groupId" value="derby" />
+		</antcall>
+		<antcall target="getAndInstallWTP">
+			<param name="file" value="wtp-${buildId}.zip" />
+		</antcall>
+		<antcall target="getAndInstallWTP">
+			<param name="file" value="wtp-wst-Automated-Tests-${buildId}.zip" />
+		</antcall>
+		<antcall target="getAndInstallWTP">
+			<param name="file" value="wtp-jst-Automated-Tests-${buildId}.zip" />
+		</antcall>
+		<antcall target="getAndInstallWTP">
+			<param name="file" value="wtp-wst-perf-Tests-${buildId}.zip" />
+		</antcall>
+		<antcall target="getAndInstallWTP">
+			<param name="file" value="wtp-jst-perf-Tests-${buildId}.zip" />
+		</antcall>
+		<antcall target="setup.derby"/>
+		<copy file="${wtp.perf}/performance-tests.xml" tofile="${perfRoot}/performance-tests.xml"></copy>
+	</target>
+
+	<target name="getAndInstall">
+		<property name="dependencyTargets" value="${build.home}/releng.wtpbuilder/scripts/dependency/build.xml"/>
+		<ant antfile="${dependencyTargets}" target="checkDependency">
+			<property name="groupId" value="${groupId}" />
+		</ant>
+		<ant antfile="${dependencyTargets}" target="installDependency">
+			<property name="groupId" value="${groupId}" />
+		</ant>
+	</target>
+
+	<target name="getAndInstallWTP">
+		<property name="wtp.dir" value="${local.cache.dir}"/>
+		<available file="${wtp.dir}/${file}" property="file.exists"/>
+		<antcall target="getWTP"/>
+		<unzip src="${wtp.dir}/${file}" dest="${install.destination}" overwrite="true"/>
+	</target>
+
+	<target name="getWTP" unless="file.exists">
+		<mkdir dir="${wtp.dir}"/>
+		<get dest="${wtp.dir}/${file}" src="http://download.eclipse.org/webtools/downloads/drops/${buildType}-${buildId}-${date}${time}/${file}"/>
+	</target>
+
+	<target name="setup.derby">
+		<property name="derby" value="${install.destination}/eclipse/plugins/org.apache.derby"/>
+		<mkdir dir="${derby}"/>
+		<copy todir="${derby}" overwrite="true">
+			<fileset dir="${perfRoot}/incubating-derby-10.0.2.1-bin/lib">
+				<include name="**/*.jar"/>
+			</fileset>
+		</copy>
+		<copy tofile="${derby}/plugin.xml" file="${wtp.perf}/derby.plugin.xml.template" overwrite="true"/>
+		<replace dir="${perfRoot}/eclipse/plugins" value="&lt;import plugin=&quot;org.apache.derby&quot;/&gt;">
+			<include name="org.eclipse.test.performance_*/plugin.xml"/>
+			<replacetoken><![CDATA[<import plugin="org.apache.derby" optional="true"/>]]></replacetoken>
+		</replace>
+	</target>
+
+	<target name="run">
+		<condition property="baseos" value="linux">
+			<os family="unix"/>
+		</condition>
+		<condition property="basews" value="gtk">
+			<os family="unix"/>
+		</condition>
+		<condition property="basearch" value="x86">
+			<os family="unix"/>
+		</condition>
+		<condition property="baseos" value="win32">
+			<os family="windows"/>
+		</condition>
+		<condition property="basews" value="win32">
+			<os family="windows"/>
+		</condition>
+		<condition property="basearch" value="x86">
+			<os family="windows"/>
+		</condition>
+		<property name="perf.target" value="main"/>
+		<ant antfile="${wtp.perf}/perf.xml" target="${perf.target}">
+			<property file="${wtp.perf}/perf.properties"/>
+			<property name="eclipse-home" value="${perfRoot}/eclipse"/>
+			<property name="perf.buildId" value="${buildType}${date}-${time}"/>
+			<property name="os" value="${baseos}"/>
+			<property name="ws" value="${basews}"/>
+			<property name="arch" value="${basearch}"/>
+			<property name="testDir" value="${perfRoot}"/>
+			<property name="testDownloadDir" value="${perfRoot}"/>
+		</ant>
+		<property file="${wtp.perf}/perf.properties"/>
+		<mkdir dir="${build.home}/${perf.dbloc}/${buildType}-${buildId}-${date}${time}"/>
+		<copy todir="${build.home}/${perf.dbloc}/${buildType}-${buildId}-${date}${time}">
+			<fileset dir="${perfRoot}/results">
+				<include name="**/*"/>
+			</fileset>
+		</copy>
+	</target>
+</project>
\ No newline at end of file
diff --git a/releng.wtpbuilder/distribution/wtp.perf/derby.plugin.xml.template b/releng.wtpbuilder/distribution/wtp.perf/derby.plugin.xml.template
new file mode 100644
index 0000000..215b957
--- /dev/null
+++ b/releng.wtpbuilder/distribution/wtp.perf/derby.plugin.xml.template
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin
+   id="org.apache.derby"
+   name="org.apache.derby"
+   version="1.0.0"
+   provider-name="">
+   <runtime>
+      <library name="derby.jar">
+         <export name="*"/>
+      </library>
+      <library name="derbynet.jar">
+         <export name="*"/>
+      </library>
+      <library name="derbytools.jar">
+         <export name="*"/>
+      </library>
+   </runtime>
+</plugin>
diff --git a/releng.wtpbuilder/distribution/wtp.perf/perf.properties b/releng.wtpbuilder/distribution/wtp.perf/perf.properties
new file mode 100644
index 0000000..1e72260
--- /dev/null
+++ b/releng.wtpbuilder/distribution/wtp.perf/perf.properties
@@ -0,0 +1,48 @@
+###########################################################
+#
+# Performance tests
+#
+###########################################################
+
+org.eclipse.wst.common.tests.performance=org.eclipse.wst.common.tests.performance_0.7.0
+
+org.eclipse.wst.server.tests.performance=org.eclipse.wst.server.tests.performance_0.7.0
+org.eclipse.jst.server.tomcat.tests.performance=org.eclipse.jst.server.tomcat.tests.performance_0.7.0
+
+org.eclipse.jst.jsp.ui.tests.performance=org.eclipse.jst.jsp.ui.tests.performance_0.7.0
+org.eclipse.wst.css.ui.tests.performance=org.eclipse.wst.css.ui.tests.performance_0.7.0
+org.eclipse.wst.html.ui.tests.performance=org.eclipse.wst.html.ui.tests.performance_0.7.0
+org.eclipse.wst.xml.ui.tests.performance=org.eclipse.wst.xml.ui.tests.performance_0.7.0
+
+org.eclipse.wst.ws.tests=org.eclipse.wst.ws.tests_0.7.0
+org.eclipse.jst.ws.tests=org.eclipse.jst.ws.tests_0.7.0
+org.eclipse.jst.ws.tests.performance=org.eclipse.jst.ws.tests.performance_0.7.0
+
+org.eclipse.wst.wsdl.tests.performance=org.eclipse.wst.wsdl.tests.performance_0.7.0
+org.eclipse.wst.xsd.tests.performance=org.eclipse.wst.xsd.tests.performance_0.7.0
+
+org.eclipse.wst.rdb.tests.performance=org.eclipse.wst.rdb.tests.performance_0.7.0
+
+org.eclipse.jst.j2ee.core.tests.performance=org.eclipse.jst.j2ee.core.tests.performance_0.7.0
+
+###########################################################
+#
+# Performance database properties
+#
+###########################################################
+
+perf.dbloc=wtp-perf-db
+perf.config=wtpbuild
+perf.jvm=sun1.4.2
+perf.ref.config=wtpbuild
+perf.ref.buildId=R20050729-0654
+perf.ref.jvm=sun1.4.2
+
+###########################################################
+#
+# SWT properties
+#
+###########################################################
+
+#swt.lib.path=org.eclipse.swt.motif_3.1.0/os/linux/x86
+swt.lib.path=org.eclipse.swt.win32_3.1.0/os/win32/x86
\ No newline at end of file
diff --git a/releng.wtpbuilder/distribution/wtp.perf/perf.xml b/releng.wtpbuilder/distribution/wtp.perf/perf.xml
new file mode 100644
index 0000000..4f12281
--- /dev/null
+++ b/releng.wtpbuilder/distribution/wtp.perf/perf.xml
@@ -0,0 +1,148 @@
+<project name="WTP performance testing" default="main">
+
+	<!-- Platform property -->
+	<property name="platform" value="" />
+
+	<!-- XML and HTML results -->
+ 	<property name="results" value="${perfRoot}/results" />
+
+	<!-- Tomcat install directory -->
+	<property name="tomcat50Dir" value="${perfRoot}/jakarta-tomcat-5.0.28"/>
+
+	<!-- jonas install directory -->
+	<property name="jonas432Dir" value="${perfRoot}/JONAS_4_3_2"/>
+
+	<target name="runperftests">
+		<ant antfile="${wtp.perf}/build.xml" target="setup"/>
+		<available file="${perfRoot}/eclipse/plugins/${testPlugin}/test.xml" property="test.xml.exists"/>
+		<antcall target="runtests"/>
+	</target>
+
+	<target name="runtests" if="test.xml.exists">
+		<ant antfile="${perfRoot}/eclipse/plugins/${testPlugin}/test.xml" dir="${perfRoot}/eclipse">
+			<property name="library-file" value="${wtp.perf}/performance-tests.xml"/>
+		</ant>
+		<mkdir dir="${results}/xml"/>
+		<copy file="${perfRoot}/eclipse/${report}.xml" tofile="${results}/xml/${report}_${platform}.xml" failonerror="false" />
+		<antcall target="genHtml" />
+	</target>
+
+	<target name="genHtml">
+		<style style="${wtp.perf}/../wtp.tests/testScripts/JUNIT.XSL" basedir="${results}/xml" destdir="${results}/html" />
+	</target>
+
+	<!-- wst.server performance tests -->
+	<target name="wst-server-perfTests" description="Runs the org.eclipse.wst.server.tests.performance test.xml">
+		<antcall target="runperftests">
+			<param name="testPlugin" value="${org.eclipse.wst.server.tests.performance}" />
+			<param name="report" value="org.eclipse.wst.server.tests.performance" />
+		</antcall>
+	</target>
+
+	<!-- Tomcat performance tests -->
+	<target name="jst-server-tomcat-perfTests" description="Runs the org.eclipse.jst.server.tomcat.tests.performance test.xml">
+		<antcall target="runperftests">
+			<param name="testPlugin" value="${org.eclipse.jst.server.tomcat.tests.performance}" />
+			<param name="report" value="org.eclipse.jst.server.tomcat.tests.performance" />
+		</antcall>
+	</target>
+
+	<!-- JSP performance tests -->
+	<target name="jst-jsp-perfTests" description="Runs test.xml for
+												org.eclipse.jst.jsp.ui.tests.performance">
+		<antcall target="runperftests">
+			<param name="testPlugin" value="${org.eclipse.jst.jsp.ui.tests.performance}" />
+			<param name="report" value="org.eclipse.jst.jsp.ui.tests.performance" />
+		</antcall>
+	</target>
+
+	<!-- XML performance tests -->
+	<target name="wst-xml-perfTests" description="Runs test.xml for
+												org.eclipse.wst.xml.ui.tests.performance">
+		<antcall target="runperftests">
+			<param name="testPlugin" value="${org.eclipse.wst.xml.ui.tests.performance}" />
+			<param name="report" value="org.eclipse.wst.xml.ui.tests.performance" />
+		</antcall>
+	</target>
+
+	<!-- HTML performance tests -->
+	<target name="wst-html-perfTests" description="Runs test.xml for
+												org.eclipse.wst.html.ui.tests.performance">
+		<antcall target="runperftests">
+			<param name="testPlugin" value="${org.eclipse.wst.html.ui.tests.performance}" />
+			<param name="report" value="org.eclipse.wst.html.ui.tests.performance" />
+		</antcall>
+	</target>
+
+	<!-- CSS performance tests -->
+	<target name="wst-css-perfTests" description="Runs test.xml for
+												org.eclipse.wst.css.ui.tests.performance">
+		<antcall target="runperftests">
+			<param name="testPlugin" value="${org.eclipse.wst.css.ui.tests.performance}" />
+			<param name="report" value="org.eclipse.wst.css.ui.tests.performance" />
+		</antcall>
+	</target>
+
+	<!-- wst.common performance tests -->
+	<target name="wst-common-perfTests" description="Runs test.xml for org.eclipse.wst.common.tests.performance">
+		<antcall target="runperftests">
+			<param name="testPlugin" value="${org.eclipse.wst.common.tests.performance}" />
+			<param name="report" value="org.eclipse.wst.common.tests.performance" />
+		</antcall>
+	</target>
+
+	<!-- Web services performance tests -->
+	<target name="jst-ws-perfTests" description="Runs the org.eclipse.jst.ws.tests.performance test.xml">
+		<antcall target="runperftests">
+			<param name="testPlugin" value="${org.eclipse.jst.ws.tests.performance}" />
+			<param name="report" value="org.eclipse.jst.ws.tests.performance" />
+		</antcall>
+	</target>
+
+	<!-- wsdl performance tests -->
+	<target name="wst-wsdl-perfTests">
+		<antcall target="runperftests">
+			<param name="testPlugin" value="${org.eclipse.wst.wsdl.tests.performance}" />
+			<param name="report" value="org.eclipse.wst.wsdl.tests.performance" />
+		</antcall>
+	</target>
+
+	<!-- xsd performance tests -->
+	<target name="wst-xsd-perfTests">
+		<antcall target="runperftests">
+			<param name="testPlugin" value="${org.eclipse.wst.xsd.tests.performance}" />
+			<param name="report" value="org.eclipse.wst.xsd.tests.performance" />
+		</antcall>
+	</target>
+
+	<!-- rdb performance tests -->
+	<target name="wst-rdb-perfTests">
+		<antcall target="runperftests">
+			<param name="testPlugin" value="${org.eclipse.wst.rdb.tests.performance}"/>
+			<param name="report" value="org.eclipse.wst.rdb.tests.performance"/>
+		</antcall>
+	</target>
+
+	<!-- j2ee performance tests -->
+	<target name="jst-j2ee-perfTests">
+		<antcall target="runperftests">
+			<param name="testPlugin" value="${org.eclipse.jst.j2ee.core.tests.performance}"/>
+			<param name="report" value="org.eclipse.jst.j2ee.core.tests.performance"/>
+		</antcall>
+	</target>
+
+	<target name="main">
+		<antcall target="wst-common-perfTests"/>
+		<antcall target="wst-wsdl-perfTests"/>
+		<antcall target="wst-server-perfTests" />
+		<antcall target="jst-server-tomcat-perfTests" />
+		<antcall target="jst-jsp-perfTests" />
+		<antcall target="wst-xml-perfTests" />
+		<antcall target="wst-html-perfTests" />
+		<antcall target="wst-css-perfTests" />
+		<antcall target="jst-ws-perfTests"/>
+		<antcall target="wst-xsd-perfTests"/>
+		<antcall target="wst-rdb-perfTests"/>
+		<antcall target="jst-j2ee-perfTests"/>
+	</target>
+</project>
\ No newline at end of file
diff --git a/releng.wtpbuilder/distribution/wtp.perf/performance-tests.xml b/releng.wtpbuilder/distribution/wtp.perf/performance-tests.xml
new file mode 100644
index 0000000..7db9c1e
--- /dev/null
+++ b/releng.wtpbuilder/distribution/wtp.perf/performance-tests.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0"?>
+<project name="WTP Performance" default="default">
+
+  <property name="library-xml-file" value="${basedir}/plugins/org.eclipse.test_3.1.0/library.xml"/>
+  <import file="${library-xml-file}"/>
+
+  <target name="ui-test">
+    <antcall target="ui-test-normal"/>
+    <antcall target="ui-test-perf"/>
+  </target>
+
+  <target name="core-test">
+    <antcall target="core-test-normal"/>
+    <antcall target="core-test-perf"/>
+  </target>
+
+  <target name="ui-test-normal" unless="runAsPerfApp">
+    <antcall target="run">
+      <param name="target" value="ui-test"/>
+    </antcall>
+  </target>
+
+  <target name="core-test-normal" unless="runAsPerfApp">
+    <antcall target="run">
+      <param name="target" value="core-test"/>
+    </antcall>
+  </target>
+
+  <target name="ui-test-perf" if="runAsPerfApp">
+    <antcall target="run">
+      <param name="target" value="eclipse-test"/>
+      <param name="application" value="org.eclipse.wst.common.tests.performance.uitestapplication"/>
+    </antcall>
+  </target>
+  
+  <target name="core-test-perf" if="runAsPerfApp">
+    <antcall target="run">
+      <param name="target" value="eclipse-test"/>
+      <param name="application" value="org.eclipse.wst.common.tests.performance.coretestapplication"/>
+    </antcall>
+  </target>
+
+  <target name="run">
+
+    <property name="eclipse.perf.dbloc" value="-Declipse.perf.dbloc=${build.home}/${perf.dbloc}"/>
+    <property name="eclipse.perf.config" value="-Declipse.perf.config=config=${perf.config};build=${perf.buildId};jvm=${perf.jvm}"/>
+    <property name="eclipse.perf.assertAgainst" value="-Declipse.perf.assertAgainst=config=${perf.ref.config};build=${perf.ref.buildId};jvm=${perf.ref.jvm}"/>
+    <property name="extraVMargs" value=""/>
+
+    <ant target="${target}" antfile="${library-xml-file}">
+      <property name="application" value="${application}"/>
+      <property name="data-dir" value="${data-dir}"/>
+      <property name="plugin-name" value="${plugin-name}"/>
+      <property name="classname" value="${classname}"/>
+      <property name="extraVMargs" value="${eclipse.perf.dbloc} ${eclipse.perf.config} ${eclipse.perf.assertAgainst} ${extraVMargs} -Dwtp.autotest.noninteractive=true"/>
+    </ant>
+
+  </target>
+
+  <target name="default"/>
+</project>
\ No newline at end of file
diff --git a/releng.wtpbuilder/scripts/dependency/template.xml b/releng.wtpbuilder/scripts/dependency/template.xml
index 01acfdd..db4935e 100644
--- a/releng.wtpbuilder/scripts/dependency/template.xml
+++ b/releng.wtpbuilder/scripts/dependency/template.xml
@@ -78,6 +78,7 @@
 	<target name="install" depends="init">
 		<echo message="Installing ${dependency.file}" />
 		<echo message="destination: ${install.destination}" />
+		<antcall target="cleanInstall"/>
 		<property file="${install.destination}/installmanifest.properties" />
 		<antcall target="callInstall" />
 		<echo message="${install.destination}/installmanifest.properties" />
@@ -86,6 +87,14 @@
     	</echo>
 	</target>
 
+	<target name="cleanInstall" if="clean">
+		<available file="${install.destination}/installmanifest.properties" property="installmanifest.exists"/>
+		<antcall target="cleanInstall2"/>
+	</target>
+
+	<target name="cleanInstall2" if="installmanifest.exists">
+		<replace file="${install.destination}/installmanifest.properties" token="@dependencyGroupId@.${dependency.file}.installed=true"/>
+	</target>
 
 	<target name="callInstall" unless="@dependencyGroupId@.${dependency.file}.installed">
 		<ant antfile="@dependencyDir@/build.xml" target="install" />