0

I am really struggeling to get the bytecode enhancement via the hibernate gradle plugin to run. Especially as no examples I can find are written in Kotlin DSL, which we are using on the project. The relevant parts of the build.gradle.kts look as follows:

plugins {
    id("org.hibernate.orm") version "5.4.8.Final"
}

val hibernateGradlePluginVersion = "5.4.8.Final"

tasks.withType<org.hibernate.orm.tooling.gradle.EnhanceTask>{
    options.enableLazyInitialization = true  // This is what I actually need!
}

dependencies {
    compile("org.hibernate:hibernate-gradle-plugin:$hibernateGradlePluginVersion")
}

Also I added this to me settings.gradle.kts:

resolutionStrategy {
    eachPlugin {
        if (requested.id.id == "org.hibernate.orm") {
            useModule("org.hibernate:hibernate-gradle-plugin:${requested.version}")
        }
    }
}

If I run 'build' in debug mode, the breakpoint where the LazyIntialization is set to true is never reached. Therefore, I assume that the hibernate plugin never executes its tasks. Any advice where my mistake might be?

Best regards!

G.Brown
  • 214
  • 2
  • 12

1 Answers1

0

Thanks to @Bernhard Kern, I got the answer. There was still a block missing:

hibernate {
    enhance(closureOf<org.hibernate.orm.tooling.gradle.EnhanceExtension> {
        enableLazyInitialization = true
    })
}
G.Brown
  • 214
  • 2
  • 12