blob: d8bf61172eb2e95630206f3d6b4043912805d299 [file]
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2010, 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="buildutilities"
default="nodefault"
basedir=".">
<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
level="debug"
message="p2.build.repo: ${p2.build.repo}"/>
<zip destfile="${buildDirectory}/${buildLabel}/temp-${buildLabel}-${component}.zip">
<zipfileset
dir="${buildDirectory}/${buildLabel}/buildrepository/${component}/"
excludes="content.xml,content.jar,artifacts.xml,artifacts.jar"/>
</zip>
<updatePackProperties
archiveFilename="${buildDirectory}/${buildLabel}/temp-${buildLabel}-${component}.zip"
verbose="false"/>
<!--
comment out the following delete statement, when debugging,
to see original zip files, before updatePackProperties ran
-->
<delete
quiet="true"
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}/buildrepository/${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
quiet="true"
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! :)
-->
<mkdir dir="${buildDirectory}/${buildLabel}/repos/"/>
<zip destfile="${buildDirectory}/${buildLabel}/repos/${archiveName}">
<zipfileset dir="${buildDirectory}/${buildLabel}/buildrepository/${component}"/>
</zip>
<antcall target="createChecksums">
<param
name="subdir"
value="repos/"/>
<param
name="archiveName"
value="${archiveName}"/>
</antcall>
<!--
now pack what's in repository ...
TODO: invalid if not conditioned.
make conditional on conditioning/signing
even if signed, still not great to do here, since it is a lengthy process,
we should do only at end (or as part of "promote") once we know we need
the pack.gz versions. Also, when we created downloadable repos, we don't
want pack.gz files in them.
<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}/buildrepository"
name="Build repository ${buildLabel}"/>
<add>
<repository location="${component}"/>
</add>
</p2.composite.repository>
</target>
<!--
==============================================================================================
Utility and Helper tasks
==============================================================================================
-->
<target
name="init"
depends="standardInit,check.sign"
unless="buildutilities.initialized">
<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>
<!-- echo important values, so it's documneted in build logs -->
<echo
level="debug"
message="doPack: ${doPack}"/>
<echo
level="debug"
message="packJarFiles: ${packJarFiles}"/>
<echo
level="debug"
message="normalizeJarFiles: ${normalizeJarFiles}"/>
<echo
level="debug"
message="doNormalize: ${doNormalize}"/>
<property
name="buildutilities.initialized"
value="true"/>
</target>
<target
name="standardInit"
unless="standardInitialized">
<!-- = = = 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"/>
<property
name="standardInitialized"
value="true"/>
</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.
-->
<!-- if not set, do not use a subdir. caller must include follow '/', such as sudir="repos/" -->
<property
name="subdir"
value=""/>
<mkdir dir="${buildDirectory}/${buildLabel}/${subdir}checksum"/>
<checksum
file="${buildDirectory}/${buildLabel}/${subdir}${archiveName}"
todir="${buildDirectory}/${buildLabel}/${subdir}checksum/"
pattern="{0} *{1}"
fileext=".md5"
algorithm="MD5"/>
<checksum
file="${buildDirectory}/${buildLabel}/${subdir}${archiveName}"
todir="${buildDirectory}/${buildLabel}/${subdir}checksum/"
pattern="{0} *{1}"
fileext=".sha1"
algorithm="SHA1"/>
</target>
<target
name="check.sign"
unless="check.sign.initialized">
<echo
level="debug"
message="sign: ${sign}"/>
<echo
level="debug"
message="env skip jar signing: ${env.SKIP_JAR_SIGNING}"/>
<echo
level="debug"
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
level="info"
message="doSign: ${doSign}"/>
<property
name="check.sign.initialized"
value="true"/>
</target>
<target
name="createTraditionalZipFiles"
depends="init">
<property
name="temprunnabledir"
value="${buildDirectory}/runnable/${component}"/>
<property
name="temprunnabledireclipse"
value="${temprunnabledir}/eclipse"/>
<p2.repo2runnable>
<repository location="file:/${temprunnabledireclipse}"/>
<source>
<repository location="${p2.build.repo}"/>
</source>
</p2.repo2runnable>
<property
name="ziparchiveName"
value="${component}-${buildLabel}.zip"/>
<copy
todir="${temprunnabledireclipse}"
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>
<delete
quiet="true"
dir="${temprunnabledir}"/>
</target>
<target name="nodefault">
<echo
level="error"
message="There is no default target for this buildutililites.xml ant script."/>
</target>
</project>