blob: 78e0ecbbbd13c28e02e2aa625c32efdb361b0aa3 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<project default="main">
<property name="library.dir" value="./libs"/>
<path id="libraries">
<fileset dir="${library.dir}">
<include name="*.jar"/>
</fileset>
</path>
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<path refid="libraries"/>
</classpath>
</taskdef>
<taskdef name="summarizeResults"
classname="org.eclipse.wtp.releng.tools.ResultsSummaryGenerator">
<classpath>
<path refid="libraries"/>
</classpath>
</taskdef>
<taskdef name="writePropertiesAsPHP"
classname="org.eclipse.wtp.releng.tools.WritePropertiesAsPHP">
<classpath>
<path refid="libraries"/>
</classpath>
</taskdef>
<!--
Intialize the variables, configuring and assembly the paths according to the nature of the build.
-->
<target name="init"
description="Setup of the variables that define the project and structure">
<!--
We need to 'pull' the Hudson variables (those like [env.***],
more details about the Hudson variables in [https://hudson.eclipse.org/webtools/env-vars.html]
-->
<property environment="env" />
<!-- In case you need to verify the information provided by those varibles, uncomment this section
<echo message="ENV Variables" />
<echo message="BUILD_NUMBER [${env.BUILD_NUMBER}]" />
<echo message="BUILD_ID [${env.BUILD_ID}]" />
<echo message="JOB_NAME [${env.JOB_NAME}]" />
<echo message="BUILD_TAG [${env.BUILD_TAG}]" />
<echo message="EXECUTOR_NUMBER [${env.EXECUTOR_NUMBER}]" />
<echo message="WORKSPACE [${env.WORKSPACE}]" />
<echo message="HUDSON_URL [${env.HUDSON_URL}]" />
<echo message="BUILD_URL [${env.BUILD_URL}]" />
<echo message="JOB_URL [${env.JOB_URL}]" />
<echo message="WORKSPACE [${env.WORKSPACE}]" />
-->
<!--1) We need the BUILD ID, but in a different format: removing the "-", replace the "_" with "-"
and remove the last 2 digits (seconds) from the timestamp.
Using to the regex's magic we only group yyyy-mm-dd_hh-mm-ss and and tranform into: yyyymmddhhmm.
-->
<!-- Jenkins does not contain this property any more... -->
<!-- <propertyregex property="build.id"
input="${env.BUILD_ID}"
regexp="(\d{4})-(\d{2})-(\d{2})_(\d{2})-(\d{2})-(\d{2})"
replace="\1\2\3\4\5\6"
casesensitive="false" /> -->
<!-- ...so just generate a timestamp from the locale -->
<tstamp>
<format property="build.id" pattern="yyyyMMddHHmmss" locale="en,US"/>
</tstamp>
<!-- <echo>${build.id}</echo> -->
<!--2) We need the WTP build branch, we will get it from the repository file;
from there we strip out the irrelevant information (path, maven qualifier, etc.).
This step include the initialization of the build.dist, repo.dir and repo.unit.dir variables and depends
if the build is a M/I-type or a P-type.
In case of a P-type the test repo is not used.
-->
<if>
<available file="../webtools.repositories/repository/target/" type="dir" />
<then>
<path id="repo.path">
<fileset dir="../webtools.repositories/repository/target/">
<include name="repository-*.zip" />
</fileset>
</path>
<property name="repo.id" refid="repo.path" />
<propertyregex
property="wtp.version"
input="${repo.id}"
regexp=".*repository-(.*)-v.*.zip"
select="\1"
casesensitive="false" />
<!--We set up some properties that depend on the type of build-->
<property name="build.dist" value="wtp" />
<property name="repo.dir" value="webtools.repositories/repository/target/repository/" />
<property name="repo.unit.dir" value="webtools.repositories/repositoryunittests/target/repository/" />
</then>
<else>
<if>
<available file="../webtools.repositories/patch-repository/target/" type="dir" />
<then>
<path id="patch.path">
<fileset dir="../webtools.repositories/patch-repository/target/">
<include name="patches-repo-P-*.zip" />
</fileset>
</path>
<property name="repo.id" refid="patch.path" />
<propertyregex
property="wtp.version"
input="${repo.id}"
regexp=".*patches-repo-P-(.*)\.zip"
select="\1"
casesensitive="false" />
<property name="build.dist" value="patches" />
<property name="repo.dir" value="webtools.repositories/patch-repository/target/repository/" />
<property name="repo.unit.dir" value="[NO USED]" />
</then>
<else>
<if>
<equals arg1="${publish}" arg2="true" />
<then>
<fail>[ERROR] The repository ZIP does not exist in ../webtools.repositories/repository/target/repository-*.zip
[ERROR] It is not possible to continue the publishing.</fail>
</then>
<else>
<echo>[WARNING] The repository ZIP does not exist in ../webtools.repositories/repository/target/repository-*.zip
[WARNING] Run a maven build of webtools.releng.aggregator/pom.xml if you want this step to be done.
[WARNING] Continuing with assumed variables...</echo>
<property name="build.dist" value="wtp" />
<property name="repo.dir" value="webtools.repositories/repository/target/repository/" />
<property name="repo.unit.dir" value="webtools.repositories/repositoryunittests/target/repository/" />
</else>
</if>
</else>
</if>
</else>
</if>
<!-- 2.1, The branch is the version with the prefix R-->
<property name="build.branch" value="R${wtp.version}" />
<!--3) The build type must be defined in the build configuration
in the ANT execution section, Properties sub-section
build.type=M
M -> Maintenance
I -> Integration
P -> Patch
<property name="build.type" value="I" />
-->
<!--4) The Build date, human readable-->
<tstamp>
<format property="build.date" pattern="dd MMMM, yyyy" locale="en,US" />
</tstamp>
<!--5) Build definition using:
- Build Type: I/M/P
- wtp-version: 3.6.1, 3.7.0
- build ID: timestamp like 2014102314_0001
-->
<property name="build" value="${build.type}-${wtp.version}-${build.id}" />
<!-- 6)Destiny path (in the downloads mount) for the new build
This is compound by:
a) The download mount point [/home/data/httpd/download.eclipse.org]
b) The webtools dir segment [/webtools/downloads/cbi]
c) The wtp version segment: [/wtp-RX.Y.Z-I]
d) The timestamp dir
-->
<property name="wtp.committers" value="/opt/public/webtools/committers" />
<property name="dest.path"
value="${wtp.committers}/${build.dist}-${build.branch}-${build.type}/${build.id}/${build}" />
<property name="dest.url"
value="http://build.eclipse.org/webtools/committers/${build.dist}-${build.branch}-${build.type}/${build.id}/${build}" />
<!--7) Test Results directory, where the JUNit Test Reports (XML & HTML files) will be stored-->
<property name="test.results" value="${dest.path}/testResults" />
<!--8) Template Directory, with all template files for the download page -->
<property name="template.dir" value="./templateFiles" />
<!--9) Logs path -->
<property name="log.path" value="/jobs/genie.webtools/${env.JOB_NAME}/builds/${env.BUILD_NUMBER}" />
<property name="full.log" value="${dest.path}/fullLog.zip" />
<!--10) Files Count-->
<property name="files.count" value="${dest.path}/files.count" />
<!--11) Logs Destiny-->
<property name="logs.dest" value="${dest.path}/logs" />
<!--Additional information for the user-->
<switch value="${build.type}">
<case value="I">
<property name="build.type.desc" value = "Integration" />
</case>
<case value="M">
<property name="build.type.desc" value = "Maintenance" />
</case>
<case value="P">
<property name="build.type.desc" value = "Patch" />
</case>
<default>
<property name="build.type.desc" value = "Initial not recognized" />
</default>
</switch>
<!--Displaying the values to be used for the post-processing-->
<echo message="" />
<echo message=":::Source directories:::" />
<echo message="Log Directory....................[${log.path}]" />
<echo message="Templates Directory..............[${template.dir}]" />
<echo message="Repository Directory.............[${repo.dir}]" />
<echo message="Repository Test Unit Directory...[${repo.unit.dir}]" />
<echo message="" />
<echo message=":::Destiny directories:::" />
<echo message="download.eclipse.org Directory...[${wtp.committers}]" />
<echo message="WTP Destination Path.............[${dest.path}]" />
<echo message="WTP Destination URL..............[${dest.url}]" />
<echo message="Test Result Directory ...........[${test.results}]" />
<echo message="Logs Directory ..................[${logs.dest}]" />
<echo message="Full log path........ ...........[${full.log}]" />
<echo message="" />
<echo message=":::Build Details:::" />
<echo message="Build ID.........................[${build.id}]" />
<echo message="Build ...........................[${build}]" />
<echo message="Build Distribution...............[${build.dist}]" />
<echo message="Build branch.....................[${build.branch}] " />
<echo message="Build type.......................[${build.type}] (${build.type.desc})" />
<echo message="Build date.......................[${build.date}]" />
<echo message="" />
<echo message=":::Additional Information:::" />
<echo message="Files Count path.................[${files.count}]" />
</target>
<!--
Copies the P2 ZIP files to the committers directory, and then rename them to match the expected name".
-->
<target name="process-artifacts"
description="Copies the artifacts generated by the build to the the Download Machine">
<echo message="Moving artifacts..." />
<if>
<!--If not a patch, we consider a valid I/M build with the repository and repositoryunittests repos-->
<not><equals arg1="${build.type}" arg2="P" /></not>
<then>
<!--1) We need to copy the artifacts generated by maven-->
<copy todir="${dest.path}" flatten="true">
<fileset dir="../">
<patternset id="wtp-artifacts">
<include name="webtools.repositories/*/target/*.zip" />
</patternset>
</fileset>
</copy>
<echo message="Renaming ZIP files" />
<!--2)WTP P2 Repository ZIP files being renamed -->
<move todir="${dest.path}">
<fileset dir="${dest.path}" />
<mapper>
<mapper type="regexp"
from=".*repository-.*.zip"
to="${build.dist}-repo-${build}.zip" />
<mapper type="regexp"
from=".*repositoryunittests-.*.zip"
to="${build.dist}-tests-repo-${build}.zip" />
</mapper>
</move>
<!-- 3) Uncompress the P2 repositoryunittests, this is optional because patches does not have this repo configured -->
<echo message="Copying P2 repositories" />
<if>
<available file="../${repo.unit.dir}" />
<then>
<copy todir="${dest.path}/repositoryunittests">
<fileset dir="../${repo.unit.dir}" includes="**/*" />
</copy>
</then>
<else>
<echo message="P2 Tests Repo ZIP not found..." />
</else>
</if>
</then>
<!--Else, it is a patch build-->
<else>
<!--Copy the ZIP files, this time is only one the patch P2 ZIP file-->
<copy todir="${dest.path}" flatten="true">
<fileset dir="../">
<patternset id="wtp-artifacts">
<include name="webtools.repositories/patch-repository/target/*.zip" />
</patternset>
</fileset>
</copy>
<!--Rename to match the expected name for a patch build. -->
<move todir="${dest.path}">
<fileset dir="${dest.path}" />
<mapper>
<mapper type="regexp"
from="patches-repo-P-.*\.zip"
to="${build.dist}-repo-${build}.zip" />
</mapper>
</move>
</else>
</if>
<!--This step copies only the P2 repository directory-->
<if>
<available file="../${repo.dir}" />
<then>
<copy todir="${dest.path}/repository">
<fileset dir="../${repo.dir}" includes="**/*" />
</copy>
</then>
<else>
<echo message="P2 Repo [../${repo.dir}] not found..." />
</else>
</if>
</target>
<!--
Generation of the MD5 and SHA1 checksums of the ZIP files, we consider only those worthy of a checksum
due to the size.
-->
<target name="generate-checksum"
description="Generates the MD5 and SHA1 checksums for the P2 ZIP Files">
<!--1) Generate the MD5 for all the ZIP files, store the result in the checksum dir-->
<echo message="Generating MD5..." />
<checksum todir="${dest.path}/checksum" algorithm="md5">
<fileset dir="${dest.path}">
<include name="*.zip" />
</fileset>
</checksum>
<!--2) Generate the SHA for all the ZIP files, store the result in the checksum dir-->
<echo message="Generating SHA1..." />
<checksum todir="${dest.path}/checksum" algorithm="sha1">
<fileset dir="${dest.path}">
<include name="*.zip" />
</fileset>
</checksum>
</target>
<!--
The JUnit test results (if any) are processed, this include:
- Copy the original XML to the committers page
- Transform the result from XML -> HTML
- Rename the HTML results to the file name expected by the PHP scripts in the web page
- Generate the Summary result from the JUnit results
-
-->
<target name="process-tests-results">
<echo message="Copying XML Test Results..." />
<copy todir="${test.results}/xml" flatten="true">
<fileset dir="../">
<patternset id="junit-reports">
<include name="**/target/surefire-reports/*.xml" />
</patternset>
</fileset>
</copy>
<if>
<available file="${test.results}/xml" type = "dir"/>
<then>
<!--The structure of the JUnit reports are not as expected from maven,
we need a little modification so the each testsuite be ready as a page, so
replace testsuite by testsuites and adjust the ending tags too.
-->
<replace dir="${test.results}/xml"
includes="**/*.xml"
value="">
<replacefilter token="&lt;testsuite" value="&lt;testsuites>&lt;testsuite "/>
<replacefilter token="&lt;/testsuite>" value="&lt;/testsuite>&lt;/testsuites>"/>
</replace>
<echo message="Generanting the HTML Test Results from the XML..." />
<!--The XML results are copied (and renamed) to the committers page.-->
<move todir="${test.results}/xml">
<fileset dir="${test.results}/xml" />
<mapper>
<mapper type="regexp" from="(TEST-)(.*)" to="\2" />
</mapper>
</move>
<log level = "0" />
<!--The XML is transformed to HTML for silly humans does not know how to parse tiny XML files -->
<xslt style="./tests/junit.xsl"
basedir="${test.results}/xml"
destdir="${test.results}/html" />
<!--Generate summary report using the WebTools libraries-->
<echo message="Generate Summary Report..." />
<summarizeResults
isBuildTested="true"
dropTokenList="${dropTokenList}"
dropDirectoryName="${dest.path}"
xmlDirectoryName="${test.results}/xml"
testResultsTemplateFileName="${template.dir}/testResults.php.template.php"
testResultsHtmlFileName="testResults.php"
hrefTestResultsTargetPath="testResults/html"
compileLogsDirectoryName=""/>
<log level = "2" />
</then>
<else>
<!--If not JUnit result are found, we only complain, but not break anything-->
<echo message="No test results found..." />
</else>
</if>
</target>
<!--ZIP files are counted and the number stored in the simple file, this is the one
indicates the PHP web page that the page is ready or not to be "visible"-->
<target name = "file-counting" >
<!--At the very end, we need the ZIP file counting, this will stored in the file indicated by
${files.count}.-->
<echo message="Writting file count..." />
<resourcecount property="counter">
<fileset dir="${dest.path}">
<patternset id="wtp-artifacts">
<include name="*.zip" />
</patternset>
</fileset>
</resourcecount>
<touch file="${files.count}"/>
<echo message="Final file counting: [${counter}]" />
<echo file="${files.count}" message="${counter}" />
</target>
<!--
-->
<target name = "process-logs" >
<echo message="Compressing and copying the full log..." />
<zip basedir= "${log.path}" file="${log.path}/log" destfile="${full.log}" />
<echo message="Getting all the component logs" />
<!--We gather all the logs, at least those are the ones I have found,
those are copied to the committers page, some of them have an ugly name like: ".log" (not so descriptive)
so, we rename to include the maven artifact that created it, easy to do since it is in the path.
We have 3 log flavors:
* Configuration, generated by Eclipse PDE if something was wrong (maybe a test)
* Metadata, something with Eclipse but it could be inclusive the launching
* General logs (maven)-->
<copy todir="${logs.dest}">
<fileset dir="../">
<patternset id="logs">
<include name="**/target/work/data/.metadata/.log" />
<include name="**/target/work/configuration/*.log" />
<include name="**/*.log" />
</patternset>
</fileset>
<mapper>
<mapper type="regexp"
from="(.*)(/target/work/data/\.metadata/\.log)"
to="\1.log" />
<mapper type="regexp"
from="(.*)(/target/work/configuration/)(\d+\.log)"
to="\1-\3" />
<mapper type="regexp"
from="(.*/)(\D+\.log)"
to="\1\2" />
</mapper>
</copy>
</target>
<!--
There are some files that PHP web page is expecting:
- The Index.php
- buildVariables.php
- dependency.properties.php
Those are copied from the repository to the committers page, some of those are pre-processed
other only renamed.
-->
<!--
To test local changes to this page or when dependencies change, run this:
cd webtools.releng.aggregator/wtp-parent; ant -f postBuild.xml -lib ./libs/ init prepare-page-files -Dpublish=false -Dbuild.type=I \
-Dwtp.version=3.10.0 -Dwtp.committers=/opt/lampp/htdocs/tmp -Dbuild.id=20201212012345
Then start a xampp apache server on localhost:80 and go to http://localhost/tmp/wtp-R3.10.0-I/20201212012345/I-3.10.0-20201212012345/
-->
<target name = "prepare-page-files">
<copy todir="${dest.path}">
<fileset dir="${template.dir}">
<exclude name="**/*template.php"/>
<exclude name="**/*php.template"/>
</fileset>
</copy>
<!--include snapshot of the parent pom in the build folder -->
<copy file="pom.xml" tofile="${dest.path}/wtp-parent_pom.xml"/>
<!--get static files required in the buildLabel directory-->
<copy todir="${dest.path}">
<fileset dir="./staticDropFiles"/>
</copy>
<!--Coping and renaming, simple ones.
-->
<copy overwrite="true"
file="${template.dir}/index.html.template.php"
tofile="${dest.path}/index.php"/>
<copy overwrite="true"
file="${template.dir}/buildvariables.php"
tofile="${dest.path}/buildvariables.php"/>
<!--
This is "filled" with information from the build, relevant to the committers.
-->
<condition property="WORKSPACE" value="${env.WORKSPACE}" else="..">
<isset property="env.WORKSPACE"/>
</condition>
<xmlproperty file="pom.xml" collapseAttributes="true" keepRoot="false" prefix="parentpom"/>
<echoproperties regex="parentpom.properties..+repo.url" destfile="${WORKSPACE}/wtp-parent/data/parentpom.properties"/>
<concat destfile="${WORKSPACE}/wtp-parent/data/dependencies.all.properties">
<fileset dir="./data" includes="dependencies.properties,parentpom.properties"/>
</concat>
<writePropertiesAsPHP
propFileName="${WORKSPACE}/wtp-parent/data/dependencies.all.properties"
outPHPFileName="${dest.path}/dependency.properties.php"
buildlabel="${build.id}"/>
<replace dir="${dest.path}"
includes="**/buildvariables.php"
value=""
propertyFile="${WORKSPACE}/wtp-parent/data/dependencies.all.properties">
<replacefilter token="@buildtype@" value="${build.type}"/>
<replacefilter token="@date@" value="${build.date}"/>
<replacefilter token="@build@" value="${build}"/>
<replacefilter token="@buildBranch@" value="${build.branch}"/>
<replacefilter token="@build_distribution@" value="${build.dist}"/>
</replace>
<touch file="${dest.path}/index.php"/>
<delete file="${WORKSPACE}/wtp-parent/data/parentpom.properties" quiet="true"/>
<delete file="${WORKSPACE}/wtp-parent/data/dependencies.all.properties" quiet="true"/>
</target>
<!--The default task, this is the one verifies if a publishing is required (publish=true) or not (publish=false)-->
<target name ="main">
<if>
<equals arg1="${publish}" arg2="true" />
<then>
<echo message="Starting the publishing..."/>
<antcall target="post-build" />
</then>
<else>
<echo message="The build won't be published to committers page. If you want to publish there, use: -Dpublish=true."/>
</else>
</if>
</target>
<!-- this must be done when everything is ready -->
<target name="post-build"
depends=" init,
prepare-page-files,
process-artifacts,
generate-checksum,
process-tests-results,
process-logs,
file-counting">
</target>
<!--Macros Definition-->
<!--This macro sets up the ant verbosity level, so it can be changed dinamically,
specially useful in the XSLT tranformation since it is spit in the log everything
-->
<macrodef name="log">
<attribute name="level" default="2"/>
<sequential>
<script language="javascript">
var logger = project.getBuildListeners( ).firstElement( );
logger.setMessageOutputLevel( @{level} );
</script>
</sequential>
</macrodef>
</project>