optionalAttrs.forEach((name, value) -> cmdl.createArgument() .setValue("-" + name + ":" + value)); throw new BuildException("Invalid target: %s", targetFile); cmdl.createArgument().setValue("-OUTPUT_DIRECTORY:" + outputDirectory.getAbsolutePath()); return; cmdl.createArgument().setValue(targetFile.getAbsolutePath()); final Path classpath = cmdl.createClasspath(getProject()); final File javaccJar = JavaCC.getArchiveFile(javaccHome); classpath.createPathElement().setPath(javaccJar.getAbsolutePath()); classpath.addJavaRuntime(); cmdl.setClassname(JavaCC.getMainClass(classpath, JavaCC.TASKDEF_TYPE_JAVACC)); cmdl.setMaxmemory(maxMemory); final Commandline.Argument arg = cmdl.createVmArgument(); arg.setValue("-Dinstall.root=" + javaccHome.getAbsolutePath()); Execute.runCommand(this, cmdl.getCommandline());
CommandlineJava cmdl = new CommandlineJava(); cmdl.setClassname(javaCommand.getExecutable()); for (String arg : javaCommand.getArguments()) { cmdl.createArgument().setValue(arg); cmdl.createClasspath(pc.getProject()).append(classpath); cmdl.addSysproperties(sysProperties); exe.setAntRun(pc.getProject()); if (Os.isFamily("openvms")) { setupCommandLineForVMS(exe, cmdl.getCommandline()); } else { exe.setCommandline(cmdl.getCommandline()); return rc; } catch (IOException e) { throw new BuildException(e); } finally { timedOut = exe.killedProcess();
String classname = getCommandLine().getClassname(); String module = getCommandLine().getModule(); final String sourceFile = getCommandLine().getSourceFile(); if (classname == null && getCommandLine().getJar() == null && module == null && sourceFile == null) { throw new BuildException("Classname must not be null."); if (!fork && getCommandLine().getJar() != null) { throw new BuildException( "Cannot execute a jar in non-forked mode. Please set fork='true'. "); if (!fork && getCommandLine().getModule() != null) { throw new BuildException( "Cannot execute a module in non-forked mode. Please set fork='true'. "); if (getCommandLine().getClasspath() != null && getCommandLine().getJar() != null) { if (getCommandLine().getAssertions() != null && !fork) { log(getCommandLine().describeCommand(), Project.MSG_VERBOSE); } else { if (getCommandLine().getVmCommand().size() > 1) { if (getCommandLine().getBootclasspath() != null) { log("running " + this.getCommandLine().getClassname() + " with default permissions (exit forbidden)", Project.MSG_VERBOSE); log("Running in same VM " + getCommandLine().describeJavaCommand(),
/** * Set the Java class to execute. * * @param s the name of the main class. * * @throws BuildException if there is also a {@code jar} or {@code sourcefile} attribute specified */ public void setClassname(String s) throws BuildException { if (getCommandLine().getJar() != null || getCommandLine().getSourceFile() != null) { throw new BuildException( "Cannot use combination of 'jar', 'classname', sourcefile attributes in same command"); } getCommandLine().setClassname(s); }
/** * Executes the given classname with the given arguments as if it * were a command line application. * * @param classname the name of the class to run. * @param args arguments for the class. * @throws BuildException in case of IOException in the execution. */ protected void run(String classname, Vector<String> args) throws BuildException { CommandlineJava cmdj = new CommandlineJava(); cmdj.setClassname(classname); args.forEach(arg -> cmdj.createArgument().setValue(arg)); run(cmdj); }
/** * Logs the compilation parameters, adds the files to compile and logs the * "niceSourceList" * @param jspc the compiler task for logging * @param compileList the list of files to compile * @param cmd the command line used */ protected void logAndAddFilesToCompile(JspC jspc, Vector<String> compileList, CommandlineJava cmd) { jspc.log("Compilation " + cmd.describeJavaCommand(), Project.MSG_VERBOSE); String niceSourceList = compileList.stream() .peek(arg -> cmd.createArgument().setValue(arg)) .map(arg -> String.format(" %s%n", arg)) .collect(Collectors.joining("")); jspc.log(String.format("File%s to be compiled:%n%s", compileList.size() == 1 ? "" : "s", niceSourceList), Project.MSG_VERBOSE); }
public void execute() throws BuildException CommandlineJava cmd = new CommandlineJava(); cmd.createArgument().setValue("-o"); cmd.createArgument().setValue(output.toString()); cmd.createArgument().setValue("-xml"); cmd.createArgument().setValue("-bytecode"); classpath.append(compilerClasspath); Java java = (Java) (getProject().createTask("java")); if (getClasspath() != null) java.setClasspath(getClasspath() .concatSystemClasspath("ignore")); java.setDir(getProject().getBaseDir()); java.setClassname("org.jboss.aop.annotation.compiler.AnnotationCompiler"); String args[] = cmd.getJavaCommand().getArguments(); for (int i = 0; i < args.length; i++) throw new BuildException("Error running aopc compiler: ", ex, getLocation());
command.setClassname(org.jboss.wsf.spi.tools.cmd.WSProvide.class.getName()); Path path = command.createClasspath(getProject()); path.append(getTaskClassPath()); path.append(classpath); command.createArgument().setValue("-k"); command.createArgument().setValue("-w"); command.createArgument().setValue("-o"); command.createArgument().setFile(destdir); command.createArgument().setValue("-r"); command.createArgument().setFile(resourcedestdir); command.createArgument().setValue("-s"); command.createArgument().setFile(sourcedestdir); command.createArgument().setValue("-q"); command.createArgument().setValue("-t"); command.createArgument().setValue(sei); log("Command invoked: " + command.getJavaCommand().toString()); execute.setJavaCommand(command.getJavaCommand()); if (execute.fork(this) != 0) throw new BuildException("Could not invoke WSProvideTask", getLocation());
log(ToolVersion.VERSION.BUILD_VERSION); log("command line: " + tool + (getFork() ? getCommandline().getJavaCommand() : getCommandline()).toString()); int status = run(getCommandline().getCommandline()); ok = (status == 0); } else { if (getCommandline().getVmCommand().size() > 1) { log("JVM args ignored when same JVM is used.", Project.MSG_WARN); Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader()); try { ok = runInVm(getCommandline().getJavaCommand().getArguments(), logstr); } finally { Thread.currentThread().setContextClassLoader(old); log("Command invoked: " + tool + getCommandline().toString()); throw new BuildException(tool + " failed", getLocation()); throw (BuildException) ex; } else { throw new BuildException("Error starting " + tool + ": " + ex.getMessage(), ex, getLocation()); throw new BuildException(e);
Execute execute= new Execute(new TestNGLogSH(this, Project.MSG_INFO, Project.MSG_WARN, (m_verbose == null || m_verbose < 5)), watchdog); execute.setCommandline(cmd.getCommandline()); execute.setAntRun(getProject()); if(m_workingDir != null) { log(cmd.describeCommand(), Project.MSG_VERBOSE); int retVal; try { throw new BuildException("Process fork failed.", e, getLocation());
Java java = new Java(owner); Path p = getClasspath(); if (getJspc().getClasspath() != null) { Project.MSG_DEBUG); java.setClasspath(p); java.setDir(getProject().getBaseDir()); java.setClassname("org.apache.jasper.JspC"); for (String arg : cmd.getJavaCommand().getArguments()) { java.createArg().setValue(arg); java.setFailonerror(getJspc().getFailonerror()); throw (BuildException) ex; throw new BuildException("Error running jsp compiler: ", ex, getJspc().getLocation()); } finally {
public void execute() throws BuildException { buildCommandLine(); LogStreamHandler log = new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN); Execute exe = new Execute(log); exe.setAntRun(getProject()); exe.setCommandline(cmd.getCommandline()); try { int rc = exe.execute(); if (exe.killedProcess() || rc != 0) { throw new BuildException("wsdl2java failed", getLocation()); } } catch (IOException e) { throw new BuildException(e, getLocation()); } }
if (bar == null) { String message = ExceptionManager.getInstance().getFullMessage("bat_BJ_1"); throw new BuildException(message); java.createArgument().setValue("-bar=" + bar.getAbsolutePath()); java.addSysproperty(testVar); var.setKey(BonitaConstants.ENVIRONMENT_PROPERTY); var.setValue(env.getAbsolutePath()); java.addSysproperty(var); var.setKey(BonitaConstants.JAAS_PROPERTY); var.setValue(jaas.getAbsolutePath()); java.addSysproperty(var); var.setKey(BonitaConstants.LOGGING_PROPERTY); var.setValue(log.getAbsolutePath()); java.addSysproperty(var); var.setKey(BonitaConstants.API_TYPE_PROPERTY); var.setValue(Misc.stringToEnum(Context.class, apitype).toString()); java.addSysproperty(var); super.execute(); } catch (Throwable t) { t.printStackTrace();
@Override protected void compile() { try { if (getFork()) { setupCommand(); setupForkCommand("com.sun.tools.jxc.SchemaGeneratorFacade"); int status = run(getCommandline().getCommandline()); if (status != 0) { if (!getVerbose()) { log("Command invoked: " + "schemagen" + getCommandline().toString()); } throw new BuildException("schemagen" + " failed", getLocation()); } } else { super.compile(); } } catch (Exception ex) { if (ex instanceof BuildException) { throw (BuildException) ex; } else { throw new BuildException("Error starting " + "schemagen" + ": " + ex.getMessage(), ex, getLocation()); } } }
@Override public void execute() { if (initialcontextfactory == null) { String message = ExceptionManager.getInstance().getFullMessage("bat_BJEE_1"); throw new BuildException(message); } if (providerurl == null) { String message = ExceptionManager.getInstance().getFullMessage("bat_BJEE_2"); throw new BuildException(message); } CommandlineJava java = getCommandLine(); if (initialcontextfactory != null) { Environment.Variable var = new Environment.Variable(); var.setKey(BonitaConstants.INITIAL_CONTEXT_FACTORY_PROPERTY); var.setValue(initialcontextfactory); java.addSysproperty(var); } if (providerurl != null) { Environment.Variable var = new Environment.Variable(); var.setKey(BonitaConstants.PROVIDER_URL_PROPERTY); var.setValue(providerurl); java.addSysproperty(var); } super.execute(); }
if (fork) { if (spawn) { spawn(commandLine.getCommandline()); return 0; return fork(commandLine.getCommandline()); run(commandLine); return 0; } catch (ExitException ex) { if (e.getLocation() == null && getLocation() != null) { e.setLocation(getLocation()); if (TIMEOUT_MESSAGE.equals(e.getMessage())) { log(TIMEOUT_MESSAGE); } else {
/** * Executes the given classname with the given arguments as it * were a command line application. * @param command CommandlineJava. */ private void run(CommandlineJava command) throws BuildException { try { ExecuteJava exe = new ExecuteJava(); exe.setJavaCommand(command.getJavaCommand()); exe.setClasspath(command.getClasspath()); exe.setSystemProperties(command.getSystemProperties()); exe.setPermissions(perm); exe.setTimeout(timeout); redirector.createStreams(); exe.execute(getProject()); redirector.complete(); if (exe.killedProcess()) { throw new BuildException(TIMEOUT_MESSAGE); } } catch (IOException e) { throw new BuildException(e); } }
classpath.setProject(getProject()); setupCommand(); setupForkCommand("com.sun.tools.xjc.XJCFacade"); int status = run(getCommandline().getCommandline()); if (status != 0) { log("Command invoked: " + "xjc" + getCommandline().toString()); throw new BuildException("xjc" + " failed", getLocation()); if (getCommandline().getVmCommand().size() > 1) { log("JVM args ignored when same JVM is used.", Project.MSG_WARN); if (e[0] instanceof RuntimeException) throw (RuntimeException) e[0]; if (e[0] instanceof BuildException) throw (BuildException) e[0]; if (e[0] != null) throw new BuildException(e[0]); } catch (InterruptedException e) { throw new BuildException(e);
cmd = (CommandlineJava) getCommandline().clone(); } catch (final CloneNotSupportedException e) { throw new BuildException("This shouldn't happen", e, getLocation()); cmd.createArgument().setValue(test.getName()); if (test.getMethods() != null) { cmd.createArgument().setValue(Constants.METHOD_NAMES + test.getMethodsString()); cmd.createArgument().setValue(Constants.TESTSFILE + casesFile); cmd.createArgument().setValue(Constants.SKIP_NON_TESTS + String.valueOf(test.isSkipNonTests())); cmd.createArgument().setValue(Constants.FILTERTRACE + test.getFiltertrace()); cmd.createArgument().setValue(Constants.HALT_ON_ERROR + test.getHaltonerror()); cmd.createArgument().setValue(Constants.HALT_ON_FAILURE + test.getHaltonfailure()); checkIncludeAntRuntime(cmd); cmd.createArgument().setValue(Constants.SHOWOUTPUT + String.valueOf(showOutput)); cmd.createArgument().setValue(Constants.OUTPUT_TO_FORMATTERS + String.valueOf(outputToFormatters)); cmd.createArgument().setValue(Constants.LOG_FAILED_TESTS + String.valueOf(logFailedTests)); cmd.createArgument().setValue(Constants.THREADID + String.valueOf(test.getThread())); cmd.createArgument().setValue(Constants.LOGTESTLISTENEREVENTS + String.valueOf(getEnableTestListenerEvents()));
private Commandline setupAptForkCommand() { CommandlineJava forkCmd = new CommandlineJava(); Path classpath = getClasspath(); forkCmd.createClasspath(getProject()).append(classpath); forkCmd.setClassname("com.sun.tools.javac.Main"); if (getJvmargs() != null) { for (Jvmarg jvmarg : jvmargs) { forkCmd.createVmArgument().setLine(jvmarg.getValue()); } } Commandline cmd = setupAptArgs(); cmd.createArgument(true).setLine(forkCmd.toString()); return cmd; }