Ejemplo n.º 1
0
 /**
  * Overrides the Java execution for settings the arguments correctly.
  *
  * @param device the current device
  * @param variables the variables for the current device
  */
 public void execute(Device device, Map variables) {
   if (this.message != null) {
     String msg = PropertyUtil.writeProperties(this.message, variables);
     System.out.println(msg);
   }
   // remove all arguments:
   super.clearArgs();
   Argument[] arguments =
       (Argument[]) this.argumentsList.toArray(new Argument[this.argumentsList.size()]);
   for (int i = 0; i < arguments.length; i++) {
     Argument argument = arguments[i];
     String[] parts = argument.getParts();
     StringBuffer buffer = new StringBuffer();
     for (int j = 0; j < parts.length; j++) {
       String part = parts[j];
       /* does not work anyhow
       if (part.indexOf(' ') != -1) {
       	part = '"' + part + '"';
       }
       */
       buffer.append(part);
       if (j != parts.length - 1) {
         buffer.append(" ");
       }
     }
     String line = PropertyUtil.writeProperties(buffer.toString(), variables);
     Argument newArgument = super.createArg();
     newArgument.setLine(line);
   }
   execute();
 }
Ejemplo n.º 2
0
  void checkBuild(String module, String classname, String[] args, boolean addAnt) {
    if (!shouldBuild(module)) {
      return;
    }
    assertTrue(null != module);
    checkJavac();
    doTask(module, true, false);
    doTask(module, true, true);
    doTask(module, false, false);
    File jar = doTask(module, false, true, true);

    // verify if possible
    if (null != classname) {
      Java java = new Java();
      Project project = new Project();
      java.setProject(project);
      java.setFailonerror(true);
      Path cp = new Path(project);
      assertTrue(jar.canRead());
      cp.append(new Path(project, jar.getAbsolutePath()));
      if (addAnt) {
        cp.append(new Path(project, getAntJar().getAbsolutePath()));
        cp.append(new Path(project, getJUnitJar().getAbsolutePath()));
      }
      java.setClasspath(cp);
      java.setClassname(classname);
      if (null != args) {
        for (int i = 0; i < args.length; i++) {
          Argument arg = java.createArg();
          arg.setValue(args[i]);
        }
      }
      try {
        java.execute();
      } catch (BuildException e) {
        e.printStackTrace(System.err);
        assertTrue("BuildException running " + classname, false);
      }
    }
    deleteJar(jar);
  }