/**
  * Sets the command line variables to be used to execute and validates for the required parameters
  *
  * @param varSet variable(name / value list)
  */
 public void execute(VariableSet varSet, Project prj) throws ToolsProcessException {
   String path = null;
   String masterConf = null;
   String confml = null;
   String impl = null;
   String iby = null;
   String keepGoing = "false";
   String report = null;
   String varName;
   String value;
   for (Variable variable : varSet.getVariables()) {
     varName = variable.getName();
     value = variable.getValue();
     if (varName.equals("path")) {
       path = value;
     } else if (varName.equals("master_conf")) {
       masterConf = value;
     } else if (varName.equals("confml")) {
       confml = value;
     } else if (varName.equals("impl")) {
       impl = value;
     } else if (varName.equals("iby")) {
       iby = value;
     } else if (varName.equals("keepgoing")) {
       keepGoing = value;
     } else if (varName.equals("report")) {
       report = value;
     }
   }
   if (path == null || masterConf == null || confml == null || iby == null) {
     throw new ToolsProcessException("Config Tool Parameter missing");
   }
   org.apache.tools.ant.taskdefs.ExecTask task = new org.apache.tools.ant.taskdefs.ExecTask();
   task.setTaskName("Configuration");
   task.setDir(new java.io.File(path));
   task.setExecutable(path + java.io.File.separator + "cli_build.cmd");
   if (keepGoing.equals("false")) {
     task.setFailonerror(true);
   } else {
     task.createArg().setValue("-ignore_errors");
   }
   task.createArg().setValue("-master_conf");
   task.createArg().setValue(masterConf);
   task.createArg().setValue("-impl");
   task.createArg().setValue(impl);
   task.createArg().setValue("-confml");
   task.createArg().setValue(confml);
   task.createArg().setValue("-iby");
   task.createArg().setValue(iby);
   if (report != null) {
     task.createArg().setValue("-report");
     task.createArg().setValue(report);
   }
   task.execute();
 }
  /**
   * Constructs an ExecTask instance, linked to the current project, for running the client. This
   * implementation prepares the exec task so it will run the appclient script.
   *
   * @return ExecTask initialized for running the appclient script to execute the generated and
   *     retrieved app client
   */
  protected ExecTask prepareRunExecTask() {
    /*
     This is the ant excerpt imitated by the exec task built by this method:

     <exec executable="${APPCLIENT}" resultproperty="result" failonerror="false" output="${build}/${log.id}.output.log">
                <arg line="-client ${archivedir}/${testName}Client.jar"/>
            </exec>
    */
    ExecTask exec = new ExecTask();
    exec.setProject(project);
    String appclientValue = project.getProperty("APPCLIENT");
    exec.setExecutable(appclientValue);
    exec.setFailonerror(false);
    exec.setTaskName("runclient");
    return exec;
  }
Beispiel #3
0
  public void execute() {
    // Make sure we have all the required fields set.
    if (outFile == null) {
      throw new BuildException("The outFile attribute is required");
    }

    // First, populate all of the properties we care about for this task.
    if (getProject().getProperty("ant.build.native.toolchain") != null) {
      this.setToolchain(getProject().getProperty("ant.build.native.toolchain"));
    }

    if (getProject().getProperty("ant.build.native.host") != null) {
      this.setHost(getProject().getProperty("ant.build.native.host"));
    }

    // Setup the compiler.
    LinkerAdapter linker = ToolchainFactory.getLinker(toolchain);
    linker.setProject(getProject());
    linker.setOutFile(outFile);

    if (host != null && host.length() > 0) {
      // Prepend the host string to the executable.
      linker.setExecutable(host + '-' + linker.getExecutable());
    }

    for (AbstractFeature feat : features) {
      if (feat.isIfConditionValid() && feat.isUnlessConditionValid()) {
        linker.addArg(feat);
      }
    }

    long newest = 0;
    Iterator<File> inFile = linker.getInFiles();
    while (inFile.hasNext()) {
      long modified = inFile.next().lastModified();

      if (newest < modified) {
        newest = modified;
      }
    }

    if (newest >= outFile.lastModified()) {
      // Print the executed command.
      Echo echo = (Echo) getProject().createTask("echo");
      echo.setTaskName(this.getTaskName());
      echo.setAppend(true);

      // Create an exec task to run a shell.  Using the current shell to
      // execute commands is required for Windows support.
      ExecTask shell = (ExecTask) getProject().createTask("exec");
      shell.setTaskName(this.getTaskName());
      shell.setFailonerror(true);
      // shell.setDir(dir);

      echo.addText(linker.getExecutable());
      shell.setExecutable(linker.getExecutable());

      Iterator<String> args = linker.getArgs();
      while (args.hasNext()) {
        String arg = args.next();

        echo.addText(" " + arg);
        shell.createArg().setLine(arg);
      }

      echo.execute();
      shell.execute();
    }
  }