From 69679b4828a3512eb702c77311fbd8a2c5b6795f Mon Sep 17 00:00:00 2001 From: Jan Materne Date: Fri, 7 Jul 2006 14:39:28 +0000 Subject: [PATCH] Bug: 39153 Add notes (log+manual) that does not handle jar+classpath together (more exactly Java itself does not). git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@419898 13f79535-47bb-0310-9956-ffa450edef68 --- CONTRIBUTORS | 1 + contributors.xml | 4 ++++ docs/manual/CoreTasks/java.html | 11 +++++++---- src/main/org/apache/tools/ant/taskdefs/Java.java | 8 ++++++-- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 5dea6ecda..45c04e1eb 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -242,6 +242,7 @@ Ulrich Schmidt Waldek Herka Will Wang William Ferguson +Wolfgang Frech Wolfgang Werner Wolf Siberski Yohann Roussel diff --git a/contributors.xml b/contributors.xml index 70fe5576e..24ae73a23 100644 --- a/contributors.xml +++ b/contributors.xml @@ -958,6 +958,10 @@ William Ferguson + + Wolfgang + Frech + Wolfgang Werner diff --git a/docs/manual/CoreTasks/java.html b/docs/manual/CoreTasks/java.html index 3315c99aa..38b386591 100644 --- a/docs/manual/CoreTasks/java.html +++ b/docs/manual/CoreTasks/java.html @@ -288,12 +288,15 @@ exit, as the class was run by the build JVM.

JAR file execution

-The parameter of the jar attribute is of type File; +

The parameter of the jar attribute is of type File; that is, the parameter is resolved to an absolute file relative to the base directory of the project, not the directory in which the Java task is run. If you need to locate a JAR file relative to the directory the task will be run in, you need to explicitly create the full path -to the JAR file. +to the JAR file.

+

When using the jar attribute, all classpath settings are +ignored according to Sun's +specification.

Examples

@@ -355,14 +358,14 @@ Runs a given class with the current classpath. <jvmarg value="-Xrunhprof:cpu=samples,file=log.txt,depth=3"/> </java> -Add system properties and JVM-properties to the JVM as in +Add system properties and JVM-properties to the JVM as in java ="-Xrunhprof:cpu=samples,file=log.txt,depth=3 -DDEBUG=true test.Main
  <java classname="ShowJavaVersion" classpath="."
         jvm="path-to-java14-home/bin/java" fork="true"
         taskname="java1.4" >
 
-Use a given Java implementation (another the one Ant is currently using) to run the class. +Use a given Java implementation (another the one Ant is currently using) to run the class. For documentation in the log taskname is used to change the [java] log-prefix to [java1.4]. diff --git a/src/main/org/apache/tools/ant/taskdefs/Java.java b/src/main/org/apache/tools/ant/taskdefs/Java.java index 4f8aa42bd..aed95cfb6 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Java.java +++ b/src/main/org/apache/tools/ant/taskdefs/Java.java @@ -116,7 +116,7 @@ public class Java extends Task { * 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 + * executed in a separate VM (fork = "yes") or a security manager was * installed that prohibits ExitVM (default). * * @throws BuildException if required parameters are missing. @@ -134,6 +134,10 @@ public class Java extends Task { throw new BuildException("Cannot spawn a java process in non-forked mode." + " Please set fork='true'. "); } + if (cmdl.getClasspath()!=null && cmdl.getJar()!=null) { + log("When using 'jar' attribute classpath-settings are ignored. " + + "See the manual for more information.", Project.MSG_VERBOSE); + } if (spawn && incompatibleWithSpawn) { getProject().log("spawn does not allow attributes related to input, " + "output, error, result", Project.MSG_ERR); @@ -925,4 +929,4 @@ public class Java extends Task { public CommandlineJava.SysProperties getSysProperties() { return cmdl.getSystemProperties(); } -} +} \ No newline at end of file