ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Ant.java
Date Tue, 02 Apr 2002 15:21:10 GMT
On 1 Apr 2002, <holtdl@apache.org> wrote:

>   If 'output' is a simple or relative filename, make it relative
>   to ${basedir}, not ${user.dir}. (If it's a full-path, it'll go
>   to the full-path file.)  (PR 4548)

Your patch will not make that happen.

What we have now:

* user has specified a dir attribute -> output is resolved relative to
dir, not to ${basedir}

* user has not specified a dir attribute -> NullPointerException
(outfile is null in the first line of the try block).

As I'm not sure what you want to do in the presence of a dir
attribute, therefore I'm not patching the task right now.  The
(untested) patch below would make it

* user has specified a dir attribute -> output is resolved relative to
dir, not to ${basedir}

* user has not specified a dir attribute -> output is resolved
relative to ${basedir}

If you really just want to resolve it relative to ${basedir}, forget
the dir != null case.

Stefan

Index: src/main/org/apache/tools/ant/taskdefs/Ant.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Ant.java,v
retrieving revision 1.44
diff -u -r1.44 Ant.java
--- src/main/org/apache/tools/ant/taskdefs/Ant.java	1 Apr 2002 05:41:30 -0000	1.44
+++ src/main/org/apache/tools/ant/taskdefs/Ant.java	2 Apr 2002 15:13:29 -0000
@@ -105,7 +105,6 @@
     
     /** the output */
     private String output  = null;
-    private String outfile = null;
     
     /** should we inherit properties from the parent ? */
     private boolean inheritAll = true;
@@ -175,10 +174,13 @@
         }
 
         if (output != null) {
+            File outfile = null;
             if (dir != null) {
-                File file = FileUtils.newFileUtils().resolveFile(dir, output);
-                outfile = file.getAbsolutePath();
+                outfile = FileUtils.newFileUtils().resolveFile(dir, output);
+            } else {
+                outfile = getProject().resolveFile(output);
             }
+            
             try {
                 PrintStream out = new PrintStream(new FileOutputStream(outfile));
                 DefaultLogger logger = new DefaultLogger();

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message