From: Kai Moritz Date: Tue, 28 Oct 2014 22:37:45 +0000 (+0100) Subject: Explained how to suppress dependency-scanning in documentation X-Git-Tag: hibernate4-maven-plugin-1.0.5~4 X-Git-Url: https://juplo.de/gitweb/?p=hibernate4-maven-plugin;a=commitdiff_plain;h=473c3ef285c19e0f0b85643b67bbd77e06c0b926;ds=sidebyside Explained how to suppress dependency-scanning in documentation Also added a test-case to be sure, that dependency-scanning is skipped, if the parameter "dependencyScanning" is set to "none". --- diff --git a/src/it/ignored-dependency/ignored/pom.xml b/src/it/ignored-dependency/ignored/pom.xml new file mode 100644 index 00000000..28e8ab9b --- /dev/null +++ b/src/it/ignored-dependency/ignored/pom.xml @@ -0,0 +1,22 @@ + + + + 4.0.0 + de.juplo + ignored + 1 + + + + org.hibernate + hibernate-core + 4.3.5.Final + + + + + 1.7 + 1.7 + + + diff --git a/src/it/ignored-dependency/ignored/src/main/java/ignored/IgnoredEntity.java b/src/it/ignored-dependency/ignored/src/main/java/ignored/IgnoredEntity.java new file mode 100644 index 00000000..afb73c38 --- /dev/null +++ b/src/it/ignored-dependency/ignored/src/main/java/ignored/IgnoredEntity.java @@ -0,0 +1,15 @@ +package ignored; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +@Entity +public class IgnoredEntity +{ + @Id + @GeneratedValue + Long id; + + String name; +} diff --git a/src/it/ignored-dependency/main/pom.xml b/src/it/ignored-dependency/main/pom.xml new file mode 100644 index 00000000..d198fc9b --- /dev/null +++ b/src/it/ignored-dependency/main/pom.xml @@ -0,0 +1,53 @@ + + + + 4.0.0 + de.juplo + main + 1 + jar + main + + + + org.hibernate + hibernate-core + 4.3.5.Final + + + de.juplo + ignored + 1 + + + + + 1.7 + 1.7 + + + + + + de.juplo + hibernate4-maven-plugin + @project.version@ + + + + export + + + + + NONE + true + CREATE + org.hibernate.dialect.PostgreSQL9Dialect + none + + + + + + diff --git a/src/it/ignored-dependency/main/src/main/java/main/MainEntity.java b/src/it/ignored-dependency/main/src/main/java/main/MainEntity.java new file mode 100644 index 00000000..a86f8096 --- /dev/null +++ b/src/it/ignored-dependency/main/src/main/java/main/MainEntity.java @@ -0,0 +1,19 @@ +package main; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Transient; + +import ignored.IgnoredEntity; + +@Entity +public class MainEntity +{ + @Id + @GeneratedValue + long id; + + @Transient + IgnoredEntity ignoredEntity; +} diff --git a/src/it/ignored-dependency/main/src/main/resources/META-INF/persistence.xml b/src/it/ignored-dependency/main/src/main/resources/META-INF/persistence.xml new file mode 100644 index 00000000..a419eda9 --- /dev/null +++ b/src/it/ignored-dependency/main/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,17 @@ + + + + java:jboss/datasources/PostgreSQLDS + + dependent.DependentEntity + + + + + + + diff --git a/src/it/ignored-dependency/pom.xml b/src/it/ignored-dependency/pom.xml new file mode 100644 index 00000000..27dd2990 --- /dev/null +++ b/src/it/ignored-dependency/pom.xml @@ -0,0 +1,16 @@ + + + + 4.0.0 + de.juplo + ignored-dependency + Hibernate 4 Maven Plugin - Ignored Dependen Test + 1 + pom + + + ignored + main + + + diff --git a/src/it/ignored-dependency/schema.sql b/src/it/ignored-dependency/schema.sql new file mode 100644 index 00000000..510de4f2 --- /dev/null +++ b/src/it/ignored-dependency/schema.sql @@ -0,0 +1,7 @@ + + create table MainEntity ( + id int8 not null, + primary key (id) + ); + + create sequence hibernate_sequence; diff --git a/src/it/ignored-dependency/verify.bsh b/src/it/ignored-dependency/verify.bsh new file mode 100644 index 00000000..47470ce6 --- /dev/null +++ b/src/it/ignored-dependency/verify.bsh @@ -0,0 +1,7 @@ +import de.juplo.test.FileComparator; + + +FileComparator comparator = new FileComparator(basedir); + +if (!comparator.isEqual("schema.sql","main/target/schema.sql")) + return false; diff --git a/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java b/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java index fa4ce6a0..85ae5182 100644 --- a/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java +++ b/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java @@ -143,6 +143,9 @@ public class Hbm2DdlMojo extends AbstractMojo * 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. diff --git a/src/site/xhtml/pitfalls.xhtml b/src/site/xhtml/pitfalls.xhtml index 50006953..90e09241 100644 --- a/src/site/xhtml/pitfalls.xhtml +++ b/src/site/xhtml/pitfalls.xhtml @@ -151,7 +151,7 @@ mvn hibernate4:export -Dhibernate.export.force=true executed, you can configure that explicitly like this:

->plugin<
+<plugin>
   <groupId>de.juplo</groupId>
   <artifactId>hibernate4-maven-plugin</artifactId>
   ...
@@ -163,5 +163,21 @@ mvn hibernate4:export -Dhibernate.export.force=true
Background-information for this design-decission can be found on the extra page To skip or not to skip: that is the question...

+

I do not want my dependencies to be scanned for hibernate annotations

+

+ If you do not want your dependencies to be scanned for hibernate annotations, + you can pass -Dhibernate.export.scan_dependencies=none to maven + or set scanDependencies to none in the configuration + of the plugin like this: +

+
+<plugin>
+  <groupId>de.juplo</groupId>
+  <artifactId>hibernate4-maven-plugin</artifactId>
+  ...
+  <configuration>
+    <scanDependencies>none</scanDependencies>
+  </configuration>
+</plugin>