161 lines
4.7 KiB
Groovy
161 lines
4.7 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.gradle.plugin-publish' version '1.2.1'
|
|
|
|
id 'checkstyle'
|
|
|
|
// for local publishing
|
|
id 'maven-publish'
|
|
}
|
|
|
|
apply from: rootProject.file( 'gradle/module.gradle' )
|
|
apply from: rootProject.file( 'gradle/javadoc.gradle' )
|
|
apply from: rootProject.file( 'gradle/releasable.gradle' )
|
|
|
|
description = "Gradle plugin for integrating Hibernate aspects into your build"
|
|
|
|
dependencies {
|
|
implementation project(':hibernate-core')
|
|
implementation libs.byteBuddy
|
|
implementation jakartaLibs.jaxbApi
|
|
|
|
implementation gradleApi()
|
|
implementation localGroovy()
|
|
|
|
// for Gradle
|
|
implementation jakartaLibs.inject
|
|
implementation localGroovy()
|
|
|
|
testImplementation gradleTestKit()
|
|
testImplementation testLibs.assertjCore
|
|
testImplementation testLibs.junit5Api
|
|
|
|
testRuntimeOnly testLibs.junit5Engine
|
|
}
|
|
|
|
gradlePlugin {
|
|
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'
|
|
|
|
plugins {
|
|
ormPlugin {
|
|
id = "org.hibernate.orm"
|
|
implementationClass = "org.hibernate.orm.tooling.gradle.HibernateOrmPlugin"
|
|
displayName = 'Gradle plugin for Hibernate ORM'
|
|
description = 'Applies Hibernate aspects into the build'
|
|
tags = ['hibernate','orm','bytecode','enhancement','bytebuddy']
|
|
}
|
|
}
|
|
}
|
|
|
|
tasks.withType(AbstractArchiveTask).configureEach {
|
|
preserveFileTimestamps = false
|
|
reproducibleFileOrder = true
|
|
}
|
|
|
|
test {
|
|
useJUnitPlatform()
|
|
if ( project.hasProperty( 'excludeTests' ) ) {
|
|
exclude project.property( 'excludeTests' )
|
|
}
|
|
}
|
|
|
|
// Publish to the Gradle Plugin Portal
|
|
tasks.release.dependsOn tasks.publishPlugins
|
|
|
|
// local publishing (SNAPSHOT testing)
|
|
tasks.publish.dependsOn tasks.publishPlugins
|
|
|
|
// 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
|
|
|
|
// local publishing (SNAPSHOT testing)
|
|
publishing {
|
|
repositories {
|
|
maven {
|
|
name = 'localPluginRepository'
|
|
url = "${buildDir}/local-plugin-repository"
|
|
}
|
|
}
|
|
}
|
|
|
|
// 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" ) {
|
|
logger.debug( "Disabling task `{}` because it publishes to Sonatype", t.path )
|
|
t.enabled = false
|
|
}
|
|
}
|
|
}
|
|
|
|
processResources {
|
|
inputs.property( "orm-version", getVersion() )
|
|
description = description + " (injected with Hibernate version)"
|
|
filter( ReplaceTokens, tokens: [ 'hibernateVersion': getVersion() ] )
|
|
}
|
|
|
|
tasks.withType( JavaCompile ) {
|
|
options.encoding = 'UTF-8'
|
|
}
|
|
|
|
if ( !jdkVersions.explicit ) {
|
|
tasks.withType( GroovyCompile ) {
|
|
sourceCompatibility = JavaVersion.toVersion( jdkVersions.baseline )
|
|
targetCompatibility = JavaVersion.toVersion( jdkVersions.baseline )
|
|
}
|
|
}
|
|
else {
|
|
logger.warn( "[WARN] Toolchains are not yet supported for Groovy compilation." +
|
|
" Using the JDK that runs Gradle for Groovy compilation." )
|
|
}
|
|
|
|
tasks.named( "javadoc", Javadoc ) {
|
|
configure( options ) {
|
|
windowTitle = "Hibernate Javadocs ($project.name)"
|
|
docTitle = "Hibernate Javadocs ($project.name : $project.version)"
|
|
}
|
|
}
|
|
|
|
checkstyle {
|
|
sourceSets = [ project.sourceSets.main ]
|
|
configFile = rootProject.file( 'shared/config/checkstyle/checkstyle.xml' )
|
|
showViolations = false
|
|
}
|
|
|
|
tasks.publish.enabled !project.ormVersion.isSnapshot
|
|
tasks.publishPlugins.enabled !project.ormVersion.isSnapshot
|
|
|
|
gradle.taskGraph.whenReady { tg ->
|
|
if ( tg.hasTask( project.tasks.publishPlugins ) && project.tasks.publishPlugins.enabled ) {
|
|
// look for sys-prop or env-var overrides of the tokens used for publishing
|
|
if ( project.properties.containsKey( 'gradle.publish.key' )
|
|
|| project.properties.containsKey( 'gradle.publish.secret' ) ) {
|
|
// nothing to do - already explicitly set
|
|
}
|
|
else {
|
|
// use the values from the credentials provider, if any
|
|
if ( project.property( 'gradle.publish.key' ) == null ) {
|
|
throw new RuntimeException( "`-Pgradle.publish.key=...` not found" )
|
|
}
|
|
if ( project.property( 'gradle.publish.secret' ) == null ) {
|
|
throw new RuntimeException( "`-Pgradle.publish.secret=...` not found" )
|
|
}
|
|
}
|
|
}
|
|
}
|