Skip to content

Commit

Permalink
repair POM generation using afterEvaluate
Browse files Browse the repository at this point in the history
  • Loading branch information
wadoon committed Aug 20, 2023
1 parent fa17e76 commit 96951d7
Showing 1 changed file with 97 additions and 98 deletions.
195 changes: 97 additions & 98 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '[email protected]'
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")

Expand All @@ -397,8 +301,6 @@ subprojects {
}
}



spotless {
// see https://github.com/diffplug/spotless/tree/main/plugin-gradle

Expand Down Expand Up @@ -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 = '[email protected]'
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 {
Expand Down

0 comments on commit 96951d7

Please sign in to comment.