X-Git-Url: https://juplo.de/gitweb/?p=hibernate4-maven-plugin;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fde%2Fjuplo%2Fplugins%2Fhibernate4%2FHbm2DdlMojo.java;h=18351f079b01668619fd831366821834109145d9;hp=97901818c999810dfe0b508871e9e2dae81348e8;hb=727d1a35bb213589270b097d04d5a1f480bffef6;hpb=eeb182205a51c4507e61e1862af184341e65dbd3 diff --git a/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java b/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java index 97901818..18351f07 100644 --- a/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java +++ b/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java @@ -875,9 +875,34 @@ public class Hbm2DdlMojo extends AbstractMojo } SchemaExport export = new SchemaExport(config, connection); - export.setOutputFile(outputFile); export.setDelimiter(delimiter); export.setFormat(format); + + File outF = new File(outputFile); + + if (!outF.isAbsolute()) + { + // Interpret relative file path relative to build directory + outF = new File(buildDirectory, outputFile); + getLog().info("Adjusted relative path, resulting path is " + outF.getPath()); + } + + // Ensure that directory path for specified file exists + File outFileParentDir = outF.getParentFile(); + if (null != outFileParentDir && !outFileParentDir.exists()) + { + try + { + getLog().info("Creating directory path for output file:" + outFileParentDir.getPath()); + outFileParentDir.mkdirs(); + } + catch (Exception e) + { + getLog().error("Error creating directory path for output file: " + e.getLocalizedMessage()); + } + } + + export.setOutputFile(outF.getPath()); export.execute(target, type); for (Object exception : export.getExceptions())