mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-10 21:24:49 +00:00
173 lines
5.9 KiB
Groovy
173 lines
5.9 KiB
Groovy
/*
|
|
* 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())
|
|
}
|
|
}
|
|
} |