+ }
+
+ private File getOutputFile(String filename)
+ throws
+ MojoExecutionException
+ {
+ File output = new File(filename);
+
+ if (!output.isAbsolute())
+ {
+ // Interpret relative file path relative to build directory
+ output = new File(buildDirectory, filename);
+ }
+ getLog().debug("Output file: " + output.getPath());
+
+ // Ensure that directory path for specified file exists
+ File outFileParentDir = output.getParentFile();
+ if (null != outFileParentDir && !outFileParentDir.exists())
+ {
+ try
+ {
+ getLog().info(
+ "Creating directory path for output file:" +
+ outFileParentDir.getPath()
+ );
+ outFileParentDir.mkdirs();
+ }
+ catch (Exception e)
+ {
+ String error =
+ "Error creating directory path for output file: " + e.getMessage();
+ getLog().error(error);
+ throw new MojoExecutionException(error);
+ }
+ }
+
+ try
+ {
+ output.createNewFile();
+ }
+ catch (IOException e)
+ {
+ String error = "Error creating output file: " + e.getMessage();
+ getLog().error(error);
+ throw new MojoExecutionException(error);
+ }
+
+ if (!output.canWrite())
+ {
+ String error =
+ "Output file " + output.getAbsolutePath() + " is not writable!";
+ getLog().error(error);
+ throw new MojoExecutionException(error);
+ }
+
+ return output;