buildframework/helium/sf/java/sbs/src/com/nokia/helium/sbs/ant/taskdefs/GetSBSInputsTask.java
author wbernard
Fri, 13 Aug 2010 14:59:05 +0300
changeset 628 7c4a911dc066
parent 588 c7c26511138f
permissions -rw-r--r--
helium_11.0.0-e00f171ca185
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
     1
/*
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
     2
 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
     3
 * All rights reserved.
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
     5
 * under the terms of the License "Eclipse Public License v1.0"
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
     8
 *
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
     9
 * Initial Contributors:
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    11
 *
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    12
 * Contributors:
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    13
 *
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    14
 * Description:  
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    15
 *
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    16
 */
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    17
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    18
package com.nokia.helium.sbs.ant.taskdefs;
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    19
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    20
import java.util.List;
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    21
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    22
import org.apache.tools.ant.BuildException;
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    23
import org.apache.tools.ant.Task;
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    24
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    25
import com.nokia.helium.sbs.ant.SBSBuildList;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    26
import com.nokia.helium.sbs.ant.types.SBSInput;
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    27
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    28
/**
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    29
 * This task provide a way to get the list of sbs command input for a particular
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    30
 * configuration from abld. For every abld command mentioned for a configuration 
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    31
 * from schema 1.4.0, there should be a corresponding sbsinput and for all
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    32
 * abld commands in the sysdef configuration a corresponding sbsbuild command has
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    33
 * to be there. And using this task the list of sbs commands are extracted and executed 
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    34
 * one after another. This is only for backward compatibility, once the sysdef config
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    35
 * is migrated to 3.0, this task would be deprecated.
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    36
 * 
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    37
 * This is internal task and should not be used outside helium.
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    38
 * 
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    39
 * <pre>
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    40
 * Example 1:
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    41
 * &lt;getsbsinputs config=&quot;sysdef.configuration&quot;
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    42
 *      outputProperty=&quot;sbs.internal.list&quot;/&gt;
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    43
 * </pre>
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    44
 * 
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    45
 * @ant.task name="getsbsinputs" category="SBS"
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    46
 */
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    47
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    48
public class GetSBSInputsTask extends Task {
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    49
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    50
    private String configName;
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    51
    private String outputProperty;
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    52
    
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    53
    /**
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    54
     *  Helper function to set the configuration name for
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    55
     *  which the sbs commands to be extracted.
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    56
     * @param name of the configuration for which sbs commands to be obtained.
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    57
     */
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    58
    public void setConfig(String name) {
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    59
        configName = name;
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    60
    }
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    61
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    62
    /**
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    63
     *  Helper function to retrive the sbs input list (list of sbs commands
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    64
     *  to be executed one after another). The list is provided with comma
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    65
     *  separated values.
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    66
     * @param property name of the property where the sbs input list to be stored.
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    67
     */
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    68
    public void setOutputProperty(String property) {
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    69
        outputProperty = property;
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    70
    }
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    71
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    72
    /**
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    73
     *  Execute the task. Finds the list of sbsinput and store it in
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    74
     *  outputproperty with comma separated values.
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    75
     * @throws BuildException
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    76
     */
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    77
    public void execute() {
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    78
        if (configName == null) {
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    79
            throw new BuildException("configInput is not defined");
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    80
        }
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    81
        List<SBSInput> sbsInputList = SBSBuildList.getSBSInputList(getProject(), configName);
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    82
        StringBuffer inputs = new StringBuffer();
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    83
        for (SBSInput input : sbsInputList) {
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    84
            if (inputs.length() > 0) {
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    85
                inputs.append(",");
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    86
            }
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    87
            inputs.append(input.getRefid().getRefId());
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    88
            getProject().setProperty(outputProperty,inputs.toString());
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    89
        }
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    90
    }
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    91
}