hibernate-orm/tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle

128 lines
3.4 KiB
Groovy
Raw Normal View History

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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
plugins {
id 'java-gradle-plugin'
2021-05-14 18:31:28 -04:00
id 'com.gradle.plugin-publish' version '0.14.0'
2021-05-14 18:31:28 -04:00
id 'com.github.sebersole.testkit-junit5' version '1.0.1'
}
2021-05-18 15:55:00 -04:00
apply from: rootProject.file( 'gradle/java-module.gradle' )
2021-05-14 18:31:28 -04:00
description = "Gradle plugin for integrating Hibernate aspects into your build"
ext {
pluginId = 'org.hibernate.orm'
pluginVersion = project.version
2021-05-14 18:31:28 -04:00
// look for command-line overrides of the username/password pairs for publishing
if ( project.hasProperty( 'hibernatePluginPortalUsername' ) ) {
credentials.hibernatePluginPortalUsername = project.property( 'hibernatePluginPortalUsername' )
}
if ( project.hasProperty( 'hibernatePluginPortalPassword' ) ) {
credentials.hibernatePluginPortalPassword = project.property( 'hibernatePluginPortalPassword' )
}
}
dependencies {
2021-05-14 18:31:28 -04:00
// compileOnly project( ':hibernate-core' )
//
// implementation gradleApi()
// implementation localGroovy()
//
// testRuntimeOnly project( ':hibernate-core' ) {
// }
2021-05-14 18:31:28 -04:00
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'
}
}
2013-12-02 21:53:19 -05:00
}
processResources {
filter( ReplaceTokens, tokens: [ 'hibernateVersion': getVersion() ] )
}
if ( project.version.toString().endsWith( '-SNAPSHOT' ) ) {
tasks.publishPlugins.enabled = false
tasks.release.dependsOn tasks.publish
}
else {
tasks.publish.enabled = false
tasks.release.dependsOn( tasks.publishPlugins )
}
tasks.publishPlugins {
doFirst {
2021-05-14 17:47:30 -04:00
if ( credentials.hibernatePluginPortalUsername == null ) {
throw new RuntimeException( "`hibernatePluginPortalUsername` not found" )
}
2021-05-14 17:47:30 -04:00
if ( credentials.hibernatePluginPortalPassword == null ) {
throw new RuntimeException( "`hibernatePluginPortalPassword` not found" )
}
}
}
publishing {
publications {
plugin( MavenPublication ) {
from components.java
}
}
}
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." +
2020-11-17 06:40:43 -05:00
" Using the JDK that runs Gradle for Groovy compilation." )
}
2020-11-17 06:40:43 -05:00
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'] )
}
}