2020-10-15 18:20:30 -04:00
|
|
|
import org.apache.tools.ant.filters.ReplaceTokens
|
|
|
|
|
2015-05-19 00:23:35 -04:00
|
|
|
/*
|
|
|
|
* 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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
|
|
|
*/
|
2020-04-06 13:21:11 -04:00
|
|
|
|
2020-10-15 18:20:30 -04:00
|
|
|
plugins {
|
|
|
|
id 'java-gradle-plugin'
|
2021-10-11 15:53:10 -04:00
|
|
|
id 'com.gradle.plugin-publish' version '0.16.0'
|
2020-10-15 18:20:30 -04:00
|
|
|
|
2021-06-26 09:46:09 -04:00
|
|
|
id 'com.github.sebersole.testkit-junit5' version '1.2.0'
|
2020-10-15 18:20:30 -04:00
|
|
|
}
|
|
|
|
|
2021-05-18 15:55:00 -04:00
|
|
|
apply from: rootProject.file( 'gradle/java-module.gradle' )
|
2020-10-15 18:20:30 -04:00
|
|
|
|
2021-05-14 18:31:28 -04:00
|
|
|
description = "Gradle plugin for integrating Hibernate aspects into your build"
|
2020-04-06 13:21:11 -04:00
|
|
|
|
2020-10-15 18:20:30 -04:00
|
|
|
ext {
|
|
|
|
pluginId = 'org.hibernate.orm'
|
|
|
|
pluginVersion = project.version
|
|
|
|
}
|
2018-01-10 16:06:58 -05:00
|
|
|
|
2013-06-26 03:45:14 -04:00
|
|
|
dependencies {
|
2021-05-14 18:31:28 -04:00
|
|
|
implementation project( ':hibernate-core' )
|
|
|
|
implementation libraries.byteBuddy
|
2021-05-14 15:59:59 -04:00
|
|
|
implementation gradleApi()
|
2021-09-22 18:52:06 -04:00
|
|
|
// for Gradle
|
2021-09-27 08:09:29 -04:00
|
|
|
implementation libraries.jakarta_inject
|
2021-05-14 15:59:59 -04:00
|
|
|
implementation localGroovy()
|
2020-10-15 18:20:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
gradlePlugin {
|
|
|
|
plugins {
|
|
|
|
ormPlugin {
|
|
|
|
id = project.pluginId
|
|
|
|
implementationClass = 'org.hibernate.orm.tooling.gradle.HibernateOrmPlugin'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pluginBundle {
|
2021-03-22 07:38:00 -04:00
|
|
|
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'
|
2020-10-15 18:20:30 -04:00
|
|
|
tags = ['hibernate','orm','bytecode','enhancement','bytebuddy']
|
|
|
|
|
2021-08-05 09:26:19 -04:00
|
|
|
// sigh
|
|
|
|
mavenCoordinates {
|
|
|
|
groupId = project.group.toString()
|
|
|
|
artifactId = project.name
|
|
|
|
version = project.version.toString()
|
|
|
|
}
|
|
|
|
|
2020-10-15 18:20:30 -04:00
|
|
|
plugins {
|
|
|
|
ormPlugin {
|
|
|
|
id = project.pluginId
|
|
|
|
displayName = 'Gradle plugin for Hibernate ORM'
|
|
|
|
description = 'Applies Hibernate aspects into the build'
|
|
|
|
}
|
|
|
|
}
|
2013-12-02 21:53:19 -05:00
|
|
|
}
|
2020-07-17 07:04:56 -04:00
|
|
|
|
2021-07-01 22:15:55 -04:00
|
|
|
task publish {
|
|
|
|
dependsOn tasks.publishPlugins
|
|
|
|
}
|
|
|
|
|
2020-10-15 18:20:30 -04:00
|
|
|
processResources {
|
|
|
|
filter( ReplaceTokens, tokens: [ 'hibernateVersion': getVersion() ] )
|
2020-07-17 07:04:56 -04:00
|
|
|
}
|
2020-10-15 18:20:30 -04:00
|
|
|
|
|
|
|
|
2020-07-17 07:04:56 -04:00
|
|
|
tasks.withType( GroovyCompile ) {
|
|
|
|
options.encoding = 'UTF-8'
|
2020-11-09 04:13:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
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." +
|
2020-11-17 06:40:43 -05:00
|
|
|
" Using the JDK that runs Gradle for Groovy compilation." )
|
2020-07-17 07:04:56 -04:00
|
|
|
}
|
2020-11-17 06:40:43 -05:00
|
|
|
|
2020-12-14 08:11:00 -05:00
|
|
|
tasks.test {
|
2021-11-26 11:24:34 -05:00
|
|
|
// Needs add-opens because Gradle uses illegal accesses to inject... mocks? Something like that.
|
|
|
|
jvmArgs( ['--add-opens', 'java.base/java.lang=ALL-UNNAMED'] )
|
2020-12-14 08:11:00 -05:00
|
|
|
}
|
2021-05-18 15:58:16 -04:00
|
|
|
|
2021-05-18 17:03:34 -04:00
|
|
|
task release {
|
|
|
|
dependsOn tasks.publishPlugins
|
|
|
|
}
|
|
|
|
|
2021-07-01 22:15:55 -04:00
|
|
|
afterEvaluate {
|
|
|
|
if ( project.ormVersion.isSnapshot ) {
|
|
|
|
release.enabled false
|
|
|
|
publish.enabled false
|
|
|
|
publishPlugins.enabled false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-18 15:58:16 -04:00
|
|
|
gradle.taskGraph.whenReady { tg ->
|
2021-08-04 13:08:17 -04:00
|
|
|
if ( tg.hasTask( project.tasks.publishPlugins ) && project.tasks.publishPlugins.enabled ) {
|
2021-08-04 12:17:25 -04:00
|
|
|
// look for sys-prop or env-var overrides of the tokens used for publishing
|
|
|
|
if ( System.properties.containsKey( 'gradle.publish.key' )
|
|
|
|
|| System.properties.containsKey( 'gradle.publish.secret' )
|
|
|
|
|| System.getenv().containsKey( 'GRADLE_PUBLISH_KEY' )
|
|
|
|
|| System.getenv().containsKey( 'GRADLE_PUBLISH_SECRET' ) ) {
|
|
|
|
// nothing to do - already explicitly set
|
2021-05-18 15:58:16 -04:00
|
|
|
}
|
2021-08-04 12:17:25 -04:00
|
|
|
else {
|
|
|
|
// use the values from the credentials provider, if any
|
|
|
|
if ( credentials.hibernatePluginPortalUsername == null ) {
|
|
|
|
throw new RuntimeException( "`hibernatePluginPortalUsername` not found" )
|
|
|
|
}
|
|
|
|
if ( credentials.hibernatePluginPortalPassword == null ) {
|
|
|
|
throw new RuntimeException( "`hibernatePluginPortalPassword` not found" )
|
|
|
|
}
|
|
|
|
System.setProperty( 'gradle.publish.key', credentials.hibernatePluginPortalUsername )
|
|
|
|
System.setProperty( 'gradle.publish.secret', credentials.hibernatePluginPortalPassword )
|
2021-05-18 15:58:16 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|