commit | fa30d102f41d8a03443d3421fb69698e76ae2851 | [log] [tgz] |
---|---|---|
author | Musachy Barroso <musachy@apache.org> | Wed Mar 04 20:31:56 2009 +0000 |
committer | Musachy Barroso <musachy@apache.org> | Wed Mar 04 20:31:56 2009 +0000 |
tree | 75f1ad68af29315435c4a7f1888aafba7bbecada | |
parent | 67ac34e95dfe42ba14d16be6196a3196e56233be [diff] |
Create output directory when it does not exist git-svn-id: https://svn.apache.org/repos/asf/struts/maven/trunk@750143 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/TagAnnotationProcessor.java b/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/TagAnnotationProcessor.java index 429edba..d3a1bbb 100644 --- a/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/TagAnnotationProcessor.java +++ b/struts-annotations/src/main/java/org/apache/struts/annotations/taglib/apt/TagAnnotationProcessor.java
@@ -353,9 +353,15 @@ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); + //create output directory if it does not exists + File outputFile = new File(getOption("outFile")); + File parentDir = outputFile.getParentFile(); + if (!parentDir.exists()) + parentDir.mkdirs(); + Source source = new DOMSource(document); Result result = new StreamResult(new OutputStreamWriter( - new FileOutputStream(getOption("outFile")))); + new FileOutputStream(outputFile))); transformer.transform(source, result); } catch (Exception e) { // oops we cannot throw checked exceptions