diff --git a/documentation/src/main/asciidoc/userguide/chapters/tooling/extras/maven-example.pom b/documentation/src/main/asciidoc/userguide/chapters/tooling/extras/maven-example.pom index 35f3166a37df..ac9824eadd14 100644 --- a/documentation/src/main/asciidoc/userguide/chapters/tooling/extras/maven-example.pom +++ b/documentation/src/main/asciidoc/userguide/chapters/tooling/extras/maven-example.pom @@ -2,16 +2,14 @@ [...] - org.hibernate.orm.tooling - hibernate-enhance-maven-plugin + org.hibernate.orm + hibernate-maven-plugin $currentHibernateVersion - true true true - true enhance diff --git a/documentation/src/main/asciidoc/userguide/chapters/tooling/maven.adoc b/documentation/src/main/asciidoc/userguide/chapters/tooling/maven.adoc index 3dc4d31f5e78..b2586cabfe58 100644 --- a/documentation/src/main/asciidoc/userguide/chapters/tooling/maven.adoc +++ b/documentation/src/main/asciidoc/userguide/chapters/tooling/maven.adoc @@ -9,8 +9,14 @@ The following sections illustrate how both <> for details -on the configuration settings. By default, all enhancements are disabled. +on the configuration settings. +[[maven-enhance-goal]] +===== *Enhance Goal* ===== + +An example of using the `enhance` goal of the plugin is shown below. In this case the plugin will +perform bytecode enhancement for lazy initialization and dirty tracking. See <> +for more details on the available parameters. .Apply the Bytecode Enhancement plugin ==== @@ -20,6 +26,138 @@ include::extras/maven-example.pom[] ---- ==== +[[maven-enhance-configuration]] +===== *Enhance Configuration* ===== + +[[maven-enhance-classesDirectory-parameter]] +====== `*classesDirectory*` ====== +This parameter points to the folder in which to look for classes to enhance. +It defaults to the value of `{project.build.directory}/classes` and thus in most cases to `target/classes`. +If both `classesDirectory` and <> are set, +`fileSets` takes precedence. + +==== +[source,xml] +---- +[...] + + + path-to-some-folder + + [...] + +[...] +---- +==== + +[[maven-enhance-filesets-parameter]] +====== `*fileSets*` ====== +This optional parameter comes in handy when you need to filter the classes that you want to enhance. +More information on how to use filesets is to be found on the +https://maven.apache.org/shared/file-management/fileset.html[fileset documentation page]. +If both <> and `fileSets` are set, +`fileSets` takes precedence. + +==== +[source,xml] +---- +[...] + + + + + + + + + [...] + +[...] +---- +==== + +[[maven-enhance-enableLazyInitialization-parameter]] +===== `*enableLazyInitialization*` ===== +This parameter has a default value of `false`. It indicates whether the enhance goal should perform the changes +to enable <>. +The parameter has been deprecated for removal. After this removal, <> +will always be enabled. + +==== +[source,xml] +---- +[...] + + + true + + [...] + +[...] +---- +==== + +[[maven-enhance-enableDirtyTracking-parameter]] +===== `*enableDirtyTracking*` ===== +This parameter has a default value of `false`. It indicates whether the enhance task should perform the changes +to enable <>. +The parameter has been deprecated for removal. After this removal, <> +will always be enabled. + +==== +[source,xml] +---- +[...] + + + true + + [...] + +[...] +---- +==== + +[[maven-enhance-enableAssociationManagement-parameter]] +===== `*enableAssociationManagement*` ===== +This parameter has a default value of `false`. It indicates whether the enhance task should perform the changes +to enable <>. + +==== +[source,xml] +---- +[...] + + + true + + [...] + +[...] +---- +==== + +[[maven-enhance-enableExtendedEnhancement-paremeter]] +===== `*enableExtendedEnhancement*` ===== +This parameter has a default value of `false`. It indicates whether the enhance task should perform the changes +to enable the extended enhancement: enhancement of non-entities to trigger lazy-loading and inline dirty tracking +even when accessing entity fields directly.. + +==== +[source,xml] +---- +[...] + + + true + + [...] + +[...] +---- +==== + + [[tooling-maven-modelgen]] ==== Static Metamodel Generation diff --git a/migration-guide.adoc b/migration-guide.adoc index 96f4813c666a..3c1ba2bd9792 100644 --- a/migration-guide.adoc +++ b/migration-guide.adoc @@ -789,3 +789,33 @@ We recommend using https://github.com/agroal/agroal[Agroal] or https://github.co Alternatively, you may implement the `ConnectionProvider` interface to integrate the connection pool of your choice. In fact, some connection pools already include their own implementations of `ConnectionProvider`. +[[maven-plugin-changes]] +== Changes to the Maven Plugin + +The Maven bytecode enhancement plugin has been completely rewritten since version 7.0. The change that has the +biggest consequence is that the artifactId and groupId of the Maven artifact have changed. As of now, you will +need to include the plugin in the build section in your Maven pom file as illustrated below. + +``` + + org.hibernate.orm + hibernate-maven-plugin + $currentHibernateVersion + + + + true + true + + + enhance + + + + +``` + +Also, because of a regression and in contrast with the corresponding Ant task and Gradle plugin, the default values +of the `enableLazyInitialization` and `enableDirtyTracking` are set to `false` while it used to be `true`. This is fixed in Hibernate ORM 7.1. + +The documentation in the userguide has been rewritten accordingly and completed with more examples. diff --git a/tooling/hibernate-maven-plugin/src/main/java/org/hibernate/orm/tooling/maven/HibernateEnhancerMojo.java b/tooling/hibernate-maven-plugin/src/main/java/org/hibernate/orm/tooling/maven/HibernateEnhancerMojo.java index 061af2c34be0..9fe345305b33 100644 --- a/tooling/hibernate-maven-plugin/src/main/java/org/hibernate/orm/tooling/maven/HibernateEnhancerMojo.java +++ b/tooling/hibernate-maven-plugin/src/main/java/org/hibernate/orm/tooling/maven/HibernateEnhancerMojo.java @@ -33,29 +33,51 @@ public class HibernateEnhancerMojo extends AbstractMojo { final private List sourceSet = new ArrayList(); private Enhancer enhancer; + /** + * A list of FileSets in which to look for classes to enhance. + * This parameter is optional but if it is specified, the 'classesDirectory' parameter is ignored. + */ @Parameter private FileSet[] fileSets; + /** + * The folder in which to look for classes to enhance. + * This parameter is required but if the 'fileSets' parameter is specified, it will be ignored. + */ @Parameter( defaultValue = "${project.build.directory}/classes", required = true) private File classesDirectory; + /** + * A boolean that indicates whether or not to add association management to automatically + * synchronize a bidirectional association when only one side is changed + */ @Parameter( defaultValue = "false", required = true) private boolean enableAssociationManagement; + /** + * A boolean that indicates whether or not to add dirty tracking + */ @Parameter( defaultValue = "false", required = true) private boolean enableDirtyTracking; + /** + * A boolean that indicates whether or not to add lazy initialization + */ @Parameter( defaultValue = "false", required = true) private boolean enableLazyInitialization; + /** + * A boolean that indicates whether or not to add extended enhancement. + * This setting will provide bytecode enhancement, even for non-entity classes + */ @Parameter( defaultValue = "false", required = true)