CPD
CPD Results
+The following document contains the results of PMD's CPD 5.2.3.
Duplications
+File | +Line |
---|---|
de/juplo/plugins/hibernate/CreateMojo.java | +35 |
de/juplo/plugins/hibernate/DropMojo.java | +35 |
+
+ public class CreateMojo extends AbstractSchemaMojo +{ + /** + * Output file. + * <p> + * If the specified filename is not absolut, the file will be created + * relative to the project build directory + * (<code>project.build.directory</code>). + * + * @parameter property="hibernate.schema.export.create" default-value="create.sql" + * @since 1.0 + */ + private String outputFile; + + + @Override + public final void execute() + throws + MojoFailureException, + MojoExecutionException + { + super.execute(outputFile); + } + + + @Override + void build(MetadataImplementor metadata) + throws + MojoExecutionException, + MojoFailureException + { + SchemaExport schemaExport = new SchemaExport(metadata, createNamespaces); + schemaExport.setDelimiter(delimiter); + schemaExport.setFormat(format); + + File output = new File(outputFile); + + if (!output.isAbsolute()) + { + // Interpret relative file path relative to build directory + output = new File(buildDirectory, outputFile); + getLog().debug("Adjusted relative path, resulting path is " + 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) + { + getLog().error("Error creating directory path for output file: " + e.getLocalizedMessage()); + } + } + + schemaExport.setOutputFile(output.getPath()); + schemaExport.execute(false, this.export, false, true); |