blob: 19362acc46cacfda6ae47cae68ed269c87e8a8da [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<project
name="buildutilities"
default="nodefault"
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 = = = -->
<!-- if not otherwise set, use these default properties -->
<property
name="debugOptimization"
value="false"/>
<!--
We should not always normalize ("-repack") jars by default,
since in production we sign the jars (which does the -repack for
us) and not in production we don't really care so why spend the
extra time. For jars which are not supposed to be normalized,
such as pre-existing jars, they need to be added to the
pack.properties file (see the updatePackProperties task). Note:
signing does the -repack when we sign. This can be over-ridden
by the caller setting normalize to true, but there are know
known cases where we want to normalize (and eventually pack) the
jar files but not sign them.
-->
<property
name="normalizeJarFiles"
value="false"/>
<!--
we'll currently pack jar files, just as part of "debugging" to
help sanity check all is working as expected. Eventually we may
want to provide some service there jar files in the bundles
directory are packed ... but, there's no known use-case for this
so far
-->
<property
name="packJarFiles"
value="false"/>
<!--
Let tmp site be global. Note: we use this odd
"tmpsite-archiveName-temp" to make sure unique directories,
since in some cases these directories can not be deleted from
ant, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=142926,
and since directory names ending in .zip are misinterpreted by
jarProcessor, see
https://bugs.eclipse.org/bugs/show_bug.cgi?id=143385 But, its
handy to do as unique directories anyway, since if a larger
process calls this mulitiple times, on different zips, and if
debugging is turnned on, then all the tmpsite directories are
left on disk for post-build inspection.
-->
<property
name="tmpsite"
value="${buildDirectory}/tmpsite-${archiveName}-temp"/>
<target
name="conditionAndSignJars"
depends="init"
if="doSign">
<!--
get zip for signing exclude content* artifacts* add
pack.properties send to eclipse and wait write over
p2.build.repo, but update content and artifacts files remove
temp file
-->
<echo
message="p2.build.repo: ${p2.build.repo}"/>
<zip
destfile="${buildDirectory}/${buildLabel}/temp-${buildLabel}-${component}.zip">
<zipfileset
dir="${buildDirectory}/${buildLabel}/repository/${component}/"
excludes="content.xml,content.jar,artifacts.xml,artifacts.jar"/>
</zip>
<updatePackProperties
archiveFilename="${buildDirectory}/${buildLabel}/temp-${buildLabel}-${component}.zip"/>
<!--
comment out the following delete statement, when debugging,
to see original zip files, before updatePackProperties ran
-->
<delete
file="${buildDirectory}/${buildLabel}/temp-${buildLabel}-${component}.zip.bak"/>
<!--
==================================================================================
sign the jars in archive file
==================================================================================
-->
<ant
antfile="${wtp.builder.home}/scripts/build/signjars.xml">
<property
name="archiveName"
value="temp-${buildLabel}-${component}.zip"/>
</ant>
<!-- now after signing, replace what we had -->
<unzip
dest="${buildDirectory}/${buildLabel}/repository/${component}"
src="${buildDirectory}/${buildLabel}/temp-${buildLabel}-${component}.zip"
overwrite="true">
<patternset
excludes="pack.properties"/>
</unzip>
<!--
Now we need to "fix" metata after being signed. do not
'pack' yet, as we want to create downloadable zipped repos,
without pack.gz files (they are not used, if jars present,
for efficiency
-->
<p2.process.artifacts
repositoryPath="${p2.build.repo}"/>
<!--
remove our temp zip file. Can comment out the delete
statement, when testing or debugging.
-->
<delete
file="${buildDirectory}/${buildLabel}/temp-${buildLabel}-${component}.zip"/>
</target>
<target
name="finishPackages"
depends="init">
<!--
now create zip of repo. This is done by us, and requires
that skipMirroring=true, or else pde builder does it later,
but does not use our conditioned jars (instead it would
reuse those in builderDirectory/tmp/eclipse. ... there's
gotta be an easier way! :)
-->
<zip
destfile="${buildDirectory}/${buildLabel}/${archiveName}">
<zipfileset
dir="${buildDirectory}/${buildLabel}/repository/${component}"/>
</zip>
<antcall
target="createChecksums">
<param
name="archiveName"
value="${archiveName}"/>
</antcall>
<!--
now pack what's in repository ... TODO: invalid if not
conditioned? or smart enough to know?
-->
<p2.process.artifacts
repositoryPath="${p2.build.repo}"
pack="true"/>
<!--
now add this repo to our overall repo, via composite. Note
we depend on relative location.
-->
<p2.composite.repository>
<repository
location="file:${buildDirectory}/${buildLabel}/repository"
name="Build repository ${buildLabel}"/>
<add>
<repository
location="${component}"/>
</add>
</p2.composite.repository>
</target>
<!--
==============================================================================================
Utility and Helper tasks
==============================================================================================
-->
<target
name="init"
depends="check.sign">
<condition
property="verboseIfDebug"
value="-verbose"
else="">
<istrue
value="${debugOptimization}"/>
</condition>
<condition
property="logIfDebug"
value="-debug -consolelog"
else="">
<istrue
value="${debugOptimization}"/>
</condition>
<condition
property="keepIfDebug"
value="true">
<istrue
value="${debugOptimization}"/>
</condition>
<!-- don't normalize if signing, since then it's done by signing -->
<condition
property="doNormalize"
value="true">
<and>
<istrue
value="${normalizeJarFiles}"/>
<not>
<equals
arg1="${doSign}"
arg2="true"
trim="true"
casesensitive="false"/>
</not>
</and>
</condition>
<condition
property="doPack"
value="true">
<and>
<istrue
value="${packJarFiles}"/>
<istrue
value="${createP2repo}"/>
<and>
<or>
<istrue
value="${normalizeJarFiles}"/>
<istrue
value="${doSign}"/>
</or>
</and>
</and>
</condition>
<condition
property="excludeFromRepoZip"
value="site.xml">
<isfalse
value="${doPack}"/>
</condition>
<condition
property="excludeFromRepoZip"
value="site.xml,plugins/*.jar,features/*.jar">
<istrue
value="${doPack}"/>
</condition>
<condition
property="archiveDir"
value="${tmpsite}/normalized">
<istrue
value="${doPack}"/>
</condition>
<condition
property="archiveDir"
value="${buildDirectory}/${buildLabel}">
<isfalse
value="${doPack}"/>
</condition>
<condition
property="doP2Repo"
value="true">
<available
file="${buildDirectory}/maps/webtools.maps/releng/sitefile/site.xml"/>
</condition>
<!-- echo important values, so it's documneted in build logs -->
<echo
message="doPack: ${doPack}"/>
<echo
message="packJarFiles: ${packJarFiles}"/>
<echo
message="normalizeJarFiles: ${normalizeJarFiles}"/>
<echo
message="doSign: ${doSign}"/>
<echo
message="doNormalize: ${doNormalize}"/>
<echo
message="doP2Repo: ${doP2Repo}"/>
</target>
<!--
always make copy, since normally either normalized, or signed
(and normalized) TODO: (minor) tiny improvement in efficiency
could be made, for N-builds?, that are neither normalized nor
signed.
-->
<target
name="createChecksums">
<!--
This createChecksums task creates two files, for use in two
contexts. a. an x.md5 file, that has the name of the file in
the contents. This is good for some "third party"
executables, like md5summ, that expects the name in the
file. b. since ant does not deal well with md5 files with
anything in them other than the checksum, we provide same
thing in a file with an md5antformat extension, that has
only the checksum.
-->
<mkdir
dir="${buildDirectory}/${buildLabel}/checksum"/>
<checksum
file="${buildDirectory}/${buildLabel}/${archiveName}"
todir="${buildDirectory}/${buildLabel}/checksum/"
pattern="{0} *{1}"
fileext=".md5"
algorithm="MD5"/>
<checksum
file="${buildDirectory}/${buildLabel}/${archiveName}"
todir="${buildDirectory}/${buildLabel}/checksum/"
pattern="{0} *{1}"
fileext=".sha1"
algorithm="SHA1"/>
</target>
<target
name="check.sign">
<echo
message="sign: ${sign}"/>
<echo
message="env skip jar signing: ${env.SKIP_JAR_SIGNING}"/>
<echo
message="skip jar signing: ${SKIP_JAR_SIGNING}"/>
<condition
property="doSign">
<and>
<equals
arg1="${sign}"
arg2="true"
trim="true"
casesensitive="false"/>
<not>
<equals
arg1="${env.SKIP_JAR_SIGNING}"
arg2="true"
trim="true"
casesensitive="false"/>
</not>
<not>
<equals
arg1="${SKIP_JAR_SIGNING}"
arg2="true"
trim="true"
casesensitive="false"/>
</not>
</and>
</condition>
<echo
message="doSign: ${doSign}"/>
</target>
<target
name="createTraditionalZipFiles"
depends="init">
<property
name="temprunnabledir"
value="${buildDirectory}/runnable/${component}/"/>
<p2.repo2runnable>
<repository
location="file:/${temprunnabledir}"/>
<source>
<repository
location="${p2.build.repo}"/>
</source>
</p2.repo2runnable>
<property
name="ziparchiveName"
value="${component}-${buildLabel}.zip"/>
<copy
todir="${temprunnabledir}"
overwrite="false">
<fileset
dir="${wtp.builder.home}/rootfiles">
</fileset>
</copy>
<zip
destfile="${buildDirectory}/${buildLabel}/${ziparchiveName}">
<zipfileset
dir="${temprunnabledir}"
excludes="content.xml,content.jar,artifacts.xml,artifacts.jar"/>
</zip>
<antcall
target="createChecksums">
<param
name="archiveName"
value="${ziparchiveName}"/>
</antcall>
</target>
<target
name="nodefault">
<echo
level="error"
message="There is no default target for this buildutililites.xml ant script."/>
</target>
</project>