Browse Source

Bug: 39153

Add notes (log+manual) that <java> 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
master
Jan Materne 19 years ago
parent
commit
69679b4828
4 changed files with 18 additions and 6 deletions
  1. +1
    -0
      CONTRIBUTORS
  2. +4
    -0
      contributors.xml
  3. +7
    -4
      docs/manual/CoreTasks/java.html
  4. +6
    -2
      src/main/org/apache/tools/ant/taskdefs/Java.java

+ 1
- 0
CONTRIBUTORS View File

@@ -242,6 +242,7 @@ Ulrich Schmidt
Waldek Herka Waldek Herka
Will Wang Will Wang
William Ferguson William Ferguson
Wolfgang Frech
Wolfgang Werner Wolfgang Werner
Wolf Siberski Wolf Siberski
Yohann Roussel Yohann Roussel


+ 4
- 0
contributors.xml View File

@@ -958,6 +958,10 @@
<first>William</first> <first>William</first>
<last>Ferguson</last> <last>Ferguson</last>
</name> </name>
<name>
<first>Wolfgang</first>
<last>Frech</last>
</name>
<name> <name>
<first>Wolfgang</first> <first>Wolfgang</first>
<last>Werner</last> <last>Werner</last>


+ 7
- 4
docs/manual/CoreTasks/java.html View File

@@ -288,12 +288,15 @@ exit, as the class was run by the build JVM.</p>


<h3>JAR file execution</h3> <h3>JAR file execution</h3>


The parameter of the <tt>jar</tt> attribute is of type <tt>File</tt>;
<p>The parameter of the <tt>jar</tt> attribute is of type <tt>File</tt>;
that is, the parameter is resolved to an absolute file relative to the that is, the parameter is resolved to an absolute file relative to the
base directory of the project, <i>not</i> the directory in which the Java base directory of the project, <i>not</i> the directory in which the Java
task is run. If you need to locate a JAR file relative to the directory 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 the task will be run in, you need to explicitly create the full path
to the JAR file.
to the JAR file.</p>
<p>When using the <tt>jar</tt> attribute, all classpath settings are
ignored according to <a href="http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/java.html#-jar">Sun's
specification</a>.




<h3>Examples</h3> <h3>Examples</h3>
@@ -355,14 +358,14 @@ Runs a given class with the current classpath.
&lt;jvmarg value=&quot;-Xrunhprof:cpu=samples,file=log.txt,depth=3&quot;/&gt; &lt;jvmarg value=&quot;-Xrunhprof:cpu=samples,file=log.txt,depth=3&quot;/&gt;
&lt;/java&gt; &lt;/java&gt;
</pre> </pre>
Add system properties and JVM-properties to the JVM as in
Add system properties and JVM-properties to the JVM as in
<code>java ="-Xrunhprof:cpu=samples,file=log.txt,depth=3 -DDEBUG=true test.Main</code> <code>java ="-Xrunhprof:cpu=samples,file=log.txt,depth=3 -DDEBUG=true test.Main</code>


<pre> &lt;java classname=&quot;ShowJavaVersion&quot; classpath=&quot;.&quot; <pre> &lt;java classname=&quot;ShowJavaVersion&quot; classpath=&quot;.&quot;
jvm=&quot;path-to-java14-home/bin/java&quot; fork=&quot;true&quot; jvm=&quot;path-to-java14-home/bin/java&quot; fork=&quot;true&quot;
taskname=&quot;java1.4&quot; &gt; taskname=&quot;java1.4&quot; &gt;
</pre> </pre>
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 <code>taskname</code> is used to change the <code>[java]</code> For documentation in the log <code>taskname</code> is used to change the <code>[java]</code>
log-prefix to <code>[java1.4]</code>. log-prefix to <code>[java1.4]</code>.




+ 6
- 2
src/main/org/apache/tools/ant/taskdefs/Java.java View File

@@ -116,7 +116,7 @@ public class Java extends Task {
* Do the execution and return a return code. * Do the execution and return a return code.
* *
* @return the return code from the execute java class if it was * @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). * installed that prohibits ExitVM (default).
* *
* @throws BuildException if required parameters are missing. * @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." throw new BuildException("Cannot spawn a java process in non-forked mode."
+ " Please set fork='true'. "); + " 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) { if (spawn && incompatibleWithSpawn) {
getProject().log("spawn does not allow attributes related to input, " getProject().log("spawn does not allow attributes related to input, "
+ "output, error, result", Project.MSG_ERR); + "output, error, result", Project.MSG_ERR);
@@ -925,4 +929,4 @@ public class Java extends Task {
public CommandlineJava.SysProperties getSysProperties() { public CommandlineJava.SysProperties getSysProperties() {
return cmdl.getSystemProperties(); return cmdl.getSystemProperties();
} }
}
}

Loading…
Cancel
Save