diff --git a/documentation/documentation.gradle b/documentation/documentation.gradle index 9b31227e9d..04ebbeaf49 100644 --- a/documentation/documentation.gradle +++ b/documentation/documentation.gradle @@ -75,7 +75,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 } } @@ -145,6 +148,7 @@ dependencies { testing project( ':hibernate-testing' ) spatial project( ':hibernate-spatial' ) + javadocSources project( path: ':hibernate-spatial', configuration: 'javadocSources' ) agroal project( ':hibernate-agroal' ) diff --git a/gradle/group-relocation.gradle b/gradle/group-relocation.gradle new file mode 100644 index 0000000000..390c523d46 --- /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 35815ff6e0..a86dd724eb 100644 --- a/gradle/java-module.gradle +++ b/gradle/java-module.gradle @@ -18,7 +18,7 @@ buildscript { } } -import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis + import org.apache.tools.ant.filters.ReplaceTokens apply plugin: 'java-library' @@ -159,21 +159,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 cb030bee8f..b868c26269 100644 --- a/gradle/javadoc.gradle +++ b/gradle/javadoc.gradle @@ -58,7 +58,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 97e972c3c8..1f0dfdffc1 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 } } @@ -36,66 +38,12 @@ java { // Publishing var publishingExtension = project.getExtensions().getByType(PublishingExtension) as PublishingExtension -publishingExtension.publications { - // main publication - publishedArtifacts { - // Add the Java component to the main publication - from components.java - } +publishingExtension.publications.named("publishedArtifacts", MavenPublication) { + // Add the Java component to the main publication + from components.java } -// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// 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 -> - boolean wasPublishingRequested = false - - graph.allTasks.each {task -> - 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 - 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" ) -} - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Release / publishing tasks @@ -112,17 +60,3 @@ tasks.preVerifyRelease.dependsOn generatePomFileForPublishedArtifactsPublication tasks.publishToSonatype.mustRunAfter test - -// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// 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}" - } - } - } -} \ No newline at end of file diff --git a/gradle/publishing-pom.gradle b/gradle/publishing-pom.gradle deleted file mode 100644 index 4654f0d873..0000000000 --- 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 0000000000..2a46feddd1 --- /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 eb5052d02d..5ceb774c43 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 f5534b84e4..69071f20ac 100644 --- a/hibernate-agroal/hibernate-agroal.gradle +++ b/hibernate-agroal/hibernate-agroal.gradle @@ -7,7 +7,8 @@ description = 'Integration for Agroal as a ConnectionProvider for Hibernate ORM' -apply from: rootProject.file( 'gradle/relocated-published-java-module.gradle' ) +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 622bc8f56a..fa2c3b712c 100644 --- a/hibernate-c3p0/hibernate-c3p0.gradle +++ b/hibernate-c3p0/hibernate-c3p0.gradle @@ -7,7 +7,8 @@ description = 'Integration for c3p0 Connection pooling into Hibernate ORM' -apply from: rootProject.file( 'gradle/relocated-published-java-module.gradle' ) +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 df3ca41efd..7e19a78ceb 100644 --- a/hibernate-community-dialects/hibernate-community-dialects.gradle +++ b/hibernate-community-dialects/hibernate-community-dialects.gradle @@ -7,7 +7,8 @@ description = 'Hibernate\'s community supported dialects' -apply from: rootProject.file( 'gradle/relocated-published-java-module.gradle' ) +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 bfcac032ab..c8bc62706b 100644 --- a/hibernate-core/hibernate-core.gradle +++ b/hibernate-core/hibernate-core.gradle @@ -12,7 +12,9 @@ plugins { description = 'Hibernate\'s core ORM functionality' -apply from: rootProject.file( 'gradle/relocated-published-java-module.gradle' ) +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 a358ad371f..40f2e746b0 100644 --- a/hibernate-envers/hibernate-envers.gradle +++ b/hibernate-envers/hibernate-envers.gradle @@ -7,7 +7,9 @@ description = 'Hibernate\'s entity version (audit/history) support' -apply from: rootProject.file( 'gradle/relocated-published-java-module.gradle' ) +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 4d6e82e75f..1c80c90ae6 100644 --- a/hibernate-graalvm/hibernate-graalvm.gradle +++ b/hibernate-graalvm/hibernate-graalvm.gradle @@ -7,7 +7,8 @@ description = "Experimental extension to make it easier to compile applications into a GraalVM native image" -apply from: rootProject.file( 'gradle/relocated-published-java-module.gradle' ) +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 f1078a3de5..76f6b28ae1 100644 --- a/hibernate-hikaricp/hibernate-hikaricp.gradle +++ b/hibernate-hikaricp/hibernate-hikaricp.gradle @@ -7,7 +7,8 @@ description = 'Integration for HikariCP into Hibernate O/RM' -apply from: rootProject.file( 'gradle/relocated-published-java-module.gradle' ) +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 aa205c868f..d58dd2de3d 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/relocated-published-java-module.gradle' ) +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-jfr/hibernate-jfr.gradle b/hibernate-jfr/hibernate-jfr.gradle index 560d5de739..4544ea8b91 100644 --- a/hibernate-jfr/hibernate-jfr.gradle +++ b/hibernate-jfr/hibernate-jfr.gradle @@ -7,7 +7,8 @@ description = 'Integration for JDK JFR into Hibernate O/RM' -apply from: rootProject.file( 'gradle/relocated-published-java-module.gradle' ) +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-micrometer/hibernate-micrometer.gradle b/hibernate-micrometer/hibernate-micrometer.gradle index 16e5c0f7a5..b3de5010ee 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/relocated-published-java-module.gradle' ) +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 b29a4b84ae..d2147de7a5 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 { @@ -65,15 +62,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 bcaea76038..f93d2a0c95 100644 --- a/hibernate-spatial/hibernate-spatial.gradle +++ b/hibernate-spatial/hibernate-spatial.gradle @@ -7,7 +7,9 @@ description = 'Integrate support for Spatial/GIS data into Hibernate O/RM' -apply from: rootProject.file( 'gradle/relocated-published-java-module.gradle' ) +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 c9e6733f41..f3458967f3 100644 --- a/hibernate-testing/hibernate-testing.gradle +++ b/hibernate-testing/hibernate-testing.gradle @@ -7,7 +7,8 @@ description = 'Support for testing Hibernate ORM functionality' -apply from: rootProject.file( 'gradle/relocated-published-java-module.gradle' ) +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-ucp/hibernate-ucp.gradle b/hibernate-ucp/hibernate-ucp.gradle index 7c5843e6ba..bab89e3ca2 100644 --- a/hibernate-ucp/hibernate-ucp.gradle +++ b/hibernate-ucp/hibernate-ucp.gradle @@ -7,7 +7,8 @@ description = 'Integration for Oracle UCP into Hibernate O/RM' -apply from: rootProject.file( 'gradle/relocated-published-java-module.gradle' ) +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-vector/hibernate-vector.gradle b/hibernate-vector/hibernate-vector.gradle index ece85d16d1..7806a0d0a3 100644 --- a/hibernate-vector/hibernate-vector.gradle +++ b/hibernate-vector/hibernate-vector.gradle @@ -7,7 +7,8 @@ description = 'Hibernate\'s extensions for vector support' -apply from: rootProject.file( 'gradle/relocated-published-java-module.gradle' ) +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 20b9895ddb..f872703322 100644 --- a/tooling/hibernate-ant/hibernate-ant.gradle +++ b/tooling/hibernate-ant/hibernate-ant.gradle @@ -1,7 +1,8 @@ description = 'Annotation Processor to generate JPA 2 static metamodel classes' -apply from: rootProject.file( 'gradle/relocated-published-java-module.gradle' ) +apply from: rootProject.file( 'gradle/published-java-module.gradle' ) +apply from: rootProject.file( 'gradle/group-relocation.gradle' ) apply plugin: 'org.hibernate.build.version-injection' dependencies { diff --git a/tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle b/tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle index 7b8edd11aa..aa9fe958bf 100644 --- a/tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle +++ b/tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle @@ -73,8 +73,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/hibernate-maven-plugin/hibernate-maven-plugin.gradle b/tooling/hibernate-maven-plugin/hibernate-maven-plugin.gradle index 9a21390ec9..f0bb4cc295 100644 --- a/tooling/hibernate-maven-plugin/hibernate-maven-plugin.gradle +++ b/tooling/hibernate-maven-plugin/hibernate-maven-plugin.gradle @@ -1,7 +1,7 @@ description = 'Maven plugin to integrate aspects of Hibernate into your build.' -apply from: rootProject.file( 'gradle/publishing-pom.gradle' ) apply from: rootProject.file( 'gradle/java-module.gradle' ) +apply from: rootProject.file( 'gradle/publishing.gradle' ) apply plugin: 'org.hibernate.build.maven-embedder' @@ -21,63 +21,60 @@ dependencies { implementation "org.apache.maven.shared:file-management:3.1.0" } -publishing { - publications { - publishedArtifacts(MavenPublication) { - from components.java - pom.withXml { - asNode() - .version - .plus { - packaging('maven-plugin') - } - asNode() - .dependencies - .dependency - .findAll { dependency -> - dependency.groupId.text().startsWith('org.apache.maven') - } - .each { dependency -> - if (dependency.groupId.text().startsWith('org.apache.maven.shared')) { - dependency.scope*.value = 'compile' - } else { - dependency.scope*.value = 'provided' - } - } - asNode() - .dependencies - .dependency - .findAll { dependency -> - dependency.groupId.text().startsWith('org.hibernate.orm') - } - .each { dependency -> - dependency.scope*.value = 'compile' - } - asNode() - .dependencies - .plus { - def plugins = build().appendNode('plugins') - def pluginPlugin = plugins.appendNode('plugin') - pluginPlugin.appendNode('groupId', 'org.apache.maven.plugins') - pluginPlugin.appendNode('artifactId', 'maven-plugin-plugin') - pluginPlugin.appendNode('version', '3.15.0') - def pluginConfiguration = pluginPlugin.appendNode('configuration') - pluginConfiguration.appendNode('goalPrefix', 'plugin') - pluginConfiguration.appendNode('outputDirectory', layout.buildDirectory.dir('generated/sources/plugin-descriptors/META-INF/maven').get().getAsFile().getAbsolutePath() ) - def invokerPlugin = plugins.appendNode('plugin'); - invokerPlugin.appendNode('groupId', 'org.apache.maven.plugins') - invokerPlugin.appendNode('artifactId', 'maven-invoker-plugin') - invokerPlugin.appendNode('version', '3.8.0') - def invokerConfiguration = invokerPlugin.appendNode('configuration'); - invokerConfiguration.appendNode('debug', 'true'); - invokerConfiguration.appendNode('mavenExecutable', 'mvnw'); - def scriptVariables = invokerConfiguration.appendNode('scriptVariables'); - scriptVariables.appendNode('hibernateCoreJarPath', layout.buildDirectory.file('maven-embedder/maven-local/org/hibernate/orm/hibernate-core/' + project.version + '/hibernate-core-' + project.version + '.jar').get().getAsFile().getAbsolutePath()) - } - } - } - } +var publishingExtension = project.getExtensions().getByType(PublishingExtension) as PublishingExtension +publishingExtension.publications.named("publishedArtifacts") { + from components.java + pom.withXml { + asNode() + .version + .plus { + packaging('maven-plugin') + } + asNode() + .dependencies + .dependency + .findAll { dependency -> + dependency.groupId.text().startsWith('org.apache.maven') + } + .each { dependency -> + if (dependency.groupId.text().startsWith('org.apache.maven.shared')) { + dependency.scope*.value = 'compile' + } else { + dependency.scope*.value = 'provided' + } + } + asNode() + .dependencies + .dependency + .findAll { dependency -> + dependency.groupId.text().startsWith('org.hibernate.orm') + } + .each { dependency -> + dependency.scope*.value = 'compile' + } + asNode() + .dependencies + .plus { + def plugins = build().appendNode('plugins') + def pluginPlugin = plugins.appendNode('plugin') + pluginPlugin.appendNode('groupId', 'org.apache.maven.plugins') + pluginPlugin.appendNode('artifactId', 'maven-plugin-plugin') + pluginPlugin.appendNode('version', '3.15.0') + def pluginConfiguration = pluginPlugin.appendNode('configuration') + pluginConfiguration.appendNode('goalPrefix', 'plugin') + pluginConfiguration.appendNode('outputDirectory', layout.buildDirectory.dir('generated/sources/plugin-descriptors/META-INF/maven').get().getAsFile().getAbsolutePath() ) + def invokerPlugin = plugins.appendNode('plugin'); + invokerPlugin.appendNode('groupId', 'org.apache.maven.plugins') + invokerPlugin.appendNode('artifactId', 'maven-invoker-plugin') + invokerPlugin.appendNode('version', '3.8.0') + def invokerConfiguration = invokerPlugin.appendNode('configuration'); + invokerConfiguration.appendNode('debug', 'true'); + invokerConfiguration.appendNode('mavenExecutable', 'mvnw'); + def scriptVariables = invokerConfiguration.appendNode('scriptVariables'); + scriptVariables.appendNode('hibernateCoreJarPath', layout.buildDirectory.file('maven-embedder/maven-local/org/hibernate/orm/hibernate-core/' + project.version + '/hibernate-core-' + project.version + '.jar').get().getAsFile().getAbsolutePath()) + } + } } // Following tasks need to be performed: diff --git a/tooling/metamodel-generator/hibernate-processor.gradle b/tooling/metamodel-generator/hibernate-processor.gradle index 54aeb9b78b..6e2df89dd3 100644 --- a/tooling/metamodel-generator/hibernate-processor.gradle +++ b/tooling/metamodel-generator/hibernate-processor.gradle @@ -8,7 +8,9 @@ import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis */ description = 'Hibernate compile-time tooling' -apply from: rootProject.file( 'gradle/relocated-published-java-module.gradle' ) +apply from: rootProject.file( 'gradle/published-java-module.gradle' ) +apply from: rootProject.file( 'gradle/group-relocation.gradle' ) + apply plugin: 'org.hibernate.build.version-injection' //java { @@ -144,60 +146,27 @@ compileTestJava { ] } -publishing { - publications { - // relocation for the published artifacts based on the old groupId - relocationPom(MavenPublication) { - pom { - name = 'hibernate-jpamodelgen - relocation' - groupId = 'org.hibernate.orm' - artifactId = 'hibernate-jpamodelgen' +var publishingExtension = project.getExtensions().getByType(PublishingExtension) as PublishingExtension + +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 - - 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 - } - } } } }