Browse Source

From the JDK tool-docs for javac of JDK 1.4:

> An argument file can include javac options and source filenames in
> any combination. The arguments within a file can be space-separated
> or newline-separated.

that means, file names must be quoted if they contain spaces.  No idea
whether this is true for JDK 1.2 or 1.3 as well (1.1 doesn't support
@argfile).

PR: 10499


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274533 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 22 years ago
parent
commit
6e7154321d
3 changed files with 32 additions and 3 deletions
  1. +3
    -0
      WHATSNEW
  2. +24
    -1
      src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
  3. +5
    -2
      src/main/org/apache/tools/ant/taskdefs/compilers/JavacExternal.java

+ 3
- 0
WHATSNEW View File

@@ -109,6 +109,9 @@ Fixed bugs:
* <replaceregexp> didn't work for multi-byte encodings if byline was false.
Bugzilla Report 19187.

* file names that include spaces need to be quoted inside the @argfile
argument using forked <javac> and JDK 1.4. Bugzilla Report 10499.

Other changes:
--------------
* Six new Clearcase tasks added.


+ 24
- 1
src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java View File

@@ -398,6 +398,25 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter {
* system.
*/
protected int executeExternalCompile(String[] args, int firstFileName) {
return executeExternalCompile(args, firstFileName, false);
}

/**
* Do the compile with the specified arguments.
* @param args - arguments to pass to process on command line
* @param firstFileName - index of the first source file in args,
* if the index is negative, no temporary file will ever be
* created, but this may hit the command line length limit on your
* system.
* @param quoteFilenames - if set to true, filenames containing
* spaces will be quoted when they appear in the external file.
* This is necessary when running JDK 1.4's javac and probably
* others.
*
* @since Ant 1.6
*/
protected int executeExternalCompile(String[] args, int firstFileName,
boolean quoteFiles) {
String[] commandArray = null;
File tmpFile = null;

@@ -418,7 +437,11 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter {
tmpFile = fileUtils.createTempFile("files", "", userDir);
out = new PrintWriter(new FileWriter(tmpFile));
for (int i = firstFileName; i < args.length; i++) {
out.println(args[i]);
if (quoteFiles && args[i].indexOf(" ") > -1) {
out.println("\"" + args[i] + "\"");
} else {
out.println(args[i]);
}
}
out.flush();
commandArray = new String[firstFileName + 1];


+ 5
- 2
src/main/org/apache/tools/ant/taskdefs/compilers/JavacExternal.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2002 The Apache Software Foundation. All rights
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -79,7 +79,10 @@ public class JavacExternal extends DefaultCompilerAdapter {
logAndAddFilesToCompile(cmd);

return
executeExternalCompile(cmd.getCommandline(), firstFileName) == 0;
executeExternalCompile(cmd.getCommandline(), firstFileName,
!assumeJava11() && !assumeJava12()
&& !assumeJava13())
== 0;
}

}


Loading…
Cancel
Save