buildframework/helium/sf/java/legacy/src/com/nokia/tools/cone/CONETool.java
changeset 628 7c4a911dc066
parent 587 85df38eb4012
equal deleted inserted replaced
588:c7c26511138f 628:7c4a911dc066
     1 /*
     1 /*
     2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3  * All rights reserved.
     4 * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     5  * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     8  *
     9 * Initial Contributors:
     9  * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10  * Nokia Corporation - initial contribution.
    11 *
    11  *
    12 * Contributors:
    12  * Contributors:
    13 *
    13  *
    14 * Description: 
    14  * Description: 
    15 *
    15  *
    16 */
    16  */
    17 
    17 
    18 package com.nokia.tools.cone;
    18 package com.nokia.tools.cone;
    19 
    19 
    20 import java.io.File;
    20 import java.io.File;
    21 import java.util.HashMap;
    21 import java.util.HashMap;
    25 
    25 
    26 import com.nokia.helium.core.ant.types.VariableSet;
    26 import com.nokia.helium.core.ant.types.VariableSet;
    27 import com.nokia.tools.Tool;
    27 import com.nokia.tools.Tool;
    28 import com.nokia.tools.ToolsProcessException;
    28 import com.nokia.tools.ToolsProcessException;
    29 
    29 
    30 
       
    31 /**
    30 /**
    32  * To generate the cenrep files using ConE tool.
    31  * To generate the cenrep files using ConE tool.
    33  * 
       
    34  *
       
    35  */
    32  */
    36 public class CONETool implements Tool {
    33 public class CONETool implements Tool {
    37     
    34 
    38     private Map<String, String> varMapping = new HashMap<String, String>();
    35     private Map<String, String> varMapping = new HashMap<String, String>();
    39 
    36 
    40     public void execute(VariableSet varSet, Project prj)
    37     public void execute(VariableSet varSet, Project prj) throws ToolsProcessException {
    41             throws ToolsProcessException {
    38     }
    42         // TODO Auto-generated method stub
       
    43 
    39 
    44     }
       
    45     
       
    46     
       
    47     /**
    40     /**
    48      * Run the cone command with arguments from hashmap.
    41      * Run the cone command with arguments from hashmap.
       
    42      * 
    49      * @param prj
    43      * @param prj
    50      * @throws ToolsProcessException
    44      * @throws ToolsProcessException
    51      */
    45      */
    52     public void execute(Project prj) throws ToolsProcessException {
    46     public void execute(Project prj) throws ToolsProcessException {
    53         
    47         String command = null;
       
    48         String osType = System.getProperty("os.name");
    54         org.apache.tools.ant.taskdefs.ExecTask task = new org.apache.tools.ant.taskdefs.ExecTask();
    49         org.apache.tools.ant.taskdefs.ExecTask task = new org.apache.tools.ant.taskdefs.ExecTask();
    55         task.setTaskName("ConE");
    50         task.setTaskName("ConE");
    56         task.setDir(new java.io.File(varMapping.get("path")));
    51         task.setDir(new java.io.File(varMapping.get("path")));
    57         task.setExecutable("cmd.exe");
    52         task.setExecutable("cmd.exe");
       
    53         command = "cmd.exe";
    58         task.setOutput(new File(varMapping.get("output")));
    54         task.setOutput(new File(varMapping.get("output")));
    59         task.createArg().setValue("/c");
    55         task.createArg().setValue("/c");
    60         task.setAppend(true);
    56         task.setAppend(true);
    61         task.createArg().setValue("cone.cmd");
    57         task.createArg().setValue("cone.cmd");
    62         task.createArg().setValue("generate");
    58         task.createArg().setValue(varMapping.get("command"));
    63         for (Map.Entry<String, String> varEntry : varMapping.entrySet() ) {
    59         command += " /c cone.cmd " + varMapping.get("command");
    64             if ( !varEntry.getKey().equals("path") && !varEntry.getKey().equals("output")) {
    60         for (Map.Entry<String, String> varEntry : varMapping.entrySet()) {
       
    61             if (!varEntry.getKey().equals("path") && !varEntry.getKey().equals("output")) {
    65                 task.createArg().setValue(varEntry.getKey());
    62                 task.createArg().setValue(varEntry.getKey());
       
    63                 command += " " + varEntry.getKey();
    66                 task.createArg().setValue(varEntry.getValue());
    64                 task.createArg().setValue(varEntry.getValue());
       
    65                 command += " " + varEntry.getValue();
    67             }
    66             }
    68         }
    67         }
       
    68         if (!osType.toLowerCase().startsWith("win")) {
       
    69             task.log("ConE tool runs only on windows platforms.");
       
    70             return;
       
    71         }
       
    72         task.log("Running ConE command \"" + command + "\"");
    69         task.execute();
    73         task.execute();
    70     }
    74     }
    71     
    75 
    72     /**
    76     /**
    73      * To Store the variable and it value into hashmap to read them later.
    77      * To Store the variable and it value into hashmap to read them later.
       
    78      * 
    74      * @param name
    79      * @param name
    75      * @param value
    80      * @param value
    76      */
    81      */
    77     public void storeVariables(String name, String value) {
    82     public void storeVariables(String name, String value) {
    78         varMapping.put(name, value);
    83         varMapping.put(name, value);