Browse Source

Made destdir in <javac> optional - don't use the -d switch at all if

this one hasn't been given.

Submitted by:	Alexander Pokahr <5pokahr@informatik.uni-hamburg.de>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268079 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 25 years ago
parent
commit
8e8cf291a5
2 changed files with 22 additions and 18 deletions
  1. +1
    -1
      docs/index.html
  2. +21
    -17
      src/main/org/apache/tools/ant/taskdefs/Javac.java

+ 1
- 1
docs/index.html View File

@@ -2555,7 +2555,7 @@ inclusion/exclusion of files works, and how to write patterns.</p>
<tr> <tr>
<td valign="top">destdir</td> <td valign="top">destdir</td>
<td valign="top">location where to store the class files.</td> <td valign="top">location where to store the class files.</td>
<td align="center" valign="top">No (defaults to - the first - srcdir)</td>
<td align="center" valign="top">No</td>
</tr> </tr>
<tr> <tr>
<td valign="top">includes</td> <td valign="top">includes</td>


+ 21
- 17
src/main/org/apache/tools/ant/taskdefs/Javac.java View File

@@ -291,14 +291,7 @@ public class Javac extends MatchingTask {
throw new BuildException("srcdir attribute must be set!", location); throw new BuildException("srcdir attribute must be set!", location);
} }
if (destDir == null) {
destDir = project.resolveFile(list[0]);
log("destdir set to "+destDir.getPath()+" from srcdir attribute",
Project.MSG_INFO);
}

if (!destDir.isDirectory()) {
if (destDir != null && !destDir.isDirectory()) {
throw new BuildException("destination directory \"" + destDir + "\" does not exist or is not a directory", location); throw new BuildException("destination directory \"" + destDir + "\" does not exist or is not a directory", location);
} }


@@ -315,7 +308,7 @@ public class Javac extends MatchingTask {


String[] files = ds.getIncludedFiles(); String[] files = ds.getIncludedFiles();


scanDir(srcDir, destDir, files);
scanDir(srcDir, destDir != null ? destDir : srcDir, files);
} }
// compile the source files // compile the source files
@@ -333,7 +326,7 @@ public class Javac extends MatchingTask {
log("Compiling " + compileList.size() + log("Compiling " + compileList.size() +
" source file" " source file"
+ (compileList.size() == 1 ? "" : "s") + (compileList.size() == 1 ? "" : "s")
+ " to " + destDir);
+ (destDir != null ? " to " + destDir : ""));


if (compiler.equalsIgnoreCase("classic")) { if (compiler.equalsIgnoreCase("classic")) {
doClassicCompile(); doClassicCompile();
@@ -407,7 +400,9 @@ public class Javac extends MatchingTask {
// add dest dir to classpath so that previously compiled and // add dest dir to classpath so that previously compiled and
// untouched classes are on classpath // untouched classes are on classpath


classpath.setLocation(destDir);
if (destDir != null) {
classpath.setLocation(destDir);
}


// add our classpath to the mix // add our classpath to the mix


@@ -542,8 +537,11 @@ public class Javac extends MatchingTask {
cmd.createArgument().setValue("-deprecation"); cmd.createArgument().setValue("-deprecation");
} }


cmd.createArgument().setValue("-d");
cmd.createArgument().setFile(destDir);
if (destDir != null) {
cmd.createArgument().setValue("-d");
cmd.createArgument().setFile(destDir);
}
cmd.createArgument().setValue("-classpath"); cmd.createArgument().setValue("-classpath");
// Just add "sourcepath" to classpath ( for JDK1.1 ) // Just add "sourcepath" to classpath ( for JDK1.1 )
if (Project.getJavaVersion().startsWith("1.1")) { if (Project.getJavaVersion().startsWith("1.1")) {
@@ -669,8 +667,11 @@ public class Javac extends MatchingTask {
if (deprecation == true) if (deprecation == true)
cmd.createArgument().setValue("-deprecation"); cmd.createArgument().setValue("-deprecation");


cmd.createArgument().setValue("-d");
cmd.createArgument().setFile(destDir);
if (destDir != null) {
cmd.createArgument().setValue("-d");
cmd.createArgument().setFile(destDir);
}
cmd.createArgument().setValue("-classpath"); cmd.createArgument().setValue("-classpath");
cmd.createArgument().setPath(classpath); cmd.createArgument().setPath(classpath);


@@ -853,8 +854,11 @@ public class Javac extends MatchingTask {
Commandline cmd = new Commandline(); Commandline cmd = new Commandline();
cmd.setExecutable("jvc"); cmd.setExecutable("jvc");


cmd.createArgument().setValue("/d");
cmd.createArgument().setFile(destDir);
if (destDir != null) {
cmd.createArgument().setValue("/d");
cmd.createArgument().setFile(destDir);
}
// Add the Classpath before the "internal" one. // Add the Classpath before the "internal" one.
cmd.createArgument().setValue("/cp:p"); cmd.createArgument().setValue("/cp:p");
cmd.createArgument().setPath(classpath); cmd.createArgument().setPath(classpath);


Loading…
Cancel
Save