From 96951d7adc36c6504e2154c9873f1e79e1a514e1 Mon Sep 17 00:00:00 2001 From: Alexander Weigl Date: Fri, 18 Aug 2023 19:56:20 +0200 Subject: [PATCH] repair POM generation using afterEvaluate --- build.gradle | 195 +++++++++++++++++++++++++-------------------------- 1 file changed, 97 insertions(+), 98 deletions(-) diff --git a/build.gradle b/build.gradle index 308cca4c851..1b1a1ae1ef2 100644 --- a/build.gradle +++ b/build.gradle @@ -277,102 +277,6 @@ subprojects { archiveClassifier = 'javadoc' } - publishing { - publications { - mavenJava(MavenPublication) { - from components.java - artifact sourcesJar - artifact javadocJar - pom { - name = projects.name - description = project.description - url = 'https://key-project.org/' - - licenses { - license { - name = "GNU General Public License (GPL), Version 2" - url = "https://www.gnu.org/licenses/old-licenses/gpl-2.0.html" - } - } - - developers { - developer { - id = 'key' - name = 'KeY Developers' - email = 'support@key-project.org' - url = "https://www.key-project.org/about/people/" - } - } - scm { - connection = 'scm:git:git://github.com/keyproject/key.git' - developerConnection = 'scm:git:git://github.com/keyproject/key.git' - url = 'https://github.com/keyproject/key/' - } - } - } - } - repositories { - maven { - /** - * To be able to publish things on Maven Central, you need two things: - * - * (1) a JIRA account with permission on group-id `org.key-project` - * (2) a keyserver-published GPG (w/o sub-keys) - * - * Your `$HOME/.gradle/gradle.properties` should like this: - * ``` - * signing.keyId=YourKeyId - * signing.password=YourPublicKeyPassword - * ossrhUsername=your-jira-id - * ossrhPassword=your-jira-password - * ``` - * - * You can test signing with `gradle sign`, and publish with `gradle publish`. - * https://central.sonatype.org/publish/publish-guide/ - */ - if (project.version.endsWith("-SNAPSHOT")) { - name = "mavenSnapshot" - url = "https://s01.oss.sonatype.org/content/repositories/snapshots/" - credentials(PasswordCredentials) { - username = project.properties.getOrDefault("ossrhUsername","") - password = project.properties.getOrDefault("ossrhPassword","") - } - } else { - name = "mavenStaging" - url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" - credentials(PasswordCredentials) { - username = project.properties.getOrDefault("ossrhUsername","") - password = project.properties.getOrDefault("ossrhPassword","") - } - } - } - - /* - maven { // deployment to git.key-project.org - name = "GitlabPackages" - url "https://git.key-project.org/api/v4/projects/35/packages/maven" - credentials(HttpHeaderCredentials) { - if (System.getenv("TOKEN") != null) { - name = 'Private-Token' - value = System.getenv("TOKEN") - } else { - name = 'Job-Token' - value = System.getenv("CI_JOB_TOKEN") - } - } - authentication { - header(HttpHeaderAuthentication) - } - } - */ - } - } - - signing { - useGpgCmd() // works better than the Java implementation, which requires PGP keyrings. - sign publishing.publications.mavenJava - } - license {//configures the license file header header = file("$rootDir/gradle/header") @@ -397,8 +301,6 @@ subprojects { } } - - spotless { // see https://github.com/diffplug/spotless/tree/main/plugin-gradle @@ -452,6 +354,103 @@ subprojects { } } + afterEvaluate { // required so project.description is non-null as set by sub build.gradle + publishing { + publications { + mavenJava(MavenPublication) { + from components.java + artifact sourcesJar + artifact javadocJar + pom { + name = projects.name + description = project.description + url = 'https://key-project.org/' + + licenses { + license { + name = "GNU General Public License (GPL), Version 2" + url = "https://www.gnu.org/licenses/old-licenses/gpl-2.0.html" + } + } + + developers { + developer { + id = 'key' + name = 'KeY Developers' + email = 'support@key-project.org' + url = "https://www.key-project.org/about/people/" + } + } + scm { + connection = 'scm:git:git://github.com/keyproject/key.git' + developerConnection = 'scm:git:git://github.com/keyproject/key.git' + url = 'https://github.com/keyproject/key/' + } + } + } + } + repositories { + maven { + /** + * To be able to publish things on Maven Central, you need two things: + * + * (1) a JIRA account with permission on group-id `org.key-project` + * (2) a keyserver-published GPG (w/o sub-keys) + * + * Your `$HOME/.gradle/gradle.properties` should like this: + * ``` + * signing.keyId=YourKeyId + * signing.password=YourPublicKeyPassword + * ossrhUsername=your-jira-id + * ossrhPassword=your-jira-password + * ``` + * + * You can test signing with `gradle sign`, and publish with `gradle publish`. + * https://central.sonatype.org/publish/publish-guide/ + */ + if (project.version.endsWith("-SNAPSHOT")) { + name = "mavenSnapshot" + url = "https://s01.oss.sonatype.org/content/repositories/snapshots/" + credentials(PasswordCredentials) { + username = project.properties.getOrDefault("ossrhUsername", "") + password = project.properties.getOrDefault("ossrhPassword", "") + } + } else { + name = "mavenStaging" + url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + credentials(PasswordCredentials) { + username = project.properties.getOrDefault("ossrhUsername", "") + password = project.properties.getOrDefault("ossrhPassword", "") + } + } + } + + /* + maven { // deployment to git.key-project.org + name = "GitlabPackages" + url "https://git.key-project.org/api/v4/projects/35/packages/maven" + credentials(HttpHeaderCredentials) { + if (System.getenv("TOKEN") != null) { + name = 'Private-Token' + value = System.getenv("TOKEN") + } else { + name = 'Job-Token' + value = System.getenv("CI_JOB_TOKEN") + } + } + authentication { + header(HttpHeaderAuthentication) + } + } + */ + } + } + + signing { + useGpgCmd() // works better than the Java implementation, which requires PGP keyrings. + sign publishing.publications.mavenJava + } + } } task start {