You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Russell Gold <ru...@acm.org> on 2000/07/20 17:29:58 UTC

[PATCH] creating sub-directories for Style task

This patch should ensure that the target directories are in place for the 
style task to use:

------ begin patch ----
Index: src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java,v
retrieving revision 1.5
diff -u -r1.5 XSLTProcess.java
--- src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java     2000/07/06 
16:48:19     1.5
+++ src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java     2000/07/20 
15:27:13
@@ -295,6 +295,7 @@
             inFile = new File(baseDir,xmlFile);
             outFile = new 
File(destDir,xmlFile.substring(0,xmlFile.lastIndexOf('.'))+fileExt);
             if (inFile.lastModified() > outFile.lastModified()) {
+            ensureDirectoryFor( outFile );
                 //-- command line status
                 log("Processing " + xmlFile + " to " + outFile, 
Project.MSG_VERBOSE);

@@ -310,5 +311,14 @@
          }

      } //-- processXML
+
+
+
+    private void ensureDirectoryFor( File targetFile ) throws BuildException {
+        File directory = new File( targetFile.getParent() );
+        if (!directory.exists()) {
+            if (!directory.mkdirs()) throw new BuildException( "Unable to 
create directory: " + directory.getAbsolutePath() );
+        }
+    }

  } //-- XSLTProcess
------- end patch -----