Browse Source

Added the support to the -jar option in the command line per suggestion of <aspyker@nc.rr.com>

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269445 13f79535-47bb-0310-9956-ffa450edef68
master
Stephane Bailliez 24 years ago
parent
commit
458b181fc1
1 changed files with 18 additions and 3 deletions
  1. +18
    -3
      src/main/org/apache/tools/ant/taskdefs/Java.java

+ 18
- 3
src/main/org/apache/tools/ant/taskdefs/Java.java View File

@@ -102,10 +102,12 @@ public class Java extends Task {
*/ */
public int executeJava() throws BuildException { public int executeJava() throws BuildException {
String classname = cmdl.getClassname(); String classname = cmdl.getClassname();

if (classname == null) {
if (classname == null && cmdl.getJar() == null) {
throw new BuildException("Classname must not be null."); throw new BuildException("Classname must not be null.");
} }
if (!fork && cmdl.getJar() != null){
throw new BuildException("Cannot execute a jar in non-forked mode. Please set fork='true'. ");
}


if (fork) { if (fork) {
log("Forking " + cmdl.toString(), Project.MSG_VERBOSE); log("Forking " + cmdl.toString(), Project.MSG_VERBOSE);
@@ -152,10 +154,23 @@ public class Java extends Task {
createClasspath().setRefid(r); createClasspath().setRefid(r);
} }


/**
* set the jar name...
*/
public void setJar(File jarfile) throws BuildException {
if ( cmdl.getClassname() != null ){
throw new BuildException("Cannot use 'jar' and 'classname' attributes in same command.");
}
cmdl.setJar(jarfile.getAbsolutePath());
}

/** /**
* Set the class name. * Set the class name.
*/ */
public void setClassname(String s) {
public void setClassname(String s) throws BuildException {
if ( cmdl.getJar() != null ){
throw new BuildException("Cannot use 'jar' and 'classname' attributes in same command");
}
cmdl.setClassname(s); cmdl.setClassname(s);
} }




Loading…
Cancel
Save