X-Git-Url: https://juplo.de/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fde%2Fjuplo%2Fplugins%2Fhibernate4%2FHbm2DdlMojo.java;h=85ae5182d1187a1d0223df9b07ef532718a2ba00;hb=473c3ef285c19e0f0b85643b67bbd77e06c0b926;hp=f9912536b76ffb7810c841bbb1815da49d89743c;hpb=2b1147d5e99c764c1f6816f4d4f000abe260097c;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 f9912536..85ae5182 100644
--- a/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java
+++ b/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java
@@ -47,17 +47,19 @@ 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.AuditConfiguration;
+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;
@@ -85,7 +87,10 @@ public class Hbm2DdlMojo extends AbstractMojo
public final static String NAMING_STRATEGY="hibernate.ejb.naming_strategy";
public final static String ENVERS = "hibernate.export.envers";
- private final static String MD5S = "schema.md5s";
+ public final static String MD5S = "hibernate4-generatedschema.md5s";
+
+ private final static Pattern split = Pattern.compile("[^,\\s]+");
+
/**
* The maven project.
@@ -113,22 +118,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.
*
@@ -139,6 +165,7 @@ public class Hbm2DdlMojo extends AbstractMojo
* to true!
*
* @parameter property="project.build.testOutputDirectory"
+ * @since 1.0.2
*/
private String testOutputDirectory;
@@ -147,13 +174,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="hibernate.export.skip" default-value="false"
+ * @parameter property="hibernate.skip" default-value="${maven.test.skip}"
+ * @since 1.0
*/
private boolean skip;
@@ -166,6 +194,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;
@@ -173,6 +202,7 @@ public class Hbm2DdlMojo extends AbstractMojo
* SQL-Driver name.
*
* @parameter property="hibernate.connection.driver_class"
+ * @since 1.0
*/
private String driverClassName;
@@ -180,6 +210,7 @@ public class Hbm2DdlMojo extends AbstractMojo
* Database URL.
*
* @parameter property="hibernate.connection.url"
+ * @since 1.0
*/
private String url;
@@ -187,6 +218,7 @@ public class Hbm2DdlMojo extends AbstractMojo
* Database username
*
* @parameter property="hibernate.connection.username"
+ * @since 1.0
*/
private String username;
@@ -194,6 +226,7 @@ public class Hbm2DdlMojo extends AbstractMojo
* Database password
*
* @parameter property="hibernate.connection.password"
+ * @since 1.0
*/
private String password;
@@ -201,12 +234,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"
+ * @since 1.0.2
*/
private String hibernateNamingStrategy;
@@ -214,6 +250,7 @@ public class Hbm2DdlMojo extends AbstractMojo
* Path to Hibernate configuration file.
*
* @parameter default-value="${project.build.outputDirectory}/hibernate.properties"
+ * @since 1.0
*/
private String hibernateProperties;
@@ -222,22 +259,24 @@ public class Hbm2DdlMojo extends AbstractMojo
* Multiple files can be separated with white-spaces and/or commas.
*
* @parameter property="hibernate.mapping"
+ * @since 1.0.2
*/
private String hibernateMapping;
/**
* Target of execution:
*
- *
NONE only export schema to SQL-script (forces excecution, signals skip)