PR: 5268 Submitted by: Alex Rosen <arosen@silverstream.com> git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271351 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -161,6 +161,8 @@ Other changes: | |||||
| * <tstamp> now supports a new "prefix" attribute to prefix properties set. | * <tstamp> now supports a new "prefix" attribute to prefix properties set. | ||||
| * you can now specify the -sourcepath for <javac> explicitly. | |||||
| Changes from Ant 1.4 to Ant 1.4.1 | Changes from Ant 1.4 to Ant 1.4.1 | ||||
| =========================================== | =========================================== | ||||
| @@ -116,6 +116,11 @@ invoking the compiler.</p> | |||||
| <td valign="top">the classpath to use.</td> | <td valign="top">the classpath to use.</td> | ||||
| <td align="center" valign="top">No</td> | <td align="center" valign="top">No</td> | ||||
| </tr> | </tr> | ||||
| <tr> | |||||
| <td valign="top">sourcepath</td> | |||||
| <td valign="top">the sourcepath to use; defaults to the value of the srcdir attribute (or <code><src></code> elements).</td> | |||||
| <td align="center" valign="top">No</td> | |||||
| </tr> | |||||
| <tr> | <tr> | ||||
| <td valign="top">bootclasspath</td> | <td valign="top">bootclasspath</td> | ||||
| <td valign="top">location of bootstrap class files.</td> | <td valign="top">location of bootstrap class files.</td> | ||||
| @@ -127,6 +132,12 @@ invoking the compiler.</p> | |||||
| <a href="../using.html#references">reference</a> to a PATH defined elsewhere.</td> | <a href="../using.html#references">reference</a> to a PATH defined elsewhere.</td> | ||||
| <td align="center" valign="top">No</td> | <td align="center" valign="top">No</td> | ||||
| </tr> | </tr> | ||||
| <tr> | |||||
| <td valign="top">sourcepathref</td> | |||||
| <td valign="top">the sourcepath to use, given as a | |||||
| <a href="../using.html#references">reference</a> to a PATH defined elsewhere.</td> | |||||
| <td align="center" valign="top">No</td> | |||||
| </tr> | |||||
| <tr> | <tr> | ||||
| <td valign="top">bootclasspathref</td> | <td valign="top">bootclasspathref</td> | ||||
| <td valign="top">location of bootstrap class files, given as a | <td valign="top">location of bootstrap class files, given as a | ||||
| @@ -255,14 +266,16 @@ supports all attributes of <code><fileset></code> | |||||
| (<code>dir</code> becomes <code>srcdir</code>) as well as the nested | (<code>dir</code> becomes <code>srcdir</code>) as well as the nested | ||||
| <code><include></code>, <code><exclude></code> and | <code><include></code>, <code><exclude></code> and | ||||
| <code><patternset></code> elements.</p> | <code><patternset></code> elements.</p> | ||||
| <h4><code>src</code>, <code>classpath</code>, <code>bootclasspath</code> and <code>extdirs</code></h4> | |||||
| <h4><code>src</code>, <code>classpath</code>, <code>sourcepath</code>, | |||||
| <code>bootclasspath</code> and <code>extdirs</code></h4> | |||||
| <p><code>Javac</code>'s <i>srcdir</i>, <i>classpath</i>, | <p><code>Javac</code>'s <i>srcdir</i>, <i>classpath</i>, | ||||
| <i>bootclasspath</i> and <i>extdirs</i> attributes are <a | |||||
| <i>sourcepath</i>, <i>bootclasspath</i> and <i>extdirs</i> attributes are <a | |||||
| href="../using.html#path">path-like structures</a> and can also be set via nested | href="../using.html#path">path-like structures</a> and can also be set via nested | ||||
| <code><src></code>, | |||||
| <code><classpath></code>, | |||||
| <code><bootclasspath></code> and | |||||
| <code><extdirs></code> elements, respectively.</p> | |||||
| <code><src></code>, | |||||
| <code><classpath></code>, | |||||
| <code><sourcepath></code>, | |||||
| <code><bootclasspath></code> and | |||||
| <code><extdirs></code> elements, respectively.</p> | |||||
| <h4>compilerarg</h4> | <h4>compilerarg</h4> | ||||
| @@ -425,7 +438,7 @@ build.compiler.warnings is "true" while all others are "false&quo | |||||
| </tr> | </tr> | ||||
| </table> | </table> | ||||
| <hr> | <hr> | ||||
| <p align="center">Copyright © 2001 Apache Software Foundation. All rights | |||||
| <p align="center">Copyright © 2001-2002 Apache Software Foundation. All rights | |||||
| Reserved.</p> | Reserved.</p> | ||||
| </body> | </body> | ||||
| @@ -111,6 +111,7 @@ public class Javac extends MatchingTask { | |||||
| private Path src; | private Path src; | ||||
| private File destDir; | private File destDir; | ||||
| private Path compileClasspath; | private Path compileClasspath; | ||||
| private Path compileSourcepath; | |||||
| private String encoding; | private String encoding; | ||||
| private boolean debug = false; | private boolean debug = false; | ||||
| private boolean optimize = false; | private boolean optimize = false; | ||||
| @@ -222,6 +223,39 @@ public class Javac extends MatchingTask { | |||||
| return destDir; | return destDir; | ||||
| } | } | ||||
| /** | |||||
| * Set the sourcepath to be used for this compilation. | |||||
| */ | |||||
| public void setSourcepath(Path sourcepath) { | |||||
| if (compileSourcepath == null) { | |||||
| compileSourcepath = sourcepath; | |||||
| } else { | |||||
| compileSourcepath.append(sourcepath); | |||||
| } | |||||
| } | |||||
| /** Gets the sourcepath to be used for this compilation. */ | |||||
| public Path getSourcepath() { | |||||
| return compileSourcepath; | |||||
| } | |||||
| /** | |||||
| * Maybe creates a nested sourcepath element. | |||||
| */ | |||||
| public Path createSourcepath() { | |||||
| if (compileSourcepath == null) { | |||||
| compileSourcepath = new Path(project); | |||||
| } | |||||
| return compileSourcepath.createPath(); | |||||
| } | |||||
| /** | |||||
| * Adds a reference to a CLASSPATH defined elsewhere. | |||||
| */ | |||||
| public void setSourcepathRef(Reference r) { | |||||
| createSourcepath().setRefid(r); | |||||
| } | |||||
| /** | /** | ||||
| * Set the classpath to be used for this compilation. | * Set the classpath to be used for this compilation. | ||||
| */ | */ | ||||
| @@ -1,7 +1,7 @@ | |||||
| /* | /* | ||||
| * The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
| * | * | ||||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
| * Copyright (c) 2001-2002 The Apache Software Foundation. All rights | |||||
| * reserved. | * reserved. | ||||
| * | * | ||||
| * Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
| @@ -97,6 +97,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter { | |||||
| protected Path bootclasspath; | protected Path bootclasspath; | ||||
| protected Path extdirs; | protected Path extdirs; | ||||
| protected Path compileClasspath; | protected Path compileClasspath; | ||||
| protected Path compileSourcepath; | |||||
| protected Project project; | protected Project project; | ||||
| protected Location location; | protected Location location; | ||||
| protected boolean includeAntRuntime; | protected boolean includeAntRuntime; | ||||
| @@ -125,6 +126,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter { | |||||
| extdirs = attributes.getExtdirs(); | extdirs = attributes.getExtdirs(); | ||||
| compileList = attributes.getFileList(); | compileList = attributes.getFileList(); | ||||
| compileClasspath = attributes.getClasspath(); | compileClasspath = attributes.getClasspath(); | ||||
| compileSourcepath = attributes.getSourcepath(); | |||||
| project = attributes.getProject(); | project = attributes.getProject(); | ||||
| location = attributes.getLocation(); | location = attributes.getLocation(); | ||||
| includeAntRuntime = attributes.getIncludeantruntime(); | includeAntRuntime = attributes.getIncludeantruntime(); | ||||
| @@ -184,6 +186,14 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter { | |||||
| protected Commandline setupJavacCommandlineSwitches(Commandline cmd, | protected Commandline setupJavacCommandlineSwitches(Commandline cmd, | ||||
| boolean useDebugLevel) { | boolean useDebugLevel) { | ||||
| Path classpath = getCompileClasspath(); | Path classpath = getCompileClasspath(); | ||||
| // For -sourcepath, use the "sourcepath" value if present. | |||||
| // Otherwise default to the "srcdir" value. | |||||
| Path sourcepath = null; | |||||
| if (compileSourcepath != null) { | |||||
| sourcepath = compileSourcepath; | |||||
| } else { | |||||
| sourcepath = src; | |||||
| } | |||||
| // we cannot be using Java 1.0 when forking, so we only have to | // we cannot be using Java 1.0 when forking, so we only have to | ||||
| // distinguish between Java 1.1, and Java 1.2 and higher, as Java 1.1 | // distinguish between Java 1.1, and Java 1.2 and higher, as Java 1.1 | ||||
| @@ -237,12 +247,15 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter { | |||||
| cp.addExtdirs(extdirs); | cp.addExtdirs(extdirs); | ||||
| } | } | ||||
| cp.append(classpath); | cp.append(classpath); | ||||
| cp.append(src); | |||||
| cp.append(sourcepath); | |||||
| cmd.createArgument().setPath(cp); | cmd.createArgument().setPath(cp); | ||||
| } else { | } else { | ||||
| cmd.createArgument().setPath(classpath); | cmd.createArgument().setPath(classpath); | ||||
| cmd.createArgument().setValue("-sourcepath"); | |||||
| cmd.createArgument().setPath(src); | |||||
| // If the buildfile specifies sourcepath="", then don't output any sourcepath. | |||||
| if (sourcepath.size() > 0) { | |||||
| cmd.createArgument().setValue("-sourcepath"); | |||||
| cmd.createArgument().setPath(sourcepath); | |||||
| } | |||||
| if (target != null) { | if (target != null) { | ||||
| cmd.createArgument().setValue("-target"); | cmd.createArgument().setValue("-target"); | ||||
| cmd.createArgument().setValue(target); | cmd.createArgument().setValue(target); | ||||