<?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:

============================================================================
-->
<!--* @package releases -->
<project name="release" xmlns:hlm="http://www.nokia.com/helium">
    <description>
        Release publising.
    </description>
    
    <!--* @property release.grace.service
    The Grace service used
    @type string
    @editable required
    @scope public
    -->

    <!--* @property release.grace.product
    The Grace product used
    @type string
    @editable required
    @scope public
    -->

    <!--* @property release.grace.mail.to
    To whom the completion mail is sent to
    @type string
    @editable required
    @scope public
    -->

    <!--* @property release.grace.mail.subject
    The subject of the Grace upload completion mail
    @type string
    @editable required
    @scope public
    -->

    <!--* @property release.grace.mail.message
    The message contents of the Grace upload completion mail
    @type string
    @editable required
    @scope public
    -->

    <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>

    <!--* @property s60.build.robot.path
    Location where to publish the build robot delivery.
    @type string
    @editable required
    @scope public
    -->

    <!--* @property s60.build.robot.date
    This property represent the releasing interval. The syntax is as follow: day1,time1,day2,time2,projectname;day1,time1,day2,time2,projectname2 With day and time matching the following properties: day [1, 14] time [00, 23]:[00, 59] Example: 2,10:00,3,20:00,ABS_domain
    @type string
    @editable required
    @scope public
    -->

    <!--
        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">
        <!-- Location of the ready.txt FMPP template (override that property if you want to customize the content).
        @type string
        @scope private
        -->
        <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>
