blob: 41949eefcde6cd2d9919c2d513d804c6861af7c9 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!--
Reduced version of the Xtext promoter.
Can only publish a nightly updatesite/p2 repository.
-->
<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}" />
<!-- supply defaults -->
<property name="build.id" value="" />
<property name="hudson.build.id" value="" />
<propertyfile file="${promoter.properties.file}" comment="Promoter script properties">
<entry key="java.home" value="${java.home}" />
<entry key="eclipse.home" value="${eclipse.home}" />
<entry key="build.id" value="${build.id}" />
<entry key="hudson.build.id" value="${hudson.build.id}" />
</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="publish.build">
<fail message="build.root property must be defined" unless="build.root" />
<property file="${build.root}/${publisher.properties.file.name}" />
<property name="property.file.location" location="${build.root}/${promoter.properties.file.name}" />
<property name="property.load.prefix" value="saved." />
<antcall target="-publish.build.start.antRunner" 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" />
<!--
Launches org.eclipse.ant.core.antRunner application using ${launcher.jar}.
Started eclipse instance runs this scripts publish.build.from.framework target.
-->
<target name="-publish.build.start.antRunner" 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>
<!-- Prepare defaults, load properties call publish target. -->
<target name="publish.build.from.framework" depends="-check.property.file.location,-load.properties">
<!--
build.packages.base=EMF.downloads
build.repository.base=EMF.p2.repository
downloads.area=/home/data/httpd/download.eclipse.org/modeling/emf/emf/
repository.name=core
-->
<!-- check properties are set -->
<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>
<fail message="build.root property must be defined" unless="build.root" />
<property file="${build.root}/${publisher.properties.file.name}" />
<fail message="downloads.area property must be defined" unless="downloads.area" />
<fail message="build.repository.base property must be defined" unless="build.repository.base" />
<fail message="build.packages.base property must be defined" unless="build.packages.base" />
<!-- setup composite.repository.base appropriate to the build type -->
<condition property="composite.repository.base" value="nightly">
<matches pattern="^N" string="${saved.build.id}" />
</condition>
<fail message="${composite.repository.base} not defined. Probably last successful build is not a nightly." unless="composite.repository.base" />
<!-- initialize properties -->
<property name="repository.name" value="${saved.build.id}" />
<!-- Source artifacts locations -->
<property name="src.packages.directory" location="${build.root}/${build.packages.base}" />
<property name="src.repo.directory" location="${build.root}/${build.repository.base}" />
<echo>Source repository: ${src.repo.directory}</echo>
<!-- Target artifacts locations -->
<property name="composite.repo.directory" location="${downloads.area}/updates/${composite.repository.base}/" />
<property name="target.repo.directory" location="${composite.repo.directory}/${repository.name}" />
<echo>Target repository: ${target.repo.directory}</echo>
<!-- check artifacts.jar is not the same -->
<condition property="alreadyPromoted">
<filesmatch file1="${src.repo.directory}/artifacts.jar" file2="${target.repo.directory}/artifacts.jar" textfile="false"/>
</condition>
<antcall target="-publish.build.repository" inheritall="true" />
<antcall target="-echo-status" inheritall="true" />
</target>
<target name="-publish.build.repository" if="target.repo.directory" unless="alreadyPromoted">
<!-- clean destination folder, unzip Update zip in it -->
<delete dir="${target.repo.directory}" failonerror="false" />
<copy todir="${target.repo.directory}">
<fileset dir="${src.repo.directory}" />
</copy>
<!-- Modify create composite p2 repository
<property name="composite.repository.url" value="file:/${composite.repository.directory}" />
<p2.composite.repository>
<repository location="${composite.repository.url}" name="EMF nightly" />
<add>
<repository location="${repository.directory}" />
</add>
</p2.composite.repository> -->
<!-- change Group owner -->
<fileset id="repository.resources" dir="${composite.repository.directory}">
<or>
<filename name="compositeContent.*" />
<filename name="compositeArtifacts.*" />
<filename name="${target.repo.directory}/**" />
</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>
</project>