blob: d567f2e592eb2019364fe86b6674139740aa5cc6 [file]
<!--
Copyright (c) 2005, 2019 IBM Corporation and others.
This program and the accompanying materials
are made available under the terms of the Eclipse Public License 2.0
which accompanies this distribution, and is available at
https://www.eclipse.org/legal/epl-2.0/
SPDX-License-Identifier: EPL-2.0
Contributors:
IBM Corporation - initial API and implementation
-->
<project
name="label"
default="label"
basedir=".">
<!-- = = = standard properties pattern = = = -->
<!--
Note to be cross-platform, "environment variables" are only appropriate for
some variables, e.g. ones we set, since properties are case sensitive, even if
the environment variables on your operating system are not, e.g. it will
be ${env.Path} not ${env.PATH} on Windows -->
<property environment="env"/>
<!--
Let users override standard properties, if desired.
If directory, file, or some properties do not exist,
then standard properties will be used.
-->
<property file="${env.LOCAL_BUILD_PROPERTIES_DIR}/${ant.project.name}.properties"/>
<!-- = = = end standard properties pattern = = = -->
<target name="init">
<!-- Capture the computer name in a cross-platform manner -->
<property
name="env.COMPUTERNAME"
value="${env.HOSTNAME}"/>
<!-- buildDirectory should always be set by caller, but in case not, such as for local test, set to some recognizable, usable value
or, for production, fail if buildDirectory has not been set, as that would be indicate a scripting error
<property
name="buildDirectory"
value="localtest"/>
-->
<fail unless="buildDirectory"/>
<mkdir dir="${buildDirectory}"/>
<available
file="${buildDirectory}/label.properties"
property="label.properties.exists"/>
</target>
<target
name="label"
depends="init"
unless="label.properties.exists">
<!-- date and time are normally not used, normally cctimestamp is set, but in case not running in cc, we'll
fall back on date/time -->
<tstamp>
<format
property="date"
pattern="yyyyMMdd"
timezone="UTC"/>
</tstamp>
<tstamp>
<format
property="time"
pattern="HHmm"
timezone="UTC"/>
</tstamp>
<condition
property="timestamp"
value="${cctimestamp}"
else="${date}${time}">
<isset property="cctimestamp"/>
</condition>
<echo level="debug" message="cctimestamp: ${cctimestamp}"/>
<echo level="debug" message="datetime: ${date}${time} "/>
<echo level="debug" message="timestamp: ${timestamp}"/>
<!-- build type should always be set by caller, but in case not, such as for local testing of script, we'll set to 'U' for "unknown" -->
<property
name="buildType"
value="U"/>
<property
name="buildId"
value="${buildType}${timestamp}"/>
<!--this naming convention used by php scripts on download server-->
<property
name="buildLabel"
value="${buildType}-${buildId}-${timestamp}"/>
<!--store the build label information in a file-->
<!--note the line.separator is required to be immune to the exact formatting -->
<echo
file="${buildDirectory}/label.properties"
append="true">buildComputer=${env.COMPUTERNAME}${line.separator}</echo>
<echo
file="${buildDirectory}/label.properties"
append="true">buildOS=${env.OS}${line.separator}</echo>
<echo
file="${buildDirectory}/label.properties"
append="true">buildType=${buildType}${line.separator}</echo>
<echo
file="${buildDirectory}/label.properties"
append="true">buildId=${buildId}${line.separator}</echo>
<echo
file="${buildDirectory}/label.properties"
append="true">timestamp=${timestamp}${line.separator}</echo>
<echo
file="${buildDirectory}/label.properties"
append="true">buildLabel=${buildLabel}${line.separator}</echo>
<echo
file="${buildDirectory}/label.properties"
append="true">date=${date}${line.separator}</echo>
<echo
file="${buildDirectory}/label.properties"
append="true">time=${time}${line.separator}</echo>
<echo
file="${buildDirectory}/label.properties"
append="true">buildBranch=${buildBranch}${line.separator}</echo>
<echo
file="${buildDirectory}/label.properties"
append="true">projectname=${projectname}${line.separator}</echo>
<echo
file="${buildDirectory}/label.properties"
append="true">build.distribution=${build.distribution}${line.separator}</echo>
</target>
</project>