Apply hibernate-gradle-plugin using plugins dsl syntax?

徘徊边缘 提交于 2020-02-04 13:27:46

问题


I want to use org.hibernate:hibernate-gradle-plugin in my project with plugins dsl style. This is my build.gradle.kts plugin section:

plugins {
    kotlin("jvm") version "1.3.31"
    id("io.spring.dependency-management") version "1.0.6.RELEASE"
    id("org.springframework.boot") version "2.1.5.RELEASE"
    id("org.jetbrains.kotlin.plugin.spring") version "1.3.31"
    id("org.jetbrains.kotlin.plugin.jpa") version "1.3.31"
}

Does anybody knows how to do this?

All of the documentation and posts are using the legacy plugin application. Like this: How to setup Hibernate Gradle plugin for bytecode enhancement?


回答1:


It looks like they haven't registered this plugin in the Gradle Plugins Repository which rules out using the newer DSL without using a custom plugin resolution strategy.

For your case in build.gradle.kts

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

And in settings.gradle.kts

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



回答2:


In addition to the perfectly working solution of @MarkRobbo you can use the following snippet to configure the options of the hibernate-gradle-plugin in build.gradle.kts

tasks.withType<org.hibernate.orm.tooling.gradle.EnhanceTask>().configureEach {
     options.enableLazyInitialization = true
}


来源:https://stackoverflow.com/questions/56441725/apply-hibernate-gradle-plugin-using-plugins-dsl-syntax

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!