You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by sb...@apache.org on 2001/08/02 23:52:59 UTC
cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Java.java
sbailliez 01/08/02 14:52:59
Modified: src/main/org/apache/tools/ant/taskdefs Java.java
Log:
Added the support to the -jar option in the command line per suggestion of <as...@nc.rr.com>
Revision Changes Path
1.29 +18 -3 jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Java.java
Index: Java.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Java.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- Java.java 2001/08/02 14:38:46 1.28
+++ Java.java 2001/08/02 21:52:59 1.29
@@ -102,10 +102,12 @@
*/
public int executeJava() throws BuildException {
String classname = cmdl.getClassname();
-
- if (classname == null) {
+ if (classname == null && cmdl.getJar() == 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) {
log("Forking " + cmdl.toString(), Project.MSG_VERBOSE);
@@ -153,9 +155,22 @@
}
/**
+ * 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.
*/
- 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);
}