<?xml version="1.0" encoding="UTF-8"?>
<!-- 
============================================================================ 
Name        : release.ant.xml 
Part of     : Helium 

Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
All rights reserved.
This component and the accompanying materials are made available
under the terms of the License "Eclipse Public License v1.0"
which accompanies this distribution, and is available
at the URL "http://www.eclipse.org/legal/epl-v10.html".

Initial Contributors:
Nokia Corporation - initial contribution.

Contributors:

Description:

============================================================================
-->
<project name="release" xmlns:hlm="http://www.nokia.com/helium">
    <description>
        Release publising.
    </description>

    <fileset id="release.files" dir="${publish.dir}">
        <include name="logs/**/*" />
        <include name="development_flash_images/**/*" />
        <include name="release_flash_images/**/*" />
        <include name="sisfiles/**/*" />
        <include name="build_area/**/*" />
        <include name="test_results/**/*" />
        <include name="utilities/**/*" />
    </fileset>

    <!-- Copies release.files fileset into publish.release.folder destination -->
    <target name="release">
        <mkdir dir="${publish.release.dir}" />
        <copy todir="${publish.release.dir}" preservelastmodified="true" failonerror="false">
            <fileset refid="release.files" />
        </copy>
    </target>

    <!--
        This target sets the '''do.robot.release''' property so it activates 
        the '''ido-sources-to-s60-build-robot''' target.
    -->
    <target name="check-robot-release" if="s60.build.robot.path">
        <script language="jython" setbeans="false">
            <![CDATA[
self.setTaskName("check-robot-release")

import ido
projects = []
mconfigstr = project.getProperty('s60.build.robot.date')
if mconfigstr != None:
    for configstr in mconfigstr.split(';'):
        config = map(lambda x: x.strip(), configstr.split(','))
        try:
            if ido.is_in_interval(int(config[0]), config[1], int(config[2]), config[3]):
                self.log("It is release time!")
                projects.append(config[4])
                project.setProperty('do.robot.release', ",".join(projects))
            else:
                self.log("It is not release time!")
        except Exception, e:
            self.log("'%s' invalid configuration." % configstr)
else:
    self.log("'s60.build.robot.date' is not defined.")
]]>
        </script>
    </target>

    <!-- Sources are sent to the S60 build robot by all the IDOs. 
    This target collects all the sources based on the System Definition file, 
    zip them all and send to the specified location. There is only one but mandatory 
    property to tell the location of the build server which is "s60.build.robot.path".
    -->
    <target name="ido-sources-to-s60-build-robot" if="do.robot.release" depends="ido-create-ado-mapping,check-robot-release,lookup-email">
        <property name="ido.template.robot.ready" location="${helium.dir}/tools/common/templates/ido/ready.txt.ftl" />
        <tempfile property="s60robot.dynamic.config" suffix=".xml" deleteonexit="false" destdir="${temp.build.dir}" />
        <fmpp sourceFile="${helium.dir}/tools/common/templates/ido/ido-robot-zip.ant.xml.ftl" outputFile="${s60robot.dynamic.config}">
            <data expandProperties="yes">
                    inputfile: antProperty(ado.mapping.file)
                    ant: antProperties()
                    data: eval('
                                            java.io.FileInputStream pin = new java.io.FileInputStream(filename);
                                            java.util.Properties props = new java.util.Properties();
                                            props.load(pin);
                        return props;
                            ', {filename: get(inputfile)})
            </data>
        </fmpp>
        <ant antfile="${s60robot.dynamic.config}" target="all" />
        <fmpp sourceFile="${ido.template.robot.ready}" outputFile="${s60.build.robot.path}/ready.txt">
            <data expandProperties="yes">
                ant: antProperties()
            </data>
        </fmpp>
    </target>

</project>
