blob: ce4583895cb742cbf804431b7dbde799d98edaec [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"/>
<!--
==================================================================================
Primary Task: unpackUpdateJarsAndCreateZippedPackages This task
takes a zip file of update jars, which is created by PDE build
process, and "converts" it to a traditional zip file, processing
the jars with pack200 for better compression on update sites.
==================================================================================
-->
<target
name="unpackUpdateJarsAndCreateZippedPackages"
depends="init">
<!--
==================================================================================
1. make "backup" copy of original zip, if debugging, since
might be needed for comparison
==================================================================================
-->
<antcall
target="makeBackupCopyForDebugging"/>
<!--
add pack.properties file that specifies effort level, and
files not to sign We don't have to do this if not
normalizing and not signing
-->
<antcall
target="updatePackPropertiesFile"/>
<!--
==================================================================================
2. normalize jars here, from a zip file of update jars. The
normalized jars are put in zip file of same name, in a
directory named normalized
==================================================================================
-->
<echo
level="info"
message="normalize jars if desired ..."/>
<antcall
target="normalizeJarFiles"/>
<echo
level="info"
message="normalized jars: ${normalizeJarFiles}"/>
<!--
==================================================================================
3. sign the jars in archive file, if desired
==================================================================================
-->
<ant
antfile="${wtp.builder.home}/scripts/build/signjars.xml"/>
<!--
==================================================================================
4. unzip the normalized jars in the zip file produced in
step 1., to the directory {tmpsite} for further processing.
plugins and features end up in {tmpsite}/eclipse
==================================================================================
-->
<echo
level="info"
message="unzip normalized update jars to a holding place"/>
<echo
level="info"
message="tmpsite: ${tmpsite}"/>
<echo
level="info"
message="archiveDir: ${archiveDir}"/>
<echo
level="info"
message="archiveName: ${archiveName}"/>
<unzip
dest="${tmpsite}"
src="${archiveDir}/${archiveName}"/>
<!--
==================================================================================
5. copy all update jars to a common update site directory,
if desired. Note: overwite is false to avoid "touching"
files already produced and processed by previous steps in a
larger build process. This means the repository *must* be
completely clean before the larger process starts.
==================================================================================
-->
<antcall
target="makeCopyForUpdate"/>
<!--
==================================================================================
6. for modularity, pack200 is done here, optionally. The
resulting gz files are produced in update site directory.
This is optional since processing is expensive to do for
every build. Only need when ready to declare an update site,
and, for exmaple, no need to do for "local" or HEAD builds
since developers wouldn't normally need it for a quick check
of a build.
==================================================================================
-->
<echo
level="info"
message="create pack files if desired ..."/>
<antcall
target="createPackFilesIfDesired"/>
<echo
level="info"
message="created pack files: ${packJarFiles}"/>
<!--
7. create a site.xml file, by merging a template site.xml
with the feature versions produced by PDE build
-->
<antcall
target="createSiteFiles"/>
<!-- 8. now generate P2 meta data for that P2 repo -->
<echo
level="info"
message="Generating p2 metadata for P2 repo."/>
<antcall
target="generateP2Metadata"/>
<!--
==================================================================================
9. now create traditional zip file of unpacked jars. This
type of "unpack" is not related to pack200, but instead
means to unpack those jars that are supposed to be unpacked
based on feature defintion, if the plugin's unpack attribute
is set to true in the feature
==================================================================================
-->
<!-- use releng task of unpackUpdateJars -->
<unpackUpdateJars
site="${tmpsite}/eclipse"
output="${tmpsite}/unpacked/eclipse"/>
<!--
add copy of legal doc's here, product.ini, etc., before
re-zipping
-->
<copy
todir="${tmpsite}/unpacked/eclipse"
overwrite="false">
<fileset
dir="${wtp.builder.home}/rootfiles">
</fileset>
</copy>
<!--
delete the zip file of update jars we started with, which we
are about to re-create as traditional zip file
-->
<delete
file="${buildDirectory}/${buildLabel}/${archiveName}"/>
<mkdir
dir="${buildDirectory}/${buildLabel}"/>
<!--
recreate zip file now, same name, traditional content, which
is mix of folders and jars
-->
<!--
explicitly exclude any features with assembly anywhere in
directory names, as these are just for controlling what's
built, and are not intended for delivery
-->
<zip
destfile="${buildDirectory}/${buildLabel}/${archiveName}"
basedir="${tmpsite}/unpacked"
update="false"
duplicate="preserve"
excludes="**/*assembly*/**"/>
<!-- always produce checksum files for any zips produced -->
<antcall
target="createChecksums"/>
<!--
==================================================================================
10. can now remove tmpsite as no longer needed, unless
debugging
==================================================================================
-->
<antcall
target="deleteTmpSite"/>
</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>
<target
name="deleteTmpSite"
unless="keepIfDebug">
<delete
dir="${tmpsite}"/>
</target>
<target
name="normalizeJarFiles"
if="doNormalize"
depends="init">
<!--
stick with JAVA5 for signing/packing for now ... I've heard
rumors of some 'compatibility' issues with JAVA6?
-->
<echo
message="Starting normalizeJarFiles"/>
<echo
message="archiveDir: ${archiveDir}"/>
<java
jar="${eclipse.launcher}"
fork="true"
jvm="${env.JAVA_5_HOME}/bin/java"
failonerror="true"
maxmemory="512m"
dir="${buildDirectory}">
<jvmarg
value="-Djava.io.tmpdir=${env.RECOMMENDED_TMP_DIR}"/>
<arg
line="${logIfDebug}"/>
<arg
line="-application org.eclipse.update.core.siteOptimizer"/>
<!--
note: this -processAll option is critical in this first
step. For various reasons, jarProcessor is written to
not act on any jar if the jar is not "marked", or if not
told explicitly to to processAll. There are ways where
not all are literally processed, such as using
pack.properties (and others, see
http://wiki.eclipse.org/JarProcessor_Options).
-->
<arg
line="-jarProcessor ${verboseIfDebug} -processAll -outputDir ${archiveDir} -repack ${buildDirectory}/${buildLabel}/${archiveName}"/>
</java>
</target>
<target
name="createPackFilesIfDesired"
if="doPack"
depends="init">
<!--
stick with JAVA5 for signing/packing for now ... I've heard
rumors of some 'compatibility' issues with JAVA6?
-->
<!--
<java
jar="${pde.builder.path}/plugins/org.eclipse.equinox.launcher.jar"
fork="true" jvm="${env.JAVA_5_HOME}/bin/java"
failonerror="true" maxmemory="512m" dir="${buildDirectory}">
<jvmarg
value="-Djava.io.tmpdir=${env.RECOMMENDED_TMP_DIR}"/> <arg
line="${logIfDebug}"/> <arg line="-application
org.eclipse.update.core.siteOptimizer"/> <arg
line="-jarProcessor ${verboseIfDebug} -outputDir
${buildDirectory}/${buildLabel}/repository -pack
${buildDirectory}/${buildLabel}/repository"/> </java>
-->
<java
jar="${pde.builder.path}/plugins/org.eclipse.equinox.launcher.jar"
fork="true"
jvm="${env.JAVA_5_HOME}/bin/java"
failonerror="true"
maxmemory="512m"
dir="${buildDirectory}">
<jvmarg
value="-Djava.io.tmpdir=${env.RECOMMENDED_TMP_DIR}"/>
<arg
line="${logIfDebug}"/>
<arg
line="-application org.eclipse.update.core.siteOptimizer"/>
<arg
line="-jarProcessor ${verboseIfDebug} -outputDir ${buildDirectory}/${buildLabel}/${component}/repository -pack ${buildDirectory}/${buildLabel}/${component}/repository"/>
</java>
</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="makeCopyForUpdate">
<mkdir
dir="${buildDirectory}/${buildLabel}/repository"/>
<copy
todir="${buildDirectory}/${buildLabel}/repository"
overwrite="false">
<fileset
dir="${tmpsite}/eclipse">
<exclude
name="**/*assembly*/**"/>
</fileset>
</copy>
<mkdir
dir="${buildDirectory}/${buildLabel}/${component}/repository"/>
<copy
todir="${buildDirectory}/${buildLabel}/${component}/repository"
overwrite="false">
<fileset
dir="${tmpsite}/eclipse">
<exclude
name="**/*assembly*/**"/>
</fileset>
</copy>
</target>
<target
name="makeBackupCopyForDebugging"
if="keepIfDebug">
<!--
temporary copy while confirming build to be able to do
side-by-side comparisons
-->
<mkdir
dir="${buildDirectory}/backuporiginalzips"/>
<copy
file="${buildDirectory}/${buildLabel}/${archiveName}"
todir="${buildDirectory}/backuporiginalzips"/>
</target>
<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}"
property="md5"/>
<echo
message="${md5} *${archiveName}"
file="${buildDirectory}/${buildLabel}/checksum/${archiveName}.md5"/>
<echo
message="${md5}"
file="${buildDirectory}/${buildLabel}/checksum/${archiveName}.md5antformat"/>
</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>
<!-- Call the p2 metadata generator on the update site. -->
<!-- TODO: do we need to pack200 files first? (create gz files?) -->
<target
name="generateP2Metadata"
depends="init"
if="doP2Repo">
<!-- 1. Generate the P2 metadata -->
<!--
ant version <p2.generator
updateSite="${buildDirectory}/${buildLabel}/${component}/repository"
compress="true"
metadataRepository="file:${buildDirectory}/${buildLabel}/${component}/repository"
artifactRepository="file:${buildDirectory}/${buildLabel}/${component}/repository"
metadataRepositoryName="Web Tools Platform Repository"
artifactRepositoryName="Web Tools Platform Repository"
noDefaultIUs="true"/>
-->
<!--
java invocation version (Orbit had trouble running ant
version, so used direct java call
-->
<!--
these shouldn't exist ... but, just in case something
changes in future we'll be sure
-->
<delete
quiet="true"
file="${buildDirectory}/${buildLabel}/${component}/repository/artifacts.jar"/>
<delete
quiet="true"
file="${buildDirectory}/${buildLabel}/${component}/repository/content.jar"/>
<java
jar="${eclipse.launcher}"
fork="true"
jvm="${env.JAVA_5_HOME}/bin/java"
failonerror="true"
maxmemory="512m"
dir="${buildDirectory}">
<jvmarg
value="-Djava.io.tmpdir=${env.RECOMMENDED_TMP_DIR}"/>
<arg
line="-application org.eclipse.equinox.p2.metadata.generator.EclipseGenerator"/>
<arg
line="-consoleLog"/>
<arg
line="-nosplash"/>
<arg
line="--launcher.suppressErrors"/>
<arg
line="-metadataRepository file:${buildDirectory}/${buildLabel}/${component}/repository"/>
<arg
line="-artifactRepository file:${buildDirectory}/${buildLabel}/${component}/repository"/>
<arg
line="-metadataRepositoryName Web-Tools-Platform-${buildLabel}"/>
<arg
line="-artifactRepositoryName Web-Tools-Platform-${buildLabel}"/>
<arg
line="-updateSite ${buildDirectory}/${buildLabel}/${component}/repository"/>
<arg
line="-reusePack200Files"/>
<arg
line="-compress"/>
<arg
line="-noDefaultIUs"/>
<arg
line="-site file:${buildDirectory}/${buildLabel}/${component}/repository/site.xml"/>
</java>
<delete
quiet="true"
file="${buildDirectory}/${buildLabel}/repository/artifacts.jar"/>
<delete
quiet="true"
file="${buildDirectory}/${buildLabel}/repository/content.jar"/>
<java
jar="${eclipse.launcher}"
fork="true"
jvm="${env.JAVA_5_HOME}/bin/java"
failonerror="true"
maxmemory="512m"
dir="${buildDirectory}">
<jvmarg
value="-Djava.io.tmpdir=${env.RECOMMENDED_TMP_DIR}"/>
<arg
line="-application org.eclipse.equinox.p2.metadata.generator.EclipseGenerator"/>
<arg
line="-consoleLog"/>
<arg
line="-nosplash"/>
<arg
line="--launcher.suppressErrors"/>
<arg
line="-metadataRepository file:${buildDirectory}/${buildLabel}/repository"/>
<arg
line="-artifactRepository file:${buildDirectory}/${buildLabel}/repository"/>
<arg
line="-metadataRepositoryName Web-Tools-Platform-${buildLabel}"/>
<arg
line="-artifactRepositoryName Web-Tools-Platform-${buildLabel}"/>
<arg
line="-updateSite ${buildDirectory}/${buildLabel}/repository"/>
<arg
line="-reusePack200Files"/>
<arg
line="-compress"/>
<arg
line="-noDefaultIUs"/>
<arg
line="-site file:${buildDirectory}/${buildLabel}/repository/site.xml"/>
</java>
<!--
2. Create zip of P2 repo. Note we put it in
'repoBaseLocation' for use by subsequent build steps TODO:
investigate a location outside a per-build location
-->
<mkdir
dir="${buildDirectory}/${buildLabel}/repos"/>
<zip
destfile="${buildDirectory}/${buildLabel}/repos/${component}-buildrepo-${buildLabel}.zip"
basedir="${buildDirectory}/${buildLabel}/${component}/repository/"
excludes="${excludeFromRepoZip}"
update="yes"
duplicate="preserve">
</zip>
<!--
<zip
destfile="${buildDirectory}/${buildLabel}/repos/${build.distribution}-buildrepo-${buildLabel}.zip"
basedir="${buildDirectory}/${buildLabel}/repository/"
excludes="${excludeFromRepoZip}" update="yes"
duplicate="preserve"> </zip>
-->
<!--
3. generate maps each step TODO: avoid double processing by
changing task so that if file exists, append to it
-->
<generateMapFiles
buildlabel="${buildLabel}"
inputFilePluginVersions="${buildDirectory}/finalPluginsVersions.properties"
inputFileFeatureVersions="${buildDirectory}/finalFeaturesVersions.properties"
p2MapFile="${buildDirectory}/${buildLabel}/Web-Tools-Platform-${buildLabel}.p2.map"
p2Repository="http://build.eclipse.org/webtools/committers/${projectname}/${buildLabel}/repository"/>
</target>
<target
name="createSiteFiles"
depends="init"
if="doP2Repo">
<property
name="sitexmlfile"
value="${buildDirectory}/maps/webtools.maps/releng/sitefile/site.xml"/>
<property
file="${buildDirectory}/finalFeaturesVersions.properties"/>
<loadfile
property="sitefiletext"
srcFile="${sitexmlfile}">
<filterchain>
<expandproperties/>
</filterchain>
</loadfile>
<echo
message="${sitefiletext}"
file="${buildDirectory}/${buildLabel}/repository/site.xml"/>
<echo
message="${sitefiletext}"
file="${buildDirectory}/${buildLabel}/${component}/repository/site.xml"/>
</target>
<target
name="updatePackPropertiesFile"
if="doNormalize">
<updatePackProperties
archiveFilename="${buildDirectory}/${buildLabel}/${archiveName}"/>
</target>
<target
name="nodefault">
<echo
level="error"
message="There is no default target for this buildutililites.xml ant script."/>
</target>
</project>