How to configure Hibernate Gradle plugin to improve bytecode?

Hibernation Gradle plugin is equivalent hibernate-enhance-maven-pluginand offers improvements to build-time code. Official docs don't mention the line apply plugin: 'something'. If I just do as the guide says, I get:

Could not find hibernate () method for arguments ...

I tried to guess the plugin name using apply plugin: 'enhance'(as this thread suggests ) and apply plugin: 'org.hibernate.orm'(as this test ), but it just says that the plugin with this identifier is unknown.

Has anyone been able to install this plugin successfully?

My build.gradle looks like this:

allprojects {
    group 'xxx'
    version '1.0-SNAPSHOT'
}

subprojects {
    apply plugin: 'java'

    sourceCompatibility = 1.8

    repositories {
        mavenLocal()
        mavenCentral()
    }

    dependencies {
        ...
    }
}

project(':xxx-model') {
    buildscript {
       repositories {
           mavenLocal()
           mavenCentral()
       }
       dependencies {
           classpath "org.hibernate:hibernate-gradle-plugin:5.0.7.Final"
       }
    }

    apply plugin: 'org.hibernate.orm'

    hibernate {
        enhance {}
    }
}

... more unrelated project blocks here

He experimented with moving buildscript{...}to the root, allprojectsand subprojectswithout any useful results.

+3
3
apply plugin: 'org.hibernate.orm'

, . , , - repositories buildScript, .

+2

( 5.1) - - . - , , Gradle Gradle;) , , , , ( Jira ).

id org.hibernate.orm, :

apply: 'org.hibernate.orm'
+4

:

apply plugin: 'java'

repositories {
    mavenLocal()
    mavenCentral()
}

buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
    }
    dependencies {
        classpath "org.hibernate:hibernate-gradle-plugin:5.1.0.Final"
    }
}

apply plugin: 'org.hibernate.orm'

hibernate {
    enhance {
        enableLazyInitialization= true
        enableDirtyTracking = true
        enableAssociationManagement = true
    }
}

dependencies {
    compile 'org.hibernate:hibernate-core:5.1.0.Final'
}
+3

Source: https://habr.com/ru/post/1694244/


All Articles