update to avoid FileNotFoundException if the parent directory does not exist .
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@112850 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -87,7 +87,7 @@ import org.apache.maven.project.Developer;
|
||||
* @author <a href="mailto:dion@multitask.com.au">dIon Gillard</a>
|
||||
* @author <a href="mailto:bodewig@apache.org">Stefan Bodewig</a>
|
||||
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
|
||||
* @version $Id: ChangeLog.java,v 1.1 2003/01/24 03:44:52 jvanzyl Exp $
|
||||
* @version $Id: ChangeLog.java,v 1.2 2003/02/07 11:47:13 evenisse Exp $
|
||||
*/
|
||||
public class ChangeLog
|
||||
{
|
||||
@@ -334,7 +334,10 @@ public class ChangeLog
|
||||
private void createDocument() throws FileNotFoundException,
|
||||
UnsupportedEncodingException
|
||||
{
|
||||
|
||||
File dir = output.getParentFile();
|
||||
if (dir != null) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
PrintWriter out = new PrintWriter(new OutputStreamWriter(
|
||||
new FileOutputStream(output), getOutputEncoding()));
|
||||
out.println(toXML());
|
||||
|
||||
@@ -56,6 +56,7 @@ package org.apache.maven.j2ee;
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.PrintStream;
|
||||
@@ -64,7 +65,7 @@ import java.io.PrintStream;
|
||||
* Base class for formatters of validation events.
|
||||
* Handles plain and xml formats.
|
||||
*
|
||||
* @version $Id: ValidationFormatter.java,v 1.1 2003/01/24 03:45:16 jvanzyl Exp $
|
||||
* @version $Id: ValidationFormatter.java,v 1.2 2003/02/07 11:47:14 evenisse Exp $
|
||||
* @author dion
|
||||
*/
|
||||
public class ValidationFormatter implements ValidationListener
|
||||
@@ -246,6 +247,11 @@ public class ValidationFormatter implements ValidationListener
|
||||
public void setFile(String file) throws FileNotFoundException
|
||||
{
|
||||
this.file = file;
|
||||
File theFile = new File(file);
|
||||
File dir = theFile.getParentFile();
|
||||
if (dir != null) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
stream = new PrintStream(fos);
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ import org.apache.commons.jelly.XMLOutput;
|
||||
*
|
||||
*
|
||||
* @author <a href="mailto:brian@brainslug.org">Brian Leonard</a>
|
||||
* @version $Id: DirectoryIndexer.java,v 1.1 2003/01/24 03:45:40 jvanzyl Exp $
|
||||
* @version $Id: DirectoryIndexer.java,v 1.2 2003/02/07 11:47:14 evenisse Exp $
|
||||
*/
|
||||
public class DirectoryIndexer
|
||||
{
|
||||
@@ -267,6 +267,11 @@ public class DirectoryIndexer
|
||||
String templateFileName = getTemplateDir() + "/" + templateName + ".jelly";
|
||||
File templateFile = new File(templateFileName);
|
||||
|
||||
File theFile = new File(outFile);
|
||||
File dir = theFile.getParentFile();
|
||||
if (dir != null) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
OutputStream out = new FileOutputStream(outFile);
|
||||
XMLOutput xmlOutput = XMLOutput.createXMLOutput(out, false);
|
||||
context.runScript(templateFile, xmlOutput);
|
||||
|
||||
@@ -74,7 +74,7 @@ import java.io.UnsupportedEncodingException;
|
||||
*
|
||||
* @author <a href="mailto:mmay@javafreedom.org">Markus M. May</a>
|
||||
* @author <a href="mailto:dion@multitask.com.au">dIon Gillard</a>
|
||||
* @version $Id: LicenseTask.java,v 1.1 2003/01/24 03:45:47 jvanzyl Exp $
|
||||
* @version $Id: LicenseTask.java,v 1.2 2003/02/07 11:47:14 evenisse Exp $
|
||||
*/
|
||||
public class LicenseTask
|
||||
{
|
||||
@@ -140,6 +140,10 @@ public class LicenseTask
|
||||
throw new IOException("cannot read license file");
|
||||
}
|
||||
|
||||
File dir = output.getParentFile();
|
||||
if (dir != null) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
PrintWriter out = new PrintWriter(new OutputStreamWriter(
|
||||
new FileOutputStream(output), getOutputEncoding()));
|
||||
out.print("<?xml version=\"1.0\" encoding=\"");
|
||||
|
||||
@@ -77,7 +77,7 @@ import org.apache.maven.linkcheck.validation.MailtoLinkValidator;
|
||||
* their links checked.
|
||||
*
|
||||
* @author <a href="mailto:bwalding@apache.org">Ben Walding</a>
|
||||
* @version $Id: LinkCheck.java,v 1.3 2003/02/03 14:13:54 bwalding Exp $
|
||||
* @version $Id: LinkCheck.java,v 1.4 2003/02/07 11:47:14 evenisse Exp $
|
||||
*/
|
||||
public class LinkCheck
|
||||
{
|
||||
@@ -216,6 +216,10 @@ public class LinkCheck
|
||||
*/
|
||||
private void createDocument(List files) throws Exception
|
||||
{
|
||||
File dir = output.getParentFile();
|
||||
if (dir != null) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
PrintWriter out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(output), getOutputEncoding()));
|
||||
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
|
||||
@@ -69,7 +69,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:bwalding@apache.org">Ben Walding</a>
|
||||
* @version $Id: LinkValidatorManager.java,v 1.2 2003/02/03 14:13:54 bwalding Exp $
|
||||
* @version $Id: LinkValidatorManager.java,v 1.3 2003/02/07 11:47:14 evenisse Exp $
|
||||
*/
|
||||
|
||||
public class LinkValidatorManager {
|
||||
@@ -145,6 +145,11 @@ public class LinkValidatorManager {
|
||||
|
||||
public void saveCache(String cacheFilename) {
|
||||
try {
|
||||
File cacheFile = new File(cacheFileName);
|
||||
File dir = cacheFile.getParentFile();
|
||||
if (dir != null) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
this.cache.save(new FileOutputStream(cacheFilename));
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
Reference in New Issue
Block a user