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'
|
2022-03-15 21:10:17 -04:00
|
|
|
id 'com.gradle.plugin-publish' version '0.20.0'
|
2020-10-15 18:20:30 -04:00
|
|
|
|
2022-03-15 21:10:17 -04:00
|
|
|
id 'checkstyle'
|
2022-04-12 18:47:04 -04:00
|
|
|
|
|
|
|
// for local publishing
|
|
|
|
id 'maven-publish'
|
2020-10-15 18:20:30 -04:00
|
|
|
}
|
|
|
|
|
2022-03-15 21:10:17 -04:00
|
|
|
apply from: rootProject.file( 'gradle/module.gradle' )
|
|
|
|
apply from: rootProject.file( 'gradle/javadoc.gradle' )
|
2022-03-15 13:15:56 -04:00
|
|
|
apply from: rootProject.file( 'gradle/releasable.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 {
|
2022-05-09 20:33:30 -04:00
|
|
|
implementation project(':hibernate-core')
|
2022-04-22 19:40:06 -04:00
|
|
|
implementation libs.byteBuddy
|
2022-05-09 20:33:30 -04:00
|
|
|
implementation jakartaLibs.jaxbApi
|
|
|
|
|
2021-05-14 15:59:59 -04:00
|
|
|
implementation gradleApi()
|
2022-05-09 20:33:30 -04:00
|
|
|
implementation localGroovy()
|
|
|
|
|
2021-09-22 18:52:06 -04:00
|
|
|
// for Gradle
|
2022-04-22 19:40:06 -04:00
|
|
|
implementation jakartaLibs.inject
|
2021-05-14 15:59:59 -04:00
|
|
|
implementation localGroovy()
|
2022-06-06 21:22:20 -04:00
|
|
|
|
|
|
|
testImplementation gradleTestKit()
|
|
|
|
testImplementation testLibs.assertjCore
|
|
|
|
testImplementation testLibs.junit5Api
|
|
|
|
|
|
|
|
testRuntimeOnly testLibs.junit5Engine
|
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
|
|
|
|
2022-06-06 21:22:20 -04:00
|
|
|
test {
|
|
|
|
useJUnitPlatform()
|
2024-04-19 07:34:46 -04:00
|
|
|
if ( project.hasProperty( 'excludeTests' ) ) {
|
|
|
|
exclude project.property( 'excludeTests' )
|
|
|
|
}
|
2022-06-06 21:22:20 -04:00
|
|
|
}
|
|
|
|
|
2022-04-12 18:47:04 -04:00
|
|
|
// Publish to the Gradle Plugin Portal
|
|
|
|
tasks.release.dependsOn tasks.publishPlugins
|
|
|
|
|
|
|
|
// local publishing (SNAPSHOT testing)
|
|
|
|
tasks.publish.dependsOn tasks.publishPlugins
|
|
|
|
|
2022-09-23 04:56:58 -04:00
|
|
|
// Make sure that the publishReleaseArtifacts task of the release module runs the release task of this sub module
|
|
|
|
tasks.getByPath( ':release:publishReleaseArtifacts' ).dependsOn tasks.release
|
|
|
|
|
2022-04-12 18:47:04 -04:00
|
|
|
// local publishing (SNAPSHOT testing)
|
|
|
|
publishing {
|
|
|
|
repositories {
|
|
|
|
maven {
|
|
|
|
name = 'localPluginRepository'
|
|
|
|
url = "${buildDir}/local-plugin-repository"
|
|
|
|
}
|
|
|
|
}
|
2022-03-15 21:10:17 -04:00
|
|
|
}
|
2022-04-12 18:47:04 -04:00
|
|
|
|
|
|
|
// local publishing (SNAPSHOT testing), cont.
|
|
|
|
// - https://github.com/gradle-nexus/publish-plugin/issues/143
|
|
|
|
// - https://github.com/gradle-nexus/publish-plugin/pull/144
|
|
|
|
gradle.taskGraph.whenReady {
|
|
|
|
tasks.withType(PublishToMavenRepository) { PublishToMavenRepository t ->
|
|
|
|
if ( t.repository == null ) {
|
|
|
|
logger.info( "Task `{}` had null repository", t.path )
|
|
|
|
}
|
|
|
|
else if ( t.repository.name == "sonatype" ) {
|
2022-05-11 21:36:48 -04:00
|
|
|
logger.debug( "Disabling task `{}` because it publishes to Sonatype", t.path )
|
2022-04-12 18:47:04 -04:00
|
|
|
t.enabled = false
|
|
|
|
}
|
|
|
|
}
|
2021-07-01 22:15:55 -04:00
|
|
|
}
|
|
|
|
|
2020-10-15 18:20:30 -04:00
|
|
|
processResources {
|
2022-04-07 14:52:09 -04:00
|
|
|
inputs.property( "orm-version", getVersion() )
|
2022-04-12 18:47:04 -04:00
|
|
|
description = description + " (injected with Hibernate version)"
|
2020-10-15 18:20:30 -04:00
|
|
|
filter( ReplaceTokens, tokens: [ 'hibernateVersion': getVersion() ] )
|
2020-07-17 07:04:56 -04:00
|
|
|
}
|
2020-10-15 18:20:30 -04:00
|
|
|
|
2022-04-07 14:52:09 -04:00
|
|
|
tasks.withType( JavaCompile ) {
|
2020-07-17 07:04:56 -04:00
|
|
|
options.encoding = 'UTF-8'
|
2020-11-09 04:13:34 -05:00
|
|
|
}
|
|
|
|
|
2023-08-07 21:05:47 -04:00
|
|
|
if ( !jdkVersions.explicit ) {
|
2020-11-09 04:13:34 -05:00
|
|
|
tasks.withType( GroovyCompile ) {
|
2023-08-15 13:35:08 -04:00
|
|
|
sourceCompatibility = JavaVersion.toVersion( jdkVersions.baseline )
|
|
|
|
targetCompatibility = JavaVersion.toVersion( jdkVersions.baseline )
|
2020-11-09 04:13:34 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
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
|
|
|
|
2023-08-29 14:19:06 -04:00
|
|
|
tasks.named( "javadoc", Javadoc ) {
|
|
|
|
configure( options ) {
|
|
|
|
windowTitle = "Hibernate Javadocs ($project.name)"
|
|
|
|
docTitle = "Hibernate Javadocs ($project.name : $project.version)"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-15 21:10:17 -04:00
|
|
|
checkstyle {
|
|
|
|
sourceSets = [ project.sourceSets.main ]
|
|
|
|
configFile = rootProject.file( 'shared/config/checkstyle/checkstyle.xml' )
|
|
|
|
showViolations = false
|
2020-12-14 08:11:00 -05:00
|
|
|
}
|
2021-05-18 15:58:16 -04:00
|
|
|
|
2022-08-30 12:20:24 -04:00
|
|
|
tasks.publish.enabled !project.ormVersion.isSnapshot
|
|
|
|
tasks.publishPlugins.enabled !project.ormVersion.isSnapshot
|
2021-07-01 22:15:55 -04:00
|
|
|
|
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
|
2022-09-23 04:56:58 -04:00
|
|
|
if ( project.properties.containsKey( 'gradle.publish.key' )
|
|
|
|
|| project.properties.containsKey( 'gradle.publish.secret' ) ) {
|
2021-08-04 12:17:25 -04:00
|
|
|
// 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
|
2022-11-28 02:29:03 -05:00
|
|
|
if ( project.property( 'gradle.publish.key' ) == null ) {
|
|
|
|
throw new RuntimeException( "`-Pgradle.publish.key=...` not found" )
|
2021-08-04 12:17:25 -04:00
|
|
|
}
|
2022-11-28 02:29:03 -05:00
|
|
|
if ( project.property( 'gradle.publish.secret' ) == null ) {
|
|
|
|
throw new RuntimeException( "`-Pgradle.publish.secret=...` not found" )
|
2021-08-04 12:17:25 -04:00
|
|
|
}
|
2021-05-18 15:58:16 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|