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

143 lines
3.6 KiB
Groovy

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'
id 'com.github.sebersole.testkit-junit5' version '1.0.1'
// for portal publishing
id "com.gradle.plugin-publish" version "0.12.0"
id "nu.studer.credentials" version "2.1"
// for publishing snapshots
id 'maven-publish'
id 'org.hibernate.build.maven-repo-auth'
id 'idea'
id 'eclipse'
}
description = "Gradle plugin for integrating Hibernate aspects into your build"
apply from: rootProject.file( 'gradle/base-information.gradle' )
apply from: rootProject.file( 'gradle/libraries.gradle' )
apply from: rootProject.file( 'gradle/javadoc.gradle' )
ext {
pluginId = 'org.hibernate.orm'
pluginVersion = project.version
//noinspection GrUnresolvedAccess
publishKey = credentials.'hibernate.gradle.publish.key'
//noinspection GrUnresolvedAccess
publishSecret = credentials.'hibernate.gradle.publish.secret'
if ( publishKey != null && publishSecret != null ) {
project.'gradle.publish.key' = publishKey
project.'gradle.publish.secret' = publishSecret
}
}
dependencies {
implementation( project( ':hibernate-core' ) )
implementation project( ':hibernate-testing' )
implementation( libraries.jpa )
implementation( libraries.javassist )
implementation( libraries.byteBuddy )
}
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() ] )
}
task release
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 {
if ( project.'gradle.publish.key' == null ) {
throw new RuntimeException( "`gradle.publish.key` not found" )
}
if ( project.'gradle.publish.secret' == null ) {
throw new RuntimeException( "`gradle.publish.secret` not found" )
}
}
}
// for SNAPSHOT version
publishing {
publications {
plugin( MavenPublication ) {
from components.java
}
}
repositories {
maven {
name 'jboss-snapshots-repository'
url 'https://repository.jboss.org/nexus/content/repositories/snapshots'
}
}
}
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'] )
}
}