import org.apache.tools.ant.filters.ReplaceTokens /* * Hibernate, Relational Persistence for Idiomatic Java * * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ plugins { id 'java-gradle-plugin' id 'com.gradle.plugin-publish' version '0.14.0' id 'com.github.sebersole.testkit-junit5' version '1.0.1' } apply from: rootProject.file( 'gradle/java-module.gradle' ) description = "Gradle plugin for integrating Hibernate aspects into your build" ext { pluginId = 'org.hibernate.orm' pluginVersion = project.version // look for command-line overrides of the username/password pairs for publishing if ( project.hasProperty( 'hibernatePluginPortalUsername' ) ) { if ( ! project.hasProperty( 'hibernatePluginPortalPassword' ) ) { throw new GradleException( "Should specify both `hibernatePluginPortalUsername` and `hibernatePluginPortalPassword` as project properties" ); } credentials.hibernatePluginPortalUsername = project.property( 'hibernatePluginPortalUsername' ) credentials.hibernatePluginPortalPassword = project.property( 'hibernatePluginPortalPassword' ) } else if ( System.properties.hibernatePluginPortalUsername != null ) { if ( System.properties.hibernatePluginPortalPassword == null ) { throw new GradleException( "Should specify both `hibernatePluginPortalUsername` and `hibernatePluginPortalPassword` as system properties" ); } credentials.hibernatePluginPortalUsername = System.properties.hibernatePluginPortalUsername credentials.hibernatePluginPortalPassword = System.properties.hibernatePluginPortalPassword } } dependencies { // compileOnly project( ':hibernate-core' ) // // implementation gradleApi() // implementation localGroovy() // // testRuntimeOnly project( ':hibernate-core' ) { // } implementation project( ':hibernate-core' ) implementation libraries.jpa implementation libraries.javassist implementation libraries.byteBuddy implementation gradleApi() implementation localGroovy() } gradlePlugin { plugins { ormPlugin { id = project.pluginId implementationClass = 'org.hibernate.orm.tooling.gradle.HibernateOrmPlugin' } } } pluginBundle { website = 'https://github.com/hibernate/hibernate-orm/tree/main/tooling/hibernate-gradle-plugin' vcsUrl = 'https://github.com/hibernate/hibernate-orm/tree/main/tooling/hibernate-gradle-plugin' tags = ['hibernate','orm','bytecode','enhancement','bytebuddy'] plugins { ormPlugin { id = project.pluginId displayName = 'Gradle plugin for Hibernate ORM' description = 'Applies Hibernate aspects into the build' } } } processResources { filter( ReplaceTokens, tokens: [ 'hibernateVersion': getVersion() ] ) } tasks.withType( GroovyCompile ) { options.encoding = 'UTF-8' } if ( !gradle.ext.javaToolchainEnabled ) { tasks.withType( GroovyCompile ) { sourceCompatibility = JavaVersion.toVersion( gradle.ext.baselineJavaVersion ) targetCompatibility = JavaVersion.toVersion( gradle.ext.baselineJavaVersion ) } } else { logger.warn( "[WARN] Toolchains are not yet supported for Groovy compilation." + " Using the JDK that runs Gradle for Groovy compilation." ) } tasks.test { if ( gradle.ext.javaVersions.test.launcher.asInt() >= 9 ) { // Needs add-opens because Gradle uses illegal accesses to inject... mocks? Something like that. jvmArgs( ['--add-opens', 'java.base/java.lang=ALL-UNNAMED'] ) } } task release { dependsOn tasks.publishPlugins } gradle.taskGraph.whenReady { tg -> if ( tg.hasTask( project.tasks.publishPlugins ) ) { if ( credentials.hibernatePluginPortalUsername == null ) { throw new RuntimeException( "`hibernatePluginPortalUsername` not found" ) } if ( credentials.hibernatePluginPortalPassword == null ) { throw new RuntimeException( "`hibernatePluginPortalPassword` not found" ) } } }