/** * Executes the task. * * <p>Builds a command line to execute cleartool and then calls Exec's run method to execute the * command line. * * @throws BuildException if the command fails and failonerr is set to true */ public void execute() throws BuildException { Commandline commandLine = new Commandline(); Project aProj = getProject(); int result = 0; // Default the viewpath to basedir if it is not specified if (getViewPath() == null) { setViewPath(aProj.getBaseDir().getPath()); } // build the command line from what we got the format is // cleartool uncheckout [options...] [viewpath ...] // as specified in the CLEARTOOL.EXE help commandLine.setExecutable(getClearToolCommand()); commandLine.createArgument().setValue(COMMAND_UNCHECKOUT); checkOptions(commandLine); if (!getFailOnErr()) { getProject() .log("Ignoring any errors that occur for: " + getViewPathBasename(), Project.MSG_VERBOSE); } result = run(commandLine); if (Execute.isFailure(result) && getFailOnErr()) { String msg = "Failed executing: " + commandLine.toString(); throw new BuildException(msg, getLocation()); } }
/** * Performs a compile using the gcj compiler. * * @return true if the compilation succeeded * @throws BuildException on error */ public boolean execute() throws BuildException { Commandline cmd; attributes.log("Using gcj compiler", Project.MSG_VERBOSE); cmd = setupGCJCommand(); int firstFileName = cmd.size(); logAndAddFilesToCompile(cmd); return executeExternalCompile(cmd.getCommandline(), firstFileName) == 0; }
/** Check the command line options. */ private void checkOptions(Commandline cmd) { // ClearCase items if (getKeepCopy()) { // -keep cmd.createArgument().setValue(FLAG_KEEPCOPY); } else { // -rm cmd.createArgument().setValue(FLAG_RM); } // viewpath cmd.createArgument().setValue(getViewPath()); }
/** * Set up the gcj commandline. * * @return the command line */ protected Commandline setupGCJCommand() { Commandline cmd = new Commandline(); Path classpath = new Path(project); // gcj doesn't support bootclasspath dir (-bootclasspath) // so we'll emulate it for compatibility and convenience. Path p = getBootClassPath(); if (p.size() > 0) { classpath.append(p); } // gcj doesn't support an extension dir (-extdir) // so we'll emulate it for compatibility and convenience. if (extdirs != null || includeJavaRuntime) { classpath.addExtdirs(extdirs); } classpath.append(getCompileClasspath()); // Gcj has no option for source-path so we // will add it to classpath. if (compileSourcepath != null) { classpath.append(compileSourcepath); } else { classpath.append(src); } String exec = getJavac().getExecutable(); cmd.setExecutable(exec == null ? "gcj" : exec); if (destDir != null) { cmd.createArgument().setValue("-d"); cmd.createArgument().setFile(destDir); if (!destDir.exists() && !destDir.mkdirs()) { throw new BuildException("Can't make output directories. " + "Maybe permission is wrong. "); } } cmd.createArgument().setValue("-classpath"); cmd.createArgument().setPath(classpath); if (encoding != null) { cmd.createArgument().setValue("--encoding=" + encoding); } if (debug) { cmd.createArgument().setValue("-g1"); } if (optimize) { cmd.createArgument().setValue("-O"); } /** gcj should be set for generate class. ... if no 'compile to native' argument is passed */ if (!isNativeBuild()) { cmd.createArgument().setValue("-C"); } if (attributes.getSource() != null) { String source = attributes.getSource(); cmd.createArgument().setValue("-fsource=" + source); } if (attributes.getTarget() != null) { String target = attributes.getTarget(); cmd.createArgument().setValue("-ftarget=" + target); } addCurrentCompilerArgs(cmd); return cmd; }