buildframework/helium/tools/common/java/src/com/nokia/ant/taskdefs/DeconfigureTask.java
author wbernard
Wed, 23 Dec 2009 19:29:07 +0200
changeset 179 d8ac696cc51f
parent 1 be27ed110b50
permissions -rw-r--r--
helium_7.0-r14027
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
     1
/*
179
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
     2
 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
     3
 * All rights reserved.
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
     4
 * This component and the accompanying materials are made available
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
     5
 * under the terms of the License "Eclipse Public License v1.0"
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
     6
 * which accompanies this distribution, and is available
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
     8
 *
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
     9
 * Initial Contributors:
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    10
 * Nokia Corporation - initial contribution.
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    11
 *
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    12
 * Contributors:
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    13
 *
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    14
 * Description: 
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    15
 *
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    16
 */
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    17
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    18
package com.nokia.ant.taskdefs;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    19
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    20
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    21
/**
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    22
 * ANT wrapper task for the GSCM deconfigure.pl script.
179
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    23
 * 
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    24
 * @ant.task category="SCM"
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    25
 */
179
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    26
public class DeconfigureTask extends AbstractScmBaseTask {
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    27
  // The attributes of this task
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    28
  private Boolean considerBranchReleases;
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    29
179
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    30
  /**
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    31
   * Return the considerBranchReleases.
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    32
   * 
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    33
   * @return the considerBranchReleases.
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    34
   */
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    35
  public Boolean getConsiderBranchReleases() {
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    36
    return considerBranchReleases;
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    37
  }
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    38
179
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    39
  /**
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    40
   * Set if we want deconfigure.pl script to check for branch differences
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    41
   * based on the 'included_releases' attribute of project.
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    42
   * 
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    43
   * @param considerBranchReleases
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    44
   * @ant.not-required Default is no.
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    45
   */
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    46
  public void setconsiderBranchReleases(Boolean considerBranchReleases) {
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    47
    this.considerBranchReleases = considerBranchReleases;
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    48
    log("Set considerBranchReleases to " + considerBranchReleases);
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    49
  }
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    50
179
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    51
  /**
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    52
   * Build a command list consisting of all the required and optional command
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    53
   * arguments of the current task.
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    54
   */
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    55
  protected void buildCommandList() {
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    56
    addCommandArg("database", "-d", true, getDatabase());
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    57
    addCommandArg("password", "-P", true, getPassword());
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    58
    addCommandArg("ccmProject", "-p", true, getCcmProject());
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    59
    addCommandArg("considerBranchReleases", "-b", getConsiderBranchReleases());
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    60
  }
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    61
179
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    62
  /**
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    63
   * Method validates the given arguments.
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    64
   */
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    65
  protected void validateArguments() {
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    66
    // Do nothing
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    67
  }
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    68
179
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    69
  /**
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    70
   * Set the execution script.
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    71
   * 
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    72
   */
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    73
  protected void setExecutionScript() {
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    74
    append2CommandString("deconfigure.pl");
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    75
  }
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    76
179
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    77
  /**
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    78
   * Method returns the correct verbosity level for the input choice.
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    79
   * 
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    80
   * @param choice
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    81
   *            is the verbosity choice set by user.
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    82
   * @return the verbosity level to set.
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    83
   */
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    84
  protected String getVerbosity(int choice) {
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    85
    String cmd = "";
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    86
    switch (choice) {
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    87
    case 0:
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    88
      cmd = "-q ";
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    89
      break;
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    90
    case 1:
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    91
      cmd = "-V ";
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    92
      break;
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    93
    case 2:
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    94
      cmd = "-W ";
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    95
      break;
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    96
    default:
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    97
      raiseError("Verbosity level is not recognised. "
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
    98
          + "Legal values are: 0 - quiet, 1 - verbose or 2 - very verbose");
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    99
    }
179
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
   100
    return cmd;
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
   101
  }
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
   102
  
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   103
}