diff --git a/build.gradle b/build.gradle index 85a808b4f54f..cacd3c3d9eba 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,6 @@ buildscript { // } dependencies { - classpath 'org.hibernate.build.gradle:version-injection-plugin:1.0.0' // classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.7' classpath 'de.thetaphi:forbiddenapis:3.2' classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.1' @@ -21,6 +20,7 @@ buildscript { plugins { id 'org.hibernate.build.xjc-jakarta' version '1.0.2' apply false + id "org.hibernate.build.version-injection" version "2.0.0" apply false id 'org.hibernate.matrix-test' version '3.1.1' apply false id 'org.hibernate.orm.database-service' apply false id 'biz.aQute.bnd' version '6.3.1' apply false diff --git a/documentation/documentation.gradle b/documentation/documentation.gradle index d533dda3ab9f..01f2af5f828b 100644 --- a/documentation/documentation.gradle +++ b/documentation/documentation.gradle @@ -79,7 +79,10 @@ configurations { } javadocSources { - description = 'Source files to be built by the javadoc tool' + description = 'All Java sources for the aggregated Javadocs' + canBeConsumed = false + canBeResolved = true + visible = false } } diff --git a/gradle/group-relocation.gradle b/gradle/group-relocation.gradle new file mode 100644 index 000000000000..390c523d4623 --- /dev/null +++ b/gradle/group-relocation.gradle @@ -0,0 +1,19 @@ +/* + * SPDX-License-Identifier: LGPL-2.1-or-later + * Copyright Red Hat Inc. and Hibernate Authors + */ +var publishingExtension = project.getExtensions().getByType(PublishingExtension) as PublishingExtension +publishingExtension.publications.create("groupRelocation", MavenPublication) { + pom { + name = project.name + ' (relocated)' + groupId = 'org.hibernate' + + distributionManagement { + relocation { + groupId = project.group + artifactId = project.name + version = project.version + } + } + } +} \ No newline at end of file diff --git a/gradle/java-module.gradle b/gradle/java-module.gradle index 44cc7754fff2..29b4081d76be 100644 --- a/gradle/java-module.gradle +++ b/gradle/java-module.gradle @@ -143,21 +143,6 @@ dependencies { } } -configurations { - javadocSources { - canBeConsumed = true - canBeResolved = false - visible = false - description = 'Configuration for accessing the sources that should be included in the javadoc for the project' - } -} - -artifacts { - sourceSets.main.allJava.srcDirs.each { srcDir -> - javadocSources srcDir - } -} - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Compilation diff --git a/gradle/javadoc.gradle b/gradle/javadoc.gradle index 7c04b14386bf..959d3b251652 100644 --- a/gradle/javadoc.gradle +++ b/gradle/javadoc.gradle @@ -56,7 +56,7 @@ tasks.named( "javadoc", Javadoc ) { } } -task javadocJar(type: Jar) { +tasks.register("javadocJar", Jar) { from project.tasks.javadoc.outputs manifest { attributes( diff --git a/gradle/published-java-module.gradle b/gradle/published-java-module.gradle index bd0d4cf2e818..86209c10fae0 100644 --- a/gradle/published-java-module.gradle +++ b/gradle/published-java-module.gradle @@ -5,18 +5,20 @@ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -apply from: rootProject.file( 'gradle/releasable.gradle' ) apply from: rootProject.file( 'gradle/java-module.gradle' ) -apply from: rootProject.file( 'gradle/publishing-pom.gradle' ) +apply from: rootProject.file( 'gradle/publishing.gradle' ) -apply plugin: 'signing' - -// 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 +tasks.register("publishReleaseArtifacts") { + // mirror for `:release:publishReleaseArtifacts` + dependsOn tasks.release +} configurations { javadocSources { - description 'Used to aggregate javadocs for the whole project' + description = "All Java sources for the project's Javadoc" + canBeConsumed = true + canBeResolved = false + visible = false } } @@ -35,152 +37,16 @@ java { withSourcesJar() } -publishing { - publications { - // main publication - publishedArtifacts { - from components.java - } - - // relocation for the published artifacts based on the old groupId - relocationPom( MavenPublication ) { - pom { - name = project.name + ' - relocation' - groupId = 'org.hibernate' - artifactId = project.name - version = project.version - - description = project.description - url = 'https://hibernate.org/orm' - - organization { - name = 'Hibernate.org' - url = 'https://hibernate.org' - } - - licenses { - license { - name = 'GNU Library General Public License v2.1 or later' - url = 'https://www.opensource.org/licenses/LGPL-2.1' - comments = 'See discussion at https://hibernate.org/community/license/ for more details.' - distribution = 'repo' - } - } - - scm { - url = 'https://github.com/hibernate/hibernate-orm' - connection = 'scm:git:https://github.com/hibernate/hibernate-orm.git' - developerConnection = 'scm:git:git@github.com:hibernate/hibernate-orm.git' - } - - developers { - developer { - id = 'hibernate-team' - name = 'The Hibernate Development Team' - organization = 'Hibernate.org' - organizationUrl = 'https://hibernate.org' - } - } - - issueManagement { - system = 'jira' - url = 'https://hibernate.atlassian.net/browse/HHH' - } - - distributionManagement { - relocation { - groupId = 'org.hibernate.orm' - artifactId = project.name - version = project.version - } - } - } - } - } -} - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// Signing - -def signPublicationsTask = tasks.register('signPublications') { - description "Grouping task which executes all Sign tasks" - - dependsOn tasks.withType( Sign ) -} - -tasks.named( "publishPublishedArtifactsPublicationToSonatypeRepository" ) { - // publishing depends on signing - dependsOn signPublicationsTask -} - -tasks.register('sign') { - description "Pseudonym for :signPublications" - dependsOn signPublicationsTask -} - -var signingExtension = project.getExtensions().getByType(SigningExtension) as SigningExtension -signingExtension.sign publishing.publications.publishedArtifacts - -gradle.taskGraph.whenReady { TaskExecutionGraph graph -> - boolean wasSigningRequested = false - boolean wasPublishingRequested = false - - graph.allTasks.each {task -> - if ( task instanceof Sign ) { - wasSigningRequested = true - } - else if ( task instanceof PublishToMavenRepository ) { - wasPublishingRequested = true - } - } - - if ( wasPublishingRequested ) { - def ossrhUser = System.getenv().get( "ORG_GRADLE_PROJECT_sonatypeUsername" ) - def ossrhPass = System.getenv().get( "ORG_GRADLE_PROJECT_sonatypePassword" ) - if ( ossrhUser == null || ossrhPass == null ) { - throw new RuntimeException( "Cannot perform publishing to OSSRH without credentials." ) - } - logger.lifecycle "Publishing {} : {} : {}", project.group, project.name, project.version - } - - if ( wasSigningRequested || wasPublishingRequested ) { - // signing was explicitly requested and/or we are publishing to Sonatype OSSRH - // - we need the signing to happen - signingExtension.required = true - - var signingKey = resolveSigningKey() - var signingPassword = resolveSigningPassphrase() - signingExtension.useInMemoryPgpKeys( signingKey, signingPassword ) - } - else { - // signing was not explicitly requested and we are not publishing to OSSRH, - // - disable all Sign tasks - tasks.withType( Sign ).each { t-> t.enabled = false } - } -} - -static String resolveSigningKey() { - var key = System.getenv().get( "SIGNING_GPG_PRIVATE_KEY" ) - if ( key != null ) { - return key - } - - var keyFile = System.getenv().get( "SIGNING_GPG_PRIVATE_KEY_PATH" ) - if ( keyFile != null ) { - return new File( keyFile ).text - } +// Publishing - throw new RuntimeException( "Cannot perform signing without GPG details." ) +var publishingExtension = project.getExtensions().getByType(PublishingExtension) as PublishingExtension +publishingExtension.publications.named("publishedArtifacts", MavenPublication) { + // Add the Java component to the main publication + from components.java } -static String resolveSigningPassphrase() { - var passphrase = System.getenv().get( "SIGNING_GPG_PASSPHRASE" ) - if ( passphrase == null ) { - throw new RuntimeException( "Cannot perform signing without GPG details." ) - } - return passphrase -} // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -195,21 +61,6 @@ tasks.release.dependsOn tasks.test, tasks.publishToSonatype tasks.preVerifyRelease.dependsOn build tasks.preVerifyRelease.dependsOn generateMetadataFileForPublishedArtifactsPublication tasks.preVerifyRelease.dependsOn generatePomFileForPublishedArtifactsPublication -tasks.preVerifyRelease.dependsOn generatePomFileForRelocationPomPublication tasks.publishToSonatype.mustRunAfter test - -// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// Ancillary tasks - -task showPublications { - doFirst { - project.publishing.publications.each { publication -> - println "Publication (${publication.name}): ${publication.groupId}:${publication.artifactId}:${publication.version}" - publication.artifacts.each { artifact -> - println " > ${artifact}" - } - } - } -} \ No newline at end of file diff --git a/gradle/publishing-pom.gradle b/gradle/publishing-pom.gradle deleted file mode 100644 index 4654f0d873e1..000000000000 --- a/gradle/publishing-pom.gradle +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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 - */ - -apply plugin: 'maven-publish' - -// Disable Gradle module metadata publishing until we know what we want. -// https://docs.gradle.org/6.0.1/userguide/publishing_gradle_module_metadata.html#sub:disabling-gmm-publication -tasks.withType(GenerateModuleMetadata) { - enabled = false -} - -publishing { - publications { - publishedArtifacts( MavenPublication ) { - pom { - name = 'Hibernate ORM - ' + project.name - description = project.description - url = 'https://hibernate.org/orm' - - organization { - name = 'Hibernate.org' - url = 'https://hibernate.org' - } - - licenses { - license { - name = 'GNU Library General Public License v2.1 or later' - url = 'https://www.opensource.org/licenses/LGPL-2.1' - comments = 'See discussion at https://hibernate.org/community/license/ for more details.' - distribution = 'repo' - } - } - - scm { - url = 'https://github.com/hibernate/hibernate-orm' - connection = 'scm:git:https://github.com/hibernate/hibernate-orm.git' - developerConnection = 'scm:git:git@github.com:hibernate/hibernate-orm.git' - } - - issueManagement { - system = 'jira' - url = 'https://hibernate.atlassian.net/browse/HHH' - } - - developers { - developer { - id = 'hibernate-team' - name = 'The Hibernate Development Team' - organization = 'Hibernate.org' - organizationUrl = 'https://hibernate.org' - } - } - - } - - } - } - -} diff --git a/gradle/publishing.gradle b/gradle/publishing.gradle new file mode 100644 index 000000000000..2a46feddd17e --- /dev/null +++ b/gradle/publishing.gradle @@ -0,0 +1,173 @@ +/* + * SPDX-License-Identifier: LGPL-2.1-or-later + * Copyright Red Hat Inc. and Hibernate Authors + */ +apply plugin: 'maven-publish' +apply plugin: 'signing' + +apply from: rootProject.file( 'gradle/releasable.gradle' ) + +// Disable Gradle module metadata publishing until we know what we want. +// https://docs.gradle.org/6.0.1/userguide/publishing_gradle_module_metadata.html#sub:disabling-gmm-publication +tasks.withType(GenerateModuleMetadata).configureEach { + enabled = false +} + +var publishingExtension = project.getExtensions().getByType(PublishingExtension) as PublishingExtension + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Apply standard POM information for all publications + +publishingExtension.publications.configureEach { + pom { + url = 'https://hibernate.org/orm' + + organization { + name = 'Hibernate.org' + url = 'https://hibernate.org' + } + + licenses { + license { + name = 'GNU Library General Public License v2.1 or later' + url = 'https://www.opensource.org/licenses/LGPL-2.1' + comments = 'See discussion at https://hibernate.org/community/license/ for more details.' + distribution = 'repo' + } + } + + scm { + url = 'https://github.com/hibernate/hibernate-orm' + connection = 'scm:git:https://github.com/hibernate/hibernate-orm.git' + developerConnection = 'scm:git:git@github.com:hibernate/hibernate-orm.git' + } + + issueManagement { + system = 'jira' + url = 'https://hibernate.atlassian.net/browse/HHH' + } + + developers { + developer { + id = 'hibernate-team' + name = 'The Hibernate Development Team' + organization = 'Hibernate.org' + organizationUrl = 'https://hibernate.org' + } + } + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// register the "main" publication named `publishedArtifacts` + +publishingExtension.publications.create("publishedArtifacts", MavenPublication) { + pom { + name = 'Hibernate ORM - ' + project.name + description = project.description + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Create a special local repository used for local testing of PublishToMavenRepository + +if ( project.hasProperty("local_pub_repo") ) { + // used for + publishingExtension.repositories { + maven { + name = "localRepo" + url = rootProject.layout.buildDirectory.dir("maven-repo").get().asFile.toURI() + } + } +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Signing + +def signingKey = resolveSigningKey() +def signingPassphrase = resolveSigningPassphrase() + +var signingExtension = project.getExtensions().getByType(SigningExtension) as SigningExtension +signingExtension.sign publishingExtension.publications.publishedArtifacts +signingExtension.useInMemoryPgpKeys(signingKey, signingPassphrase) + +gradle.taskGraph.whenReady { TaskExecutionGraph graph -> + // are we publishing to OSSRH? + boolean wasPublishingRequested = false + + graph.allTasks.each {task -> + if ( task instanceof PublishToMavenRepository ) { + if ( "sonatype" == task.repository.name ) { + wasPublishingRequested = true + } + } + } + + if ( wasPublishingRequested ) { + def ossrhUser = System.getenv().get( "ORG_GRADLE_PROJECT_sonatypeUsername" ) + def ossrhPass = System.getenv().get( "ORG_GRADLE_PROJECT_sonatypePassword" ) + if ( ossrhUser == null || ossrhPass == null ) { + throw new RuntimeException( "Cannot perform publishing to OSSRH without credentials." ) + } + logger.lifecycle "Publishing {} : {} : {}", project.group, project.name, project.version + signingExtension.required = true + } + else if ( signingKey == null || signingPassphrase == null ) { + tasks.withType( Sign ).each { t-> t.enabled = false } + } +} + +static String resolveSigningKey() { + var key = System.getenv().get( "SIGNING_GPG_PRIVATE_KEY" ) + if ( key != null ) { + return key + } + + var keyFile = System.getenv().get( "SIGNING_GPG_PRIVATE_KEY_PATH" ) + if ( keyFile != null ) { + return new File( keyFile ).text + } + + return null +} + +static String resolveSigningPassphrase() { + return System.getenv().get( "SIGNING_GPG_PASSPHRASE" ) +} + + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Ancillary tasks + +tasks.register('showPublications') { + doFirst { + project.publishing.publications.each { publication -> + println "Publication (${publication.name}): ${publication.groupId}:${publication.artifactId}:${publication.version}" + publication.artifacts.each { artifact -> + println " > ${artifact}" + } + } + } +} + +tasks.withType(PublishToMavenLocal).configureEach { + doFirst { + logger.lifecycle("PublishToMavenLocal ({})", publication.name) + logger.lifecycle(" - {} : {} : {} ", publication.groupId, publication.artifactId, publication.pom.packaging) + logger.lifecycle(" - artifacts ({})...", publication.artifacts.size()) + publication.artifacts.forEach { + logger.lifecycle(" - artifact ({}) : {} ({})" , it.classifier, it.file, it.file.size()) + } + } +} + +tasks.withType(PublishToMavenRepository).configureEach { + doFirst { + logger.lifecycle("PublishToMavenRepository ({} : {})", publication.name, repository.name) + logger.lifecycle(" - {} : {} : {} ", publication.groupId, publication.artifactId, publication.pom.packaging) + logger.lifecycle(" - artifacts ({})...", publication.artifacts.size()) + publication.artifacts.forEach { + logger.lifecycle(" - artifact ({}) : {} ({})" , it.classifier, it.file, it.file.size()) + } + } +} \ No newline at end of file diff --git a/gradle/releasable.gradle b/gradle/releasable.gradle index eb5052d02db7..5ceb774c436f 100644 --- a/gradle/releasable.gradle +++ b/gradle/releasable.gradle @@ -1,10 +1,10 @@ apply from: rootProject.file( 'gradle/base-information.gradle' ) -task release { +tasks.register('release') { mustRunAfter ':release:releaseChecks' enabled !project.ormVersion.isSnapshot } -task preVerifyRelease { +tasks.register('preVerifyRelease') { dependsOn ':release:preVerifyRelease' } diff --git a/hibernate-agroal/hibernate-agroal.gradle b/hibernate-agroal/hibernate-agroal.gradle index 54ae8107dea3..69071f20acdc 100644 --- a/hibernate-agroal/hibernate-agroal.gradle +++ b/hibernate-agroal/hibernate-agroal.gradle @@ -8,6 +8,7 @@ description = 'Integration for Agroal as a ConnectionProvider for Hibernate ORM' apply from: rootProject.file( 'gradle/published-java-module.gradle' ) +apply from: rootProject.file( 'gradle/group-relocation.gradle' ) dependencies { implementation project( ':hibernate-core' ) diff --git a/hibernate-c3p0/hibernate-c3p0.gradle b/hibernate-c3p0/hibernate-c3p0.gradle index b5bce3e18853..a029995037ae 100644 --- a/hibernate-c3p0/hibernate-c3p0.gradle +++ b/hibernate-c3p0/hibernate-c3p0.gradle @@ -8,6 +8,7 @@ description = 'Integration for c3p0 Connection pooling into Hibernate ORM' apply from: rootProject.file( 'gradle/published-java-module.gradle' ) +apply from: rootProject.file( 'gradle/group-relocation.gradle' ) dependencies { implementation project( ':hibernate-core' ) diff --git a/hibernate-community-dialects/hibernate-community-dialects.gradle b/hibernate-community-dialects/hibernate-community-dialects.gradle index aa5b903582ff..7e19a78ceb20 100644 --- a/hibernate-community-dialects/hibernate-community-dialects.gradle +++ b/hibernate-community-dialects/hibernate-community-dialects.gradle @@ -8,6 +8,7 @@ description = 'Hibernate\'s community supported dialects' apply from: rootProject.file( 'gradle/published-java-module.gradle' ) +apply from: rootProject.file( 'gradle/group-relocation.gradle' ) dependencies { api project( ':hibernate-core' ) diff --git a/hibernate-core/hibernate-core.gradle b/hibernate-core/hibernate-core.gradle index 2d81078036a9..d769338c4009 100644 --- a/hibernate-core/hibernate-core.gradle +++ b/hibernate-core/hibernate-core.gradle @@ -17,6 +17,8 @@ repositories { description = 'Hibernate\'s core ORM functionality' apply from: rootProject.file( 'gradle/published-java-module.gradle' ) +apply from: rootProject.file( 'gradle/group-relocation.gradle' ) + apply plugin: 'org.hibernate.orm.antlr' apply plugin: 'org.hibernate.matrix-test' diff --git a/hibernate-envers/hibernate-envers.gradle b/hibernate-envers/hibernate-envers.gradle index f309f313ce69..31f0cb81aaa9 100644 --- a/hibernate-envers/hibernate-envers.gradle +++ b/hibernate-envers/hibernate-envers.gradle @@ -8,6 +8,8 @@ description = 'Hibernate\'s entity version (audit/history) support' apply from: rootProject.file( 'gradle/published-java-module.gradle' ) +apply from: rootProject.file( 'gradle/group-relocation.gradle' ) + apply plugin: 'org.hibernate.matrix-test' dependencies { diff --git a/hibernate-graalvm/hibernate-graalvm.gradle b/hibernate-graalvm/hibernate-graalvm.gradle index 628488a6c654..6468315b7e65 100644 --- a/hibernate-graalvm/hibernate-graalvm.gradle +++ b/hibernate-graalvm/hibernate-graalvm.gradle @@ -8,6 +8,7 @@ description = "Experimental extension to make it easier to compile applications into a GraalVM native image" apply from: rootProject.file( 'gradle/published-java-module.gradle' ) +apply from: rootProject.file( 'gradle/group-relocation.gradle' ) dependencies { //No need for transitive dependencies: this is all just metadata to be used as companion jar. diff --git a/hibernate-hikaricp/hibernate-hikaricp.gradle b/hibernate-hikaricp/hibernate-hikaricp.gradle index 0729d5cf8815..76f6b28ae19d 100644 --- a/hibernate-hikaricp/hibernate-hikaricp.gradle +++ b/hibernate-hikaricp/hibernate-hikaricp.gradle @@ -8,6 +8,7 @@ description = 'Integration for HikariCP into Hibernate O/RM' apply from: rootProject.file( 'gradle/published-java-module.gradle' ) +apply from: rootProject.file( 'gradle/group-relocation.gradle' ) dependencies { implementation project( ':hibernate-core' ) diff --git a/hibernate-jcache/hibernate-jcache.gradle b/hibernate-jcache/hibernate-jcache.gradle index 1aa17a8ac251..d58dd2de3d0c 100644 --- a/hibernate-jcache/hibernate-jcache.gradle +++ b/hibernate-jcache/hibernate-jcache.gradle @@ -1,6 +1,7 @@ description = 'Integration for javax.cache into Hibernate as a second-level caching service' apply from: rootProject.file( 'gradle/published-java-module.gradle' ) +apply from: rootProject.file( 'gradle/group-relocation.gradle' ) dependencies { api project( ':hibernate-core' ) diff --git a/hibernate-micrometer/hibernate-micrometer.gradle b/hibernate-micrometer/hibernate-micrometer.gradle index 1e331ad421da..66c8ef7e88fa 100644 --- a/hibernate-micrometer/hibernate-micrometer.gradle +++ b/hibernate-micrometer/hibernate-micrometer.gradle @@ -1,6 +1,7 @@ description = 'Integration for Micrometer metrics into Hibernate as a metrics collection package' apply from: rootProject.file( 'gradle/published-java-module.gradle' ) +apply from: rootProject.file( 'gradle/group-relocation.gradle' ) dependencies { implementation project( ':hibernate-core' ) diff --git a/hibernate-platform/hibernate-platform.gradle b/hibernate-platform/hibernate-platform.gradle index 46cd490f6f57..64ce72435bc8 100644 --- a/hibernate-platform/hibernate-platform.gradle +++ b/hibernate-platform/hibernate-platform.gradle @@ -2,13 +2,10 @@ plugins { id 'java-platform' } -description = 'Gradle platform for Hibernate ORM' +description = 'Platform (BOM) for Hibernate ORM dependencies' -apply from: rootProject.file( 'gradle/releasable.gradle' ) apply from: rootProject.file( "gradle/base-information.gradle" ) -apply from: rootProject.file( "gradle/publishing-pom.gradle" ) - -apply plugin: 'signing' +apply from: rootProject.file( "gradle/publishing.gradle" ) dependencies { constraints { @@ -68,15 +65,13 @@ dependencies { } } -publishing { - publications { - publishedArtifacts { - from components.javaPlatform - } - } +var publishingExtension = project.getExtensions().getByType(PublishingExtension) as PublishingExtension +publishingExtension.publications.named("publishedArtifacts", MavenPublication) { + from components.javaPlatform } -project( ":release" ).getTasks().named( "publishReleaseArtifacts" ).configure { +tasks.register("publishReleaseArtifacts") { + // mirror for `:release:publishReleaseArtifacts` dependsOn tasks.release } diff --git a/hibernate-spatial/hibernate-spatial.gradle b/hibernate-spatial/hibernate-spatial.gradle index 34ba99f1647a..89b8c6cc96da 100644 --- a/hibernate-spatial/hibernate-spatial.gradle +++ b/hibernate-spatial/hibernate-spatial.gradle @@ -8,6 +8,8 @@ description = 'Integrate support for Spatial/GIS data into Hibernate O/RM' apply from: rootProject.file( 'gradle/published-java-module.gradle' ) +apply from: rootProject.file( 'gradle/group-relocation.gradle' ) + apply plugin: 'org.hibernate.matrix-test' diff --git a/hibernate-testing/hibernate-testing.gradle b/hibernate-testing/hibernate-testing.gradle index 7c9d1f04f1af..e4aad69892f3 100644 --- a/hibernate-testing/hibernate-testing.gradle +++ b/hibernate-testing/hibernate-testing.gradle @@ -8,6 +8,7 @@ description = 'Support for testing Hibernate ORM functionality' apply from: rootProject.file( 'gradle/published-java-module.gradle' ) +apply from: rootProject.file( 'gradle/group-relocation.gradle' ) dependencies { api project( ':hibernate-core' ) diff --git a/tooling/hibernate-ant/hibernate-ant.gradle b/tooling/hibernate-ant/hibernate-ant.gradle index 17632b9c7d83..f87270332258 100644 --- a/tooling/hibernate-ant/hibernate-ant.gradle +++ b/tooling/hibernate-ant/hibernate-ant.gradle @@ -2,7 +2,8 @@ description = 'Annotation Processor to generate JPA 2 static metamodel classes' apply from: rootProject.file( 'gradle/published-java-module.gradle' ) -apply plugin: 'version-injection' +apply from: rootProject.file( 'gradle/group-relocation.gradle' ) +apply plugin: 'org.hibernate.build.version-injection' dependencies { compileOnly libs.ant diff --git a/tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle b/tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle index 5778364aba00..d3e1af63bea4 100644 --- a/tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle +++ b/tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle @@ -87,8 +87,10 @@ 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 +tasks.register("publishReleaseArtifacts") { + // mirror for `:release:publishReleaseArtifacts` + dependsOn tasks.release +} // local publishing (SNAPSHOT testing) publishing { diff --git a/tooling/metamodel-generator/hibernate-jpamodelgen.gradle b/tooling/metamodel-generator/hibernate-jpamodelgen.gradle index 334146d7a061..49de23bed91a 100644 --- a/tooling/metamodel-generator/hibernate-jpamodelgen.gradle +++ b/tooling/metamodel-generator/hibernate-jpamodelgen.gradle @@ -11,7 +11,9 @@ plugins { description = 'Annotation Processor to generate JPA 2 static metamodel classes' apply from: rootProject.file( 'gradle/published-java-module.gradle' ) -apply plugin: 'version-injection' +apply from: rootProject.file( 'gradle/group-relocation.gradle' ) + +apply plugin: 'org.hibernate.build.version-injection' ext { xjcTargetDir = file( "${buildDir}/generated/sources/xjc/main" ) @@ -42,38 +44,63 @@ compileTestJava { ] } - // Tests with records if ( jdkVersions.test.release.asInt() >= 17 && jdkVersions.explicit ) { - // We need to configure the source and target version to 17 - //compileTestJava17Java { - compileTestJava { - javaCompiler = javaToolchains.compilerFor { - languageVersion = jdkVersions.test.compile - } - sourceCompatibility = 17 - targetCompatibility = 17 - } + // We need to configure the source and target version to 17 + //compileTestJava17Java { + compileTestJava { + javaCompiler = javaToolchains.compilerFor { + languageVersion = jdkVersions.test.compile + } + sourceCompatibility = 17 + targetCompatibility = 17 + } + + test { + javaLauncher = javaToolchains.launcherFor { + languageVersion = jdkVersions.test.launcher + } + + if ( jdkVersions.test.launcher.asInt() >= 19 ) { + logger.warn( "The version of Java bytecode that will be tested is not supported by Bytebuddy by default. " + + " Setting 'net.bytebuddy.experimental=true'." ) + systemProperty 'net.bytebuddy.experimental', true + } + } +} else { + sourceSets { + test { + java { + exclude '**/records/*.java' + } + } + } +} - test { - javaLauncher = javaToolchains.launcherFor { - languageVersion = jdkVersions.test.launcher - } +var publishingExtension = project.getExtensions().getByType(PublishingExtension) as PublishingExtension - if ( jdkVersions.test.launcher.asInt() >= 19 ) { - logger.warn( "The version of Java bytecode that will be tested is not supported by Bytebuddy by default. " + - " Setting 'net.bytebuddy.experimental=true'." ) - systemProperty 'net.bytebuddy.experimental', true - } - } -} else { - sourceSets { - test { - java { - exclude '**/records/*.java' - } - } - } +publishingExtension.publications.named("groupRelocation", MavenPublication) { + // org.hibernate:hibernate-jpamodelgen -> org.hibernate.orm:hibernate-processor + pom { + artifactId = 'hibernate-jpamodelgen' + name = 'hibernate-jpamodelgen (relocated)' + } +} + +publishingExtension.publications.register("renameRelocation", MavenPublication) { + // org.hibernate.orm:hibernate-jpamodelgen -> org.hibernate.orm:hibernate-processor + pom { + artifactId = 'hibernate-jpamodelgen' + name = 'hibernate-jpamodelgen (relocated)' + + distributionManagement { + relocation { + groupId = project.group + artifactId = project.name + version = project.version + } + } + } }