| <?xml version="1.0" encoding="UTF-8"?> |
| <project name="Promoter / Publisher" default="publish.build"> |
| <property name="promoter.properties.file.name" value="promote.properties" /> |
| <property name="publisher.properties.file.name" value="publisher.properties" /> |
| |
| <target name="-setup.promoter"> |
| <!-- <property name="promoter.setup.directory" location="${sp:output}" /> |
| <property name="promoter.properties.file" location="${promoter.setup.directory}/${promoter.properties.file.name}" /> |
| |
| <mkdir dir="${promoter.setup.directory}" />--> |
| <property environment="env." /> |
| |
| <fail message="WORKSPACE not present in the environment, can't continue" unless="env.WORKSPACE" /> |
| <property name="promoter.properties.file" location="${env.WORKSPACE}/${promoter.properties.file.name}" /> |
| |
| <!-- supply defaults --> |
| <property name="build.id" value="" /> |
| <property name="hudson.build.id" value="" /> |
| <property name="must.publish.javadoc" value="false"/> |
| |
| <propertyfile file="${promoter.properties.file}" comment="Promoter script properties"> |
| <entry key="eclipse.home" value="${eclipse.home}" /> |
| <entry key="build.id" value="${build.id}" /> |
| <entry key="hudson.build.id" value="${hudson.build.id}" /> |
| <entry key="must.publish.doc" value="${manage.doc}" /> |
| <entry key="must.publish.javadoc" value="${manage.javadoc}" /> |
| </propertyfile> |
| |
| <!-- diagnostics |
| <property environment="env." /> |
| <echoproperties destfile="${promoter.setup.directory}/all.properties" /> |
| --> |
| </target> |
| |
| <target name="-locate.launcher.jar" unless="launcher.jar"> |
| <pathconvert property="launcher.jar"> |
| <first count="1"> |
| <sort> |
| <fileset dir="${saved.eclipse.home}/plugins" includes="**/org.eclipse.equinox.launcher_*.jar" /> |
| <reverse xmlns="antlib:org.apache.tools.ant.types.resources.comparators"> |
| <date /> |
| </reverse> |
| </sort> |
| </first> |
| </pathconvert> |
| </target> |
| |
| <target name="setup.publisher"> |
| <property environment="env." /> |
| |
| <fail message="WORKSPACE not present in the environment, can't continue" unless="env.WORKSPACE" /> |
| |
| <!-- default publisher root --> |
| <property name="publisher.root" location="${env.WORKSPACE}/publishroot" /> |
| |
| <delete dir="${publisher.root}" /> |
| <mkdir dir="${publisher.root}" /> |
| |
| <copy tofile="${publisher.root}/publisher.ant" file="${ant.file}" /> |
| |
| <property name="promoter.properties.file" value="${env.WORKSPACE}/${promoter.properties.file.name}" /> |
| |
| <!-- load the promoter properties using the PROMOTED_URL supplied by Hudson --> |
| <property prefix="saved." file="${promoter.properties.file}" /> |
| |
| <fail message="hudson.build.id not defined in ${promoter.properties.file}, can't continue"> |
| <condition> |
| <not> |
| <and> |
| <isset property="saved.hudson.build.id" /> |
| <length string="${saved.hudson.build.id}" trim="true" when="greater" length="0" /> |
| </and> |
| </not> |
| </condition> |
| </fail> |
| |
| <property name="build.root" location="${env.WORKSPACE}/../builds/${saved.hudson.build.id}" /> |
| |
| <echoproperties destfile="${publisher.root}/${publisher.properties.file.name}"> |
| <propertyset> |
| <propertyref builtin="commandline" /> |
| <propertyref prefix="saved." /> |
| <propertyref name="build.root" /> |
| </propertyset> |
| </echoproperties> |
| </target> |
| |
| <target name="publish.build"> |
| <fail message="build.archives property must be defined" unless="build.archives" /> |
| <property file="${publisher.properties.file.name}" /> |
| <property name="property.file.location" location="${build.archives}/${promoter.properties.file.name}" /> |
| <property name="property.load.prefix" value="saved." /> |
| |
| <antcall target="publish.build.stage.2" inheritall="true" /> |
| </target> |
| |
| <target name="-setup.property.file.location" unless="property.file.location"> |
| <dirname property="script.directory" file="${ant.file}" /> |
| <property name="property.file.location" location="${script.directory}/${publisher.properties.file.name}" /> |
| </target> |
| |
| <target name="-load.properties.as.is" unless="property.load.prefix"> |
| <property file="${property.file.location}" /> |
| </target> |
| |
| <target name="-load.properties.with.prefix" if="property.load.prefix"> |
| <property prefix="${property.load.prefix}" file="${property.file.location}" /> |
| </target> |
| |
| <target name="-load.properties" depends="-load.properties.as.is,-load.properties.with.prefix" /> |
| |
| <target name="publish.build.stage.2" depends="-setup.property.file.location,-load.properties,-locate.launcher.jar"> |
| <condition property="java.executable" value="${saved.java.home}/bin/java" else="java"> |
| <isset property="saved.java.home" /> |
| </condition> |
| <tempfile property="publisher.workspace" prefix="workspace." destdir="${java.io.tmpdir}" /> |
| <echo>Used launcher: ${launcher.jar}</echo> |
| <java jvm="${java.executable}" jar="${launcher.jar}" fork="true" failonerror="true"> |
| <syspropertyset> |
| <propertyref builtin="commandline" /> |
| <propertyref name="property.file.location" /> |
| <propertyref name="property.load.prefix" /> |
| </syspropertyset> |
| <arg value="-data" /> |
| <arg value="${publisher.workspace}" /> |
| <arg value="-configuration" /> |
| <arg value="${publisher.workspace}/configuration" /> |
| <arg value="-application" /> |
| <arg value="org.eclipse.ant.core.antRunner" /> |
| <arg value="-buildfile" /> |
| <arg value="${ant.file}" /> |
| <arg value="publish.build.from.framework" /> |
| </java> |
| |
| <!-- |
| somewhat more complicated than simple <delete dir="${publisher.workspace}" /> |
| but this way it does not produce the "Deleting directory" message |
| --> |
| <delete dir="${publisher.workspace}" includeemptydirs="true" quiet="true"> |
| <or> |
| <type type="dir" /> |
| <type type="file" /> |
| </or> |
| </delete> |
| </target> |
| |
| <target name="-check.property.file.location"> |
| <fail message="property.file.location property must be defined" unless="property.file.location" /> |
| </target> |
| |
| <target name="publish.build.from.framework" depends="-check.property.file.location,-load.properties"> |
| <fail message="saved.build.id property must be defined"> |
| <condition> |
| <not> |
| <and> |
| <isset property="saved.build.id" /> |
| <length string="${saved.build.id}" trim="true" when="greater" length="0" /> |
| </and> |
| </not> |
| </condition> |
| </fail> |
| <property file="${publisher.properties.file.name}" /> |
| <fail message="build.archives property must be defined" unless="build.archives" /> |
| <fail message="downloads.area property must be defined" unless="downloads.area" /> |
| <fail message="doc.area property must be defined" unless="doc.area" /> |
| <fail message="javadoc.area property must be defined" unless="javadoc.area" /> |
| |
| <!-- defaults --> |
| <property name="version" value="3.1.0" /> |
| <property name="packages.base" value="downloads" /> |
| <property name="tests.base" value="test.results" /> |
| <property name="doc.base" value="MDT-OCL.doc" /> |
| <property name="javadoc.base" value="MDT-OCL.javadoc" /> |
| |
| <property name="packages.directory" location="${build.archives}/${packages.base}" /> |
| <property name="testresults.directory" location="${build.archives}/${tests.base}" /> |
| <property name="doc.directory" location="${build.archives}/${doc.base}" /> |
| <property name="javadoc.directory" location="${build.archives}/${javadoc.base}" /> |
| |
| <property name="project.doc.directory" location="${doc.area}/${version}" /> |
| <property name="project.javadoc.directory" location="${javadoc.area}/${version}" /> |
| <property name="build.drop.directory" location="${downloads.area}/downloads/drops/${version}/${saved.build.id}" /> |
| <available file="${build.drop.directory}" type="dir" property="alreadyPromoted" /> |
| <antcall target="publish" inheritall="true" /> |
| <antcall target="echo-status" inheritall="true" /> |
| </target> |
| |
| <target name="publish" unless="alreadyPromoted"> |
| <!-- will fail if already exists --> |
| <mkdir dir="${build.drop.directory}" /> |
| |
| <echo>Remove existing nightly builds</echo> |
| <delete verbose="true"> |
| <fileset dir="${downloads.area}/downloads/drops/${version}/"> |
| <type type="dir" /> |
| <include name="N*" /> |
| </fileset> |
| </delete> |
| |
| <echo>Copying zip packages</echo> |
| <copy todir="${build.drop.directory}"> |
| <fileset dir="${packages.directory}"> |
| <filename name="*.zip" /> |
| </fileset> |
| </copy> |
| |
| <echo>Generating md5 checksums</echo> |
| <checksum algorithm="MD5" fileext=".md5" format="MD5SUM"> |
| <fileset dir="${build.drop.directory}"> |
| <filename name="*.zip" /> |
| </fileset> |
| </checksum> |
| |
| <echo>Generating SHA-512 checksums</echo> |
| <checksum algorithm="SHA-512" fileext=".sha1" format="MD5SUM"> |
| <fileset dir="${build.drop.directory}"> |
| <filename name="*.zip" /> |
| </fileset> |
| </checksum> |
| |
| <echo>Copying Test Results</echo> |
| <mkdir dir="${build.drop.directory}/testresults" /> |
| <copy todir="${build.drop.directory}/testresults"> |
| <fileset dir="${testresults.directory}"> |
| <filename name="**/*.xml" /> |
| </fileset> |
| </copy> |
| |
| <fileset id="drop.resources" dir="${build.drop.directory}"> |
| <or> |
| <type type="dir" /> |
| <type type="file" /> |
| </or> |
| </fileset> |
| |
| <!-- chgrp --> |
| <antcall target="-change.group.owner" inheritall="true"> |
| <reference refid="drop.resources" torefid="change.group.owner.resources" /> |
| </antcall> |
| |
| <!-- strip the micro version and anything following it --> |
| <buckminster.substitute value="${version}" pattern="^(\d+\.\d+)\.\d+.*$" replacement="$$1" property="base.version" /> |
| |
| <!-- setup composite.repository.base appropriate to the build type --> |
| <condition property="composite.repository.base" value="nightly/${version}"> |
| <matches pattern="^N" string="${saved.build.id}" /> |
| </condition> |
| <condition property="composite.repository.base" value="maintenance/${version}/${saved.build.id}"> |
| <matches pattern="^M" string="${saved.build.id}" /> |
| </condition> |
| <condition property="composite.repository.base" value="interim/${version}"> |
| <matches pattern="^I" string="${saved.build.id}" /> |
| </condition> |
| <condition property="composite.repository.base" value="milestones/${version}/${saved.build.id}"> |
| <matches pattern="^S" string="${saved.build.id}" /> |
| </condition> |
| <condition property="composite.repository.base" value="releases/${version}/${base.version}"> |
| <matches pattern="^R" string="${saved.build.id}" /> |
| </condition> |
| |
| <antcall target="-publish.build.repository" inheritall="true" /> |
| |
| <!-- Prepare the property which will dictate if the javadoc will be published --> |
| |
| <condition property="publish.javadoc"> |
| <equals arg1="${saved.must.publish.javadoc}" arg2="true"/> |
| </condition> |
| <antcall target="-publish.javadoc" inheritall="true" /> |
| |
| <condition property="publish.doc"> |
| <equals arg1="${saved.must.publish.doc}" arg2="true"/> |
| </condition> |
| <antcall target="-publish.doc" inheritall="true" /> |
| </target> |
| |
| <target name="-publish.build.repository" if="composite.repository.base"> |
| <property name="composite.repository.directory" location="${downloads.area}/updates/${composite.repository.base}" /> |
| <property name="composite.repository.url" value="file:/${composite.repository.directory}" /> |
| <!-- |
| without p2.composite.repository |
| <property name="build.repository.directory" location="${composite.repository.directory}/${saved.build.id}" /> |
| --> |
| <property name="build.repository.directory" location="${composite.repository.directory}" /> |
| |
| <deltree dir="${build.repository.directory}" /> |
| |
| <unzip dest="${build.repository.directory}"> |
| <fileset dir="${packages.directory}"> |
| <filename name="*-Update*.zip" /> |
| </fileset> |
| </unzip> |
| |
| <!--<p2.composite.repository destination="${composite.repository.url}"> |
| <add> |
| <repository location="${saved.build.id}" /> |
| </add> |
| </p2.composite.repository>--> |
| |
| |
| <!-- change Group owner --> |
| <fileset id="repository.resources" dir="${composite.repository.directory}"> |
| <or> |
| <filename name="compositeContent.*" /> |
| <filename name="compositeArtifacts.*" /> |
| <filename name="${saved.build.id}/**" /> |
| </or> |
| </fileset> |
| |
| <antcall target="-change.group.owner" inheritall="true"> |
| <reference refid="repository.resources" torefid="change.group.owner.resources" /> |
| </antcall> |
| </target> |
| |
| <target name="-change.group.owner" if="group.owner"> |
| <chgrp group="${group.owner}" type="both" verbose="true"> |
| <fileset refid="change.group.owner.resources" /> |
| </chgrp> |
| </target> |
| |
| <target name="echo-status" if="alreadyPromoted"> |
| <echo>Build ${saved.build.id} already promoted, nothing to do...</echo> |
| </target> |
| |
| <target name="-publish.doc" if="publish.doc"> |
| <mkdir dir="${project.doc.directory}" /> |
| <echo>Remove existing doc from ${project.doc.directory}</echo> |
| <delete verbose="true"> |
| <fileset dir="${project.doc.directory}"/> |
| </delete> |
| |
| <dirset id="dist1.contents" dir="${doc.directory}/.." includes="*"/> |
| <property name="prop.dist1.contents" refid="dist1.contents"/> |
| <echo>${doc.directory}/..: ${prop.dist1.contents}</echo> |
| |
| <echo>Copying ${doc.directory}/ocl.pdf to ${project.doc.directory}</echo> |
| <copy todir="${project.doc.directory}"> |
| <fileset dir="${doc.directory}"> |
| <filename name="ocl.pdf" /> |
| </fileset> |
| </copy> |
| </target> |
| |
| <target name="-publish.javadoc" if="publish.javadoc"> |
| <mkdir dir="${project.javadoc.directory}" /> |
| <echo>Remove existing javadoc from ${project.javadoc.directory}</echo> |
| <delete verbose="true"> |
| <fileset dir="${project.javadoc.directory}"/> |
| </delete> |
| |
| <dirset id="dist1.contents" dir="${javadoc.directory}/.." includes="*"/> |
| <property name="prop.dist1.contents" refid="dist1.contents"/> |
| <echo>${javadoc.directory}/..: ${prop.dist1.contents}</echo> |
| |
| <echo>Unzipping ${javadoc.directory}/MDT-OCL-javadoc.zip to ${project.javadoc.directory}</echo> |
| <unzip dest="${project.javadoc.directory}"> |
| <fileset dir="${javadoc.directory}"> |
| <filename name="MDT-OCL-javadoc.zip" /> |
| </fileset> |
| </unzip> |
| </target> |
| </project> |