bodewig 2003/04/29 06:16:22
Modified: . WHATSNEW src/main/org/apache/tools/ant/taskdefs/compilers DefaultCompilerAdapter.java JavacExternal.java Log: 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 Revision Changes Path 1.406 +3 -0 ant/WHATSNEW Index: WHATSNEW =================================================================== RCS file: /home/cvs/ant/WHATSNEW,v retrieving revision 1.405 retrieving revision 1.406 diff -u -r1.405 -r1.406 --- WHATSNEW 24 Apr 2003 13:02:53 -0000 1.405 +++ WHATSNEW 29 Apr 2003 13:16:22 -0000 1.406 @@ -109,6 +109,9 @@ * <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. 1.35 +24 -1 ant/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java Index: DefaultCompilerAdapter.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- DefaultCompilerAdapter.java 7 Mar 2003 11:23:04 -0000 1.34 +++ DefaultCompilerAdapter.java 29 Apr 2003 13:16:22 -0000 1.35 @@ -398,6 +398,25 @@ * 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 @@ 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]; 1.9 +5 -2 ant/src/main/org/apache/tools/ant/taskdefs/compilers/JavacExternal.java Index: JavacExternal.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/compilers/JavacExternal.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- JavacExternal.java 10 Feb 2003 14:13:42 -0000 1.8 +++ JavacExternal.java 29 Apr 2003 13:16:22 -0000 1.9 @@ -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 @@ logAndAddFilesToCompile(cmd); return - executeExternalCompile(cmd.getCommandline(), firstFileName) == 0; + executeExternalCompile(cmd.getCommandline(), firstFileName, + !assumeJava11() && !assumeJava12() + && !assumeJava13()) + == 0; } }