X-Git-Url: https://juplo.de/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fde%2Fjuplo%2Fplugins%2Fhibernate4%2FHbm2DdlMojo.java;h=b85c601f1fa0e9392868189ae5e74a126a6a3665;hb=55dc25ac24b0e3edca26c9015ddd2fd31d3092e5;hp=36a5aca4b4d57058e500f3ff062556a60678bfe9;hpb=b6ac188a40136102edc51b6824875dfb07c89955;p=hibernate-maven-plugin
diff --git a/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java b/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java
index 36a5aca4..b85c601f 100644
--- a/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java
+++ b/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java
@@ -19,6 +19,7 @@ package de.juplo.plugins.hibernate4;
import com.pyx4j.log4j.MavenLogAppender;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -28,6 +29,7 @@ import java.math.BigInteger;
import java.net.URL;
import java.net.URLClassLoader;
import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
@@ -45,18 +47,20 @@ import java.util.Properties;
import java.util.Set;
import java.util.TreeSet;
import java.util.logging.Logger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.MappedSuperclass;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Resource;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
-import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.NamingStrategy;
+import org.hibernate.envers.configuration.spi.AuditConfiguration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
-import org.hibernate.tool.hbm2ddl.SchemaExport.Type;
-import org.hibernate.tool.hbm2ddl.Target;
import org.scannotation.AnnotationDB;
@@ -79,8 +83,12 @@ public class Hbm2DdlMojo extends AbstractMojo
public final static String PASSWORD = "hibernate.connection.password";
public final static String DIALECT = "hibernate.dialect";
public final static String NAMING_STRATEGY="hibernate.ejb.naming_strategy";
+ public final static String ENVERS = "hibernate.export.envers";
+
+ public final static String MD5S = "hibernate4-generatedschema.md5s";
+
+ private final static Pattern split = Pattern.compile("[^,\\s]+");
- private final static String MD5S = "schema.md5s";
/**
* The maven project.
@@ -108,22 +116,43 @@ public class Hbm2DdlMojo extends AbstractMojo
* Classes-Directory to scan.
*
* This parameter defaults to the maven build-output-directory for classes.
- * Additonally, all dependencies are scanned for annotated classes.
+ * Additionally, all dependencies are scanned for annotated classes.
*
* @parameter property="project.build.outputDirectory"
+ * @since 1.0
*/
private String outputDirectory;
/**
- * Wether to scan test-classes too, or not.
+ * Whether to scan test-classes too, or not.
*
* If this parameter is set to true the test-classes of the
* artifact will be scanned for hibernate-annotated classes additionally.
*
* @parameter property="hibernate.export.scan_testclasses" default-value="false"
+ * @since 1.0.1
*/
private boolean scanTestClasses;
+ /**
+ * Dependency-Scopes, that should be scanned for annotated classes.
+ *
+ * By default, only dependencies in the scope compile are
+ * scanned for annotated classes. Multiple scopes can be seperated by
+ * white space or commas.
+ *
+ * If you do not want any dependencies to be scanned for annotated
+ * classes, set this parameter to none.
+ *
+ * The plugin does not scan for annotated classes in transitive
+ * dependencies. If some of your annotated classes are hidden in a
+ * transitive dependency, you can simply add that dependency explicitly.
+ *
+ * @parameter property="hibernate.export.scan_dependencies" default-value="compile"
+ * @since 1.0.3
+ */
+ private String scanDependencies;
+
/**
* Test-Classes-Directory to scan.
*
@@ -134,6 +163,7 @@ public class Hbm2DdlMojo extends AbstractMojo
* to true!
*
* @parameter property="project.build.testOutputDirectory"
+ * @since 1.0.2
*/
private String testOutputDirectory;
@@ -142,13 +172,14 @@ public class Hbm2DdlMojo extends AbstractMojo
*
* If set to true, the execution is skipped.
*
- * A skipped excecution is signaled via the maven-property
+ * A skipped execution is signaled via the maven-property
* ${hibernate.export.skipped}.
*
- * The excecution is skipped automatically, if no modified or newly added
+ * The execution is skipped automatically, if no modified or newly added
* annotated classes are found and the dialect was not changed.
*
- * @parameter property="maven.test.skip" default-value="false"
+ * @parameter property="hibernate.skip" default-value="${maven.test.skip}"
+ * @since 1.0
*/
private boolean skip;
@@ -161,6 +192,7 @@ public class Hbm2DdlMojo extends AbstractMojo
* skip takes precedence over force.
*
* @parameter property="hibernate.export.force" default-value="false"
+ * @since 1.0
*/
private boolean force;
@@ -168,6 +200,7 @@ public class Hbm2DdlMojo extends AbstractMojo
* SQL-Driver name.
*
* @parameter property="hibernate.connection.driver_class"
+ * @since 1.0
*/
private String driverClassName;
@@ -175,6 +208,7 @@ public class Hbm2DdlMojo extends AbstractMojo
* Database URL.
*
* @parameter property="hibernate.connection.url"
+ * @since 1.0
*/
private String url;
@@ -182,6 +216,7 @@ public class Hbm2DdlMojo extends AbstractMojo
* Database username
*
* @parameter property="hibernate.connection.username"
+ * @since 1.0
*/
private String username;
@@ -189,6 +224,7 @@ public class Hbm2DdlMojo extends AbstractMojo
* Database password
*
* @parameter property="hibernate.connection.password"
+ * @since 1.0
*/
private String password;
@@ -196,13 +232,15 @@ public class Hbm2DdlMojo extends AbstractMojo
* Hibernate dialect.
*
* @parameter property="hibernate.dialect"
+ * @since 1.0
*/
private String hibernateDialect;
/**
* Hibernate Naming Strategy
+ *
* @parameter property="hibernate.ejb.naming_strategy"
- * @author nicus
+ * @since 1.0.2
*/
private String hibernateNamingStrategy;
@@ -210,39 +248,56 @@ public class Hbm2DdlMojo extends AbstractMojo
* Path to Hibernate configuration file.
*
* @parameter default-value="${project.build.outputDirectory}/hibernate.properties"
+ * @since 1.0
*/
private String hibernateProperties;
/**
- * Target of execution:
- *
- *
NONE do nothing - just validate the configuration (forces excecution, signals skip)