Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,11 @@
<plugins>
[...]
<plugin>
<groupId>org.hibernate.orm.tooling</groupId>
<artifactId>hibernate-enhance-maven-plugin</artifactId>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-maven-plugin</artifactId>
<version>$currentHibernateVersion</version>
<executions>
<execution>
<configuration>
<failOnError>true</failOnError>
<enableLazyInitialization>true</enableLazyInitialization>
<enableDirtyTracking>true</enableDirtyTracking>
<enableAssociationManagement>true</enableAssociationManagement>
</configuration>
<goals>
<goal>enhance</goal>
</goals>
Expand Down
140 changes: 139 additions & 1 deletion documentation/src/main/asciidoc/userguide/chapters/tooling/maven.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ The following sections illustrate how both <<tooling-maven-enhancement,bytecode
Hibernate provides a https://maven.apache.org/[Maven] plugin capable of providing
build-time enhancement of the domain model as they are compiled as part of a Maven
build. See the section on <<BytecodeEnhancement>> 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. By default the plugin will
perform bytecode enhancement for lazy initialization and dirty tracking. See <<maven-enhance-configuration, below>>
for more details on the available parameters.

.Apply the Bytecode Enhancement plugin
====
Expand All @@ -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 <<maven-enhance-filesets-parameter,fileSets>> are set,
`fileSets` takes precedence.

====
[source,xml]
----
[...]
<execution>
<configuration>
<classesDirectory>path-to-some-folder</classesDirectory>
</configuration>
[...]
</execution>
[...]
----
====

[[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 <<maven-enhance-classesDirectory-parameter, classesDirectory>> and `fileSets` are set,
`fileSets` takes precedence.

====
[source,xml]
----
[...]
<execution>
<configuration>
<fileSets>
<fileset dir="path-to-some-folder">
<exclude name='Baz.class' />
</fileset>
</fileSets>
</configuration>
[...]
</execution>
[...]
----
====

[[maven-enhance-enableLazyInitialization-parameter]]
===== `*enableLazyInitialization*` =====
This parameter has a default value of `true`. It indicates whether the enhance goal should perform the changes
to enable <<BytecodeEnhancement-lazy-loading,lazy loading>>.
The parameter has been deprecated for removal. After this removal, <<BytecodeEnhancement-lazy-loading,lazy loading>>
will always be enabled.

====
[source,xml]
----
[...]
<execution>
<configuration>
<enableLazyInitialization>false</enableLazyInitialization>
</configuration>
[...]
</execution>
[...]
----
====

[[maven-enhance-enableDirtyTracking-parameter]]
===== `*enableDirtyTracking*` =====
This parameter has a default value of `true`. It indicates whether the enhance task should perform the changes
to enable <<BytecodeEnhancement-dirty-tracking,dirty tracking>>.
The parameter has been deprecated for removal. After this removal, <<BytecodeEnhancement-dirty-tracking,dirty tracking>>
will always be enabled.

====
[source,xml]
----
[...]
<execution>
<configuration>
<enableDirtyTracking>false</enableDirtyTracking>
</configuration>
[...]
</execution>
[...]
----
====

[[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 <<BytecodeEnhancement-dirty-tracking-bidirectional,association management>>.

====
[source,xml]
----
[...]
<execution>
<configuration>
<enableAssociationManagement>true</enableAssociationManagement>
</configuration>
[...]
</execution>
[...]
----
====

[[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]
----
[...]
<execution>
<configuration>
<enableExtendedEnhancement>true</enableExtendedEnhancement>
</configuration>
[...]
</execution>
[...]
----
====


[[tooling-maven-modelgen]]
==== Static Metamodel Generation

Expand Down
27 changes: 27 additions & 0 deletions migration-guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,30 @@ This section describes changes to dependencies used by Hibernate ORM.
=== Inclusion of Agroal Pool

`agroal-pool` is now a transitive implementation (runtime) dependency of the `hibernate-agroal` module. Applications using `hibernate-agroal` no longer need to manually depend on it.

[[maven-plugin-changes]]
== Changes to the Maven Plugin

Because of a regression the `enableLazyInitialization` and `enableDirtyTracking` parameters of
the Maven plugin had since version 7.0.0.Final a default value of `false` while it used to be `true`.
To fix the regression and bring the defaults in line with the corresponding Ant task and Gradle
plugin, the default versions for both these parameters are set to `true` starting with version
7.1.4.Final. The configuration of the enhancement plugin is now simplified in comparison to
previous versions.

```
<plugin>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-maven-plugin</artifactId>
<version>$currentHibernateVersion</version>
<executions>
<execution>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
```

The documentation in the userguide has been rewritten accordingly.
47 changes: 45 additions & 2 deletions tooling/hibernate-maven-plugin/hibernate-maven-plugin.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,34 @@ plugins {

description = 'Maven plugin to integrate aspects of Hibernate into your build.'

sourceSets {
intTest {
compileClasspath += sourceSets.main.output
runtimeClasspath += sourceSets.main.output
}
}

configurations {
intTestImplementation.extendsFrom implementation
intTestRuntimeOnly.extendsFrom runtimeOnly
}

dependencies {
implementation project( ":hibernate-core" )

implementation "org.apache.maven:maven-plugin-api:3.6.3"
implementation "org.apache.maven:maven-plugin-api:3.9.11"
implementation "org.apache.maven:maven-project:2.2.1"
implementation "org.apache.maven.shared:file-management:3.1.0"

compileOnly "org.apache.maven.plugin-tools:maven-plugin-annotations:3.6.0"
compileOnly "org.apache.maven.plugin-tools:maven-plugin-tools-annotations:3.15.1"

intTestImplementation 'org.junit.jupiter:junit-jupiter:5.13.4'
intTestImplementation 'org.apache.maven:maven-embedder:3.9.11'
intTestRuntimeOnly 'org.junit.platform:junit-platform-launcher'
intTestRuntimeOnly 'ch.qos.logback:logback-classic:1.5.18'
intTestRuntimeOnly 'org.apache.maven:maven-compat:3.9.11'
intTestRuntimeOnly 'org.apache.maven.resolver:maven-resolver-transport-http:1.9.24'
intTestRuntimeOnly 'org.apache.maven.resolver:maven-resolver-connector-basic:1.9.24'
}

def releasePrepareTask = tasks.register("releasePrepare") {
Expand All @@ -37,6 +57,22 @@ tasks.register("preVerifyRelease") {
dependsOn releasePrepareTask
}

tasks.register('integrationTest', Test) {
description = 'Runs integration tests.'
group = 'verification'

testClassesDirs = sourceSets.intTest.output.classesDirs
classpath = sourceSets.intTest.runtimeClasspath
shouldRunAfter test

useJUnitPlatform()

}

tasks.forbiddenApisIntTest {
enabled = false
}

var publishingExtension = project.getExtensions().getByType(PublishingExtension) as PublishingExtension
publishingExtension.publications.named("publishedArtifacts") {
from components.java
Expand Down Expand Up @@ -64,3 +100,10 @@ publishingExtension.publications.named("publishedArtifacts") {
}
}

integrationTest {
environment "hibernateVersion", project.version
}

integrationTest.dependsOn rootProject.childProjects.'hibernate-core'.tasks.publishToMavenLocal
integrationTest.dependsOn publishToMavenLocal
check.dependsOn integrationTest
Loading
Loading