本文整理了Java中org.apache.tools.ant.taskdefs.Java
类的一些代码示例,展示了Java
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Java
类的具体详情如下:
包路径:org.apache.tools.ant.taskdefs.Java
类名称:Java
[英]Launcher for Java applications. Allows use of the same JVM for the called application thus resulting in much faster operation.
[中]Java应用程序的启动器。允许对被调用的应用程序使用相同的JVM,从而导致更快的操作。
代码示例来源:origin: org.apache.ant/ant
Java genicTask = new Java(getTask()); // GenIC task
genicTask.setTaskName("genic");
genicTask.setFork(true);
genicTask.createJvmarg().setValue("-Dinstall.root=" + jonasroot);
File javaPolicyFile = new File(jonasConfigDir, "java.policy");
if (javaPolicyFile.exists()) {
genicTask.createJvmarg().setValue("-Djava.security.policy="
+ javaPolicyFile.toString());
genicTask.createArg().setValue("-d");
genicTask.createArg().setFile(outputdir);
genicTask.setClasspath(classpath);
genicTask.setClassname(genicClass);
genicTask.createArg().setValue("-keepgenerated");
genicTask.createArg().setValue("-nocompil");
genicTask.createArg().setValue("-novalidation");
genicTask.createArg().setValue("-javac");
genicTask.createArg().setLine(javac);
genicTask.createArg().setValue("-javacopts");
genicTask.createArg().setLine(javacopts);
代码示例来源:origin: org.apache.ant/ant
Java java = new Java(owner);
Path p = getClasspath();
if (getJspc().getClasspath() != null) {
getProject().log("using user supplied classpath: " + p,
Project.MSG_DEBUG);
} else {
getProject().log("using system classpath: " + p,
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());
java.setFork(true);
java.setTaskName("jasperc");
java.execute();
return true;
} catch (Exception ex) {
throw (BuildException) ex;
代码示例来源:origin: org.apache.ant/ant
try {
if (ejbdeploy) {
Java javaTask = new Java(getTask());
javaTask.createJvmarg().setValue("-Xms64m");
javaTask.createJvmarg().setValue("-Xmx128m");
File libdir = new File(websphereHome, "lib");
var.setValue(libdir.getAbsolutePath());
javaTask.addSysproperty(var);
javaTask.setDir(websphereHome);
javaTask.setTaskName("ejbdeploy");
javaTask.setClassname("com.ibm.etools.ejbdeploy.EJBDeploy");
javaTask.createArg().setValue(sourceJar.getPath());
javaTask.createArg().setValue(tempdir);
javaTask.createArg().setValue(destJar.getPath());
javaTask.createArg().setLine(getOptions());
if (getCombinedClasspath() != null
&& !getCombinedClasspath().toString().isEmpty()) {
javaTask.createArg().setValue("-cp");
javaTask.createArg().setValue(getCombinedClasspath().toString());
javaTask.setFork(true);
if (classpath != null) {
javaTask.setClasspath(classpath);
代码示例来源:origin: org.apache.ant/ant
/**
* Do the execution and return a return code.
*
* @return the return code from the execute java class if it was
* executed in a separate VM (fork = "yes") or a security manager was
* installed that prohibits ExitVM (default).
*
* @throws BuildException if required parameters are missing.
*/
public int executeJava() throws BuildException {
return executeJava(getCommandLine());
}
代码示例来源:origin: org.apache.ant/ant
/**
* Perform the actual deployment.
* For this generic implementation, a JVM is spawned using the
* supplied classpath, classname, JVM args, and command line arguments.
* @exception BuildException if the attributes are invalid or incomplete.
*/
@Override
public void deploy() throws BuildException {
java.setClassname(className);
java.setClasspath(getClasspath());
java.setFork(true);
java.setFailonerror(true);
java.execute();
}
代码示例来源:origin: org.apache.ant/ant
/**
* Do the execution.
* @throws BuildException if failOnError is set to true and the application
* returns a nonzero result code.
*/
@Override
public void execute() throws BuildException {
File savedDir = dir;
Permissions savedPermissions = perm;
int err = -1;
try {
checkConfiguration();
err = executeJava();
if (err != 0) {
if (failOnError) {
throw new ExitStatusException("Java returned: " + err,
err,
getLocation());
} else {
log("Java Result: " + err, Project.MSG_ERR);
}
}
maybeSetResultPropertyValue(err);
} finally {
dir = savedDir;
perm = savedPermissions;
}
}
代码示例来源:origin: jboss/jbossretro
public void execute() throws BuildException
cmd.createArgument().setValue("-destdir");
getProject().log("using user supplied classpath: " + getClasspath(), Project.MSG_DEBUG);
java.setClasspath(getClasspath().concatSystemClasspath("ignore"));
Path classpath = new Path(getProject());
java.setClasspath(classpath);
java.setDir(getProject().getBaseDir());
java.setClassname("org.jboss.ant.tasks.retrocheck.Checker");
java.createArg().setValue(args[i]);
java.setFailonerror(getFailonerror());
java.setFork(true);
java.setTaskName("retrocheck");
if (maxmemory != null)
java.setMaxmemory(maxmemory);
java.execute();
throw new BuildException("Error running weaver: ", ex, getLocation());
代码示例来源:origin: net.sourceforge.cobertura/cobertura
public void execute() throws BuildException {
CommandLineBuilder builder = null;
try {
builder = new CommandLineBuilder();
if (dataFile != null)
builder.addArg("--datafile", dataFile);
createArgumentsForFilesets(builder);
builder.saveArgs();
} catch (IOException ioe) {
getProject().log("Error creating commands file.", Project.MSG_ERR);
throw new BuildException("Unable to create the commands file.", ioe);
}
// Execute GPL licensed code in separate virtual machine
getJava().createArg().setValue("--commandsfile");
getJava().createArg().setValue(builder.getCommandLineFile());
AntUtil.transferCoberturaDataFileProperty(getJava());
if (getJava().executeJava() != 0) {
throw new BuildException(
"Error running reports. See messages above.");
}
builder.dispose();
}
代码示例来源:origin: org.apache.ant/ant
throw new BuildException("src directory %s is not valid",
sourceDirectory.getPath());
throw new BuildException("package attribute must be present.",
getLocation());
compileClasspath = new Path(getProject());
compileClasspath = compileClasspath.concatSystemClasspath();
Java helperTask = new Java(this);
helperTask.setFork(true);
helperTask.setClassname("weblogic.jspc");
helperTask.setTaskName(getTaskName());
args[j++] = compileClasspath.toString();
helperTask.clearArgs();
helperTask.createArg().setValue(args[x]);
helperTask.setClasspath(compileClasspath);
if (helperTask.executeJava() != 0) {
log(filename + " failed to compile", Project.MSG_WARN);
代码示例来源:origin: spotbugs/spotbugs
findbugsEngine.setTaskName(getTaskName());
findbugsEngine.setFork(true);
findbugsEngine.setTimeout(timeout);
jvmargs = jvmargs + " -Dfindbugs.debug=true";
findbugsEngine.createJvmarg().setLine(jvmargs);
findbugsEngine.setClasspath(new Path(getProject(), findbugsLibFindBugs.getPath()));
} else if (findBugsFindBugs.exists()) {
findbugsEngine.setClasspath(new Path(getProject(), findBugsFindBugs.getPath()));
} else {
throw new IllegalArgumentException("Can't find spotbugs.jar in " + homeDir);
findbugsEngine.setClassname("edu.umd.cs.findbugs.LaunchAppropriateUI");
findbugsEngine.createJvmarg().setValue("-Dspotbugs.home=" + homeDir.getPath());
} else {
findbugsEngine.setClasspath(classpath);
findbugsEngine.setClassname("edu.umd.cs.findbugs.LaunchAppropriateUI");
addArg(pluginList.toString());
int rc = findbugsEngine.executeJava();
throw new BuildException("Execution of findbugs failed.");
代码示例来源:origin: org.codehaus.openxma/dsl-generator
public void execute() throws BuildException {
log("Adding param: " + getFile());
super.createArg().setValue(getFile());
for (Parameter param : params) {
if (param != null) {
final String paramString = "-p" + param.getName() + "=" + param.getValue();
super.createArg().setValue(paramString);
log("Adding param: " + paramString);
super.createArg().setValue("--ant");
super.setFailonerror(true);
super.setClassname(WorkflowRunner.class.getName());
try {
super.execute();
if (ex.getCause() != null) {
ex.getCause().printStackTrace();
String message = "workflow failed: " + String.valueOf(ex.getMessage());
代码示例来源:origin: org.apache.ant/ant
Java javaTask = new Java(getTask());
javaTask.setTaskName("ejbc");
javaTask.createJvmarg().setLine(additionalJvmArgs);
sysprops.forEach(javaTask::addSysproperty);
javaTask.createJvmarg().setLine(" -Dweblogic.StdoutSeverityLevel=" + jvmDebugLevel);
javaTask.setClassname(ejbcClassName);
javaTask.createArg().setLine(additionalArgs);
if (keepgenerated) {
javaTask.createArg().setValue("-keepgenerated");
javaTask.createArg().setValue("-compiler");
javaTask.createArg().setValue("jikes");
javaTask.createArg().setValue("-compiler");
javaTask.createArg().setLine(compiler);
&& !combinedClasspath.toString().trim().isEmpty()) {
javaTask.createArg().setValue("-classpath");
javaTask.createArg().setPath(combinedClasspath);
javaTask.createArg().setValue(sourceJar.getPath());
if (outputDir == null) {
javaTask.createArg().setValue(destJar.getPath());
} else {
javaTask.createArg().setValue(outputDir.getPath());
代码示例来源:origin: axis/axis-ant
private void executeForkedAntTask() {
/* if (callee2 == null) { */
callee2 = (Java) getProject().createTask("java");
callee2.setOwningTarget(getOwningTarget());
callee2.setTaskName(getTaskName());
callee2.setLocation(getLocation());
callee2.setClassname("org.apache.tools.ant.Main");
callee2.setAppend(true);
callee2.setFork(true);
callee2.createJvmarg().setValue("-Xbootclasspath/p:" + System.getProperty("sun.boot.class.path"));
/* } */
String systemClassPath = System.getProperty("java.class.path");
callee2.setClasspath(new Path(getProject(), systemClassPath));
String args = "-buildfile " + properties.get("file");
Commandline.Argument arguments = callee2.createArg();
arguments.setLine(args);
if (verbose) {
callee2.createArg().setValue("-verbose");
}
callee2.createArg().setValue(subTarget);
if (callee2.executeJava() != 0) {
throw new BuildException("Execution of ANT Task failed");
}
}
代码示例来源:origin: com.atlassian.maven.plugins/maven-amps-plugin
this.java.setFailonerror(true);
this.java.execute();
if (ex.getMessage().contains("Java returned: 1"))
ex = new BuildException(ex.getMessage()
+ " See log for details.", ex.getCause(), ex.getLocation());
代码示例来源:origin: org.apache.ant/ant
Java execTask = new Java(this);
execTask.setDir(new File("."));
execTask.setClassname("com.inprise.server.commandline.EJBUtilities");
execTask.setClasspath(classpath.concatSystemClasspath());
execTask.setFork(true);
execTask.createArg().setValue("generateclient");
if (debug) {
execTask.createArg().setValue("-trace");
execTask.createArg().setValue("-short");
execTask.createArg().setValue("-jarfile");
execTask.createArg().setValue(ejbjarfile.getAbsolutePath());
execTask.createArg().setValue("-single");
execTask.createArg().setValue("-clientjarfile");
execTask.createArg().setValue(clientjarfile.getAbsolutePath());
execTask.execute();
throw new BuildException("Exception while calling generateclient", e);
代码示例来源:origin: axis/axis-ant
private void executeInForkedVM(String[] args) {
try {
// Create an instance of the compiler, redirecting output to
// the project log
Java java = (Java) (getProject().createTask("java"));
getProject().log("using classpath: " + classpath,
Project.MSG_DEBUG);
java.setClasspath(classpath);
java.setClassname("org.apache.axis.client.AdminClient");
for (int i = 0; i < args.length; i++) {
java.createArg().setValue(args[i]);
}
java.setFailonerror(failOnError);
//we are forking here to be sure that if AdminClient calls
//System.exit() it doesn't halt the build
java.setFork(true);
java.setTaskName("AdminClient");
java.execute();
} catch (BuildException e) {
//rethrow these
throw e;
} catch (Exception e) {
throw new BuildException("Exception in " + getTaskName(), e);
}
}
代码示例来源:origin: org.apache.ant/ant
/**
* Verify the produced jar file by invoking the Borland verify tool
* @param sourceJar java.io.File representing the produced jar file
*/
private void verifyBorlandJarV4(File sourceJar) {
Java javaTask = null;
log("verify BAS " + sourceJar, Project.MSG_INFO);
try {
String args = verifyArgs;
args += " " + sourceJar.getPath();
javaTask = new Java(getTask());
javaTask.setTaskName("verify");
javaTask.setClassname(VERIFY);
Commandline.Argument arguments = javaTask.createArg();
arguments.setLine(args);
Path classpath = getCombinedClasspath();
if (classpath != null) {
javaTask.setClasspath(classpath);
javaTask.setFork(true);
}
log("Calling " + VERIFY + " for " + sourceJar.toString(),
Project.MSG_VERBOSE);
javaTask.execute();
} catch (Exception e) {
//TO DO : delete the file if it is not a valid file.
String msg = "Exception while calling " + VERIFY + " Details: "
+ e.toString();
throw new BuildException(msg, e);
}
}
代码示例来源:origin: net.sf.antenna/antenna
writer.close();
Java java = new Java();
java.setProject(project);
java.setTaskName(parent.getTaskName());
String home = project.getProperty("wtk.proguard.home");
java.createClasspath().setPath(
home != null ? new File(home + "/lib", "proguard.jar").getAbsolutePath() : getWtkRelative("bin/proguard.jar"));
java.createClasspath().setPath(System.getProperty("java.class.path"));
java.setClassname("proguard.ProGuard");
java.setFailonerror(true);
java.createArg().setLine("\"@'" + script + "'\"");
if (verbose) {
java.createArg().setLine(" -verbose");
java.createArg().setLine(" " + arguments.elementAt(i));
java.setFork(true);
int result = java.executeJava();
if (result != 0) {
throw new BuildException("Obfuscation failed (result=" + result + ")");
代码示例来源:origin: net.sf.antenna/antenna
throw new BuildException("Error loading JAD file", ex);
Java java = new Java();
java.setProject(getProject());
java.setTaskName(this.getTaskName());
java.createClasspath().setPath(converter);
java.setClassname("com.sun.midp.palm.database.MakeMIDPApp");
java.setFork(true);
java.setFailonerror(true);
java.createArg().setLine(" -o \"" + prc + "\"");
if (creator != null) java.createArg().setLine(" -creator \"" + creator + "\"");
if (icon != null) java.createArg().setLine(" -icon \"" + icon + "\"");
if (smallicon != null) java.createArg().setLine(" -smallicon \"" + smallicon + "\"");
if (name != null) java.createArg().setLine(" -name \"" + name + "\"");
if (longname != null) java.createArg().setLine(" -longname \"" + longname + "\"");
if (type != null) java.createArg().setLine(" -type " + type);
if (jadFile != null) java.createArg().setLine(" -jad \"" + jadFile + "\"");
java.createArg().setFile(jarFile);
java.createArg().setFile(new File(jadFile.getParent(), new File(jad.getValue("MIDlet-Jar-URL")).getName()));
java.execute();
if (!new File(prc).exists()) {
log("There was a problem generating the PRC file. Maybe you are using");
代码示例来源:origin: org.ow2.bonita/bonita-client
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);
super.execute();
} catch (Throwable t) {
t.printStackTrace();
内容来源于网络,如有侵权,请联系作者删除!