buildframework/helium/sf/java/legacy/src/com/nokia/tools/configuration/CONFIGURATIONTool.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:
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     1
/*
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
     2
 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
     3
 * All rights reserved.
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
     4
 * This component and the accompanying materials are made available
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
     5
 * under the terms of the License "Eclipse Public License v1.0"
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
     6
 * which accompanies this distribution, and is available
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
     8
 *
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
     9
 * Initial Contributors:
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    10
 * Nokia Corporation - initial contribution.
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    11
 *
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    12
 * Contributors:
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    13
 *
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    14
 * Description: 
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    15
 *
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    16
 */
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    17
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    18
package com.nokia.tools.configuration;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    19
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    20
import org.apache.tools.ant.Project;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    21
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    22
import com.nokia.helium.core.ant.MappedVariable;
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    23
import com.nokia.helium.core.ant.types.VariableSet;
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    24
import com.nokia.tools.Tool;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    25
import com.nokia.tools.ToolsProcessException;
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    26
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    27
/**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    28
 * Command Line wrapper for configuration tools
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    29
 */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    30
public class CONFIGURATIONTool implements Tool {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    31
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    32
    /**
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    33
     * Sets the command line variables to be used to execute and validates for the required
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    34
     * parameters
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    35
     * 
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    36
     * @param varSet variable(name / value list)
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    37
     */
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    38
    public void execute(VariableSet varSet, Project prj) throws ToolsProcessException {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    39
        String path = null;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    40
        String masterConf = null;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    41
        String confml = null;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    42
        String impl = null;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    43
        String iby = null;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    44
        String keepGoing = "false";
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    45
        String report = null;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    46
        String varName;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    47
        String value;
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    48
        for (MappedVariable variable : varSet.getVariables()) {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    49
            varName = variable.getName();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    50
            value = variable.getValue();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    51
            if (varName.equals("path")) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    52
                path = value;
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    53
            }
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    54
            else if (varName.equals("master_conf")) {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    55
                masterConf = value;
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    56
            }
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    57
            else if (varName.equals("confml")) {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    58
                confml = value;
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    59
            }
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    60
            else if (varName.equals("impl")) {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    61
                impl = value;
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    62
            }
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    63
            else if (varName.equals("iby")) {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    64
                iby = value;
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    65
            }
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    66
            else if (varName.equals("keepgoing")) {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    67
                keepGoing = value;
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    68
            }
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    69
            else if (varName.equals("report")) {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    70
                report = value;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    71
            }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    72
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    73
        if (path == null || masterConf == null || confml == null || iby == null) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    74
            throw new ToolsProcessException("Config Tool Parameter missing");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    75
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    76
        org.apache.tools.ant.taskdefs.ExecTask task = new org.apache.tools.ant.taskdefs.ExecTask();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    77
        task.setTaskName("Configuration");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    78
        task.setDir(new java.io.File(path));
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    79
        task.setExecutable(path + java.io.File.separator + "cli_build.cmd");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    80
        if (keepGoing.equals("false")) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    81
            task.setFailonerror(true);
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    82
        }
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    83
        else {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    84
            task.createArg().setValue("-ignore_errors");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    85
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    86
        task.createArg().setValue("-master_conf");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    87
        task.createArg().setValue(masterConf);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    88
        task.createArg().setValue("-impl");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    89
        task.createArg().setValue(impl);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    90
        task.createArg().setValue("-confml");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    91
        task.createArg().setValue(confml);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    92
        task.createArg().setValue("-iby");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    93
        task.createArg().setValue(iby);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    94
        if (report != null) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    95
            task.createArg().setValue("-report");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    96
            task.createArg().setValue(report);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    97
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    98
        task.execute();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    99
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   100
}