Hibernate enhance gradle plugin for Kotlin

Hi all, please, is it possible to use Hibernate enhance gradle plugin for Kotlin project? When I use Spring Boot (2.7.0) and Hibernate (5.6.9.Final) it does nothing with entities.

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

// enable via Task
tasks.withType<org.hibernate.orm.tooling.gradle.EnhanceTask>().configureEach {
    options.enableLazyInitialization = true
    options.enableDirtyTracking = true
    options.enableAssociationManagement = true
}

// or via DSL
hibernate {
    enhance(closureOf<org.hibernate.orm.tooling.gradle.EnhanceExtension> {
        enableLazyInitialization = true
        enableDirtyTracking = true
        enableAssociationManagement = true
        enableExtendedEnhancement = false
    })
}

When I’m trying it with Hibernate 6

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

hibernate {
	enhancement {
		lazyInitialization(true)
		dirtyTracking(true)
		associationManagement(true)
		extendedEnhancement(false)
	}
}

there is an issue

* What went wrong:
A problem was found with the configuration of task ':hibernateEnhance' (type 'EnhancementTask').
  - In plugin 'org.hibernate.orm' type 'org.hibernate.orm.tooling.gradle.enhance.EnhancementTask' property 'javaCompileDirectory' specifies directory 'C:\Users\user\www\project-name\build\classes\java\main' which doesn't exist.

I would like to use Hibernate 5.6.9.Final as Spring Boot supports it, but in the first scenario no enhancement found in classes (/build/classes/kotlin…). Am I missing something, or Kotlin is not supported? Thank you for answer

I have never tried it with Kotlin projects. Create a Jira please and I will work on a test for the test suite

I created Jira task [HHH-15314] - Hibernate JIRA and also I created test case GitHub - matejschwartz/hibernate-gradle-plugin-test: Test case for hibernate enhancement gradle plugin in Kotlin. Thank you

1 Like