From 19d506c28725cc7d006c4759f2035dc1337ddbc3 Mon Sep 17 00:00:00 2001 From: Ahmed Moussa Date: Thu, 14 Dec 2023 22:15:17 +0200 Subject: [PATCH] fix: Gradle publish script Signed-off-by: Ahmed Moussa --- build.gradle.kts | 196 ++++++++++++-------------- iOSLibs/build.gradle.kts | 8 +- secp256k1-kmp/build.gradle.kts | 21 --- secp256k1-kmp/native/build.gradle.kts | 10 +- 4 files changed, 105 insertions(+), 130 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 2e1824465..384bae6c5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,6 @@ plugins { id("org.jlleitschuh.gradle.ktlint") version "11.6.1" id("maven-publish") id("org.jetbrains.kotlinx.kover") version "0.7.4" - id("io.github.gradle-nexus.publish-plugin") version "2.0.0-rc-1" id("signing") } @@ -44,102 +43,99 @@ allprojects { } apply(plugin = "org.gradle.maven-publish") + apply(plugin = "org.gradle.signing") - // Disable Publish Gradle task for the following modules - val disabledProjects = listOf("iOSLibs", "secp256k1-kmp", "native") - if (disabledProjects.contains(project.name)) { - afterEvaluate { - tasks.named("publishAllPublicationsToSonatypeRepository") { - enabled = false - } - } - } // Allowed projects to publish to maven val allowedProjectsToPublish = listOf("apollo") - publishing { - publications { - if (allowedProjectsToPublish.contains(project.name)) { - create(project.name) { - groupId = publishedMavenId - artifactId = project.name - version = project.version.toString() - pom { - name.set("Atala PRISM Apollo") - description.set("Collection of the cryptographic methods used all around Atala PRISM") - url.set("https://docs.atalaprism.io/") - organization { - name.set("IOG") - url.set("https://iog.io/") + if (allowedProjectsToPublish.contains(project.name)) { + publications.withType { + groupId = publishedMavenId + artifactId = project.name + version = project.version.toString() + pom { + name.set("Atala PRISM Apollo") + description.set("Collection of the cryptographic methods used all around Atala PRISM") + url.set("https://docs.atalaprism.io/") + organization { + name.set("IOG") + url.set("https://iog.io/") + } + licenses { + license { + name.set("The Apache License, Version 2.0") + url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") + } + } + developers { + developer { + id.set("hamada147") + name.set("Ahmed Moussa") + email.set("ahmed.moussa@iohk.io") + organization.set("IOG") + roles.add("developer") } - licenses { - license { - name.set("The Apache License, Version 2.0") - url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") - } + developer { + id.set("amagyar-iohk") + name.set("Allain Magyar") + email.set("allain.magyar@iohk.io") + organization.set("IOG") + roles.add("qc") } - developers { - developer { - id.set("hamada147") - name.set("Ahmed Moussa") - email.set("ahmed.moussa@iohk.io") - organization.set("IOG") - roles.add("developer") - } - developer { - id.set("amagyar-iohk") - name.set("Allain Magyar") - email.set("allain.magyar@iohk.io") - organization.set("IOG") - roles.add("qc") - } - developer { - id.set("antonbaliasnikov") - name.set("Anton Baliasnikov") - email.set("anton.baliasnikov@iohk.io") - organization.set("IOG") - roles.add("qc") - } - developer { - id.set("elribonazo") - name.set("Javier Ribó") - email.set("javier.ribo@iohk.io") - organization.set("IOG") - roles.add("developer") - } - developer { - id.set("goncalo-frade-iohk") - name.set("Gonçalo Frade") - email.set("goncalo.frade@iohk.io") - organization.set("IOG") - roles.add("developer") - } - developer { - id.set("curtis-h") - name.set("Curtis Harding") - email.set("curtis.harding@iohk.io") - organization.set("IOG") - roles.add("developer") - } - developer { - id.set("cristianIOHK") - name.set("Cristian Gonzalez") - email.set("cristian.castro@iohk.io") - organization.set("IOG") - roles.add("developer") - } + developer { + id.set("antonbaliasnikov") + name.set("Anton Baliasnikov") + email.set("anton.baliasnikov@iohk.io") + organization.set("IOG") + roles.add("qc") } - scm { - connection.set("scm:git:git://input-output-hk/atala-prism-apollo.git") - developerConnection.set("scm:git:ssh://input-output-hk/atala-prism-apollo.git") - url.set("https://github.com/input-output-hk/atala-prism-apollo") + developer { + id.set("elribonazo") + name.set("Javier Ribó") + email.set("javier.ribo@iohk.io") + organization.set("IOG") + roles.add("developer") + } + developer { + id.set("goncalo-frade-iohk") + name.set("Gonçalo Frade") + email.set("goncalo.frade@iohk.io") + organization.set("IOG") + roles.add("developer") + } + developer { + id.set("curtis-h") + name.set("Curtis Harding") + email.set("curtis.harding@iohk.io") + organization.set("IOG") + roles.add("developer") + } + developer { + id.set("cristianIOHK") + name.set("Cristian Gonzalez") + email.set("cristian.castro@iohk.io") + organization.set("IOG") + roles.add("developer") } } + scm { + connection.set("scm:git:git://input-output-hk/atala-prism-apollo.git") + developerConnection.set("scm:git:ssh://input-output-hk/atala-prism-apollo.git") + url.set("https://github.com/input-output-hk/atala-prism-apollo") + } } } - } -// repositories { -// // GitHub Maven Repo + repositories { + // Maven Central + maven { + name = "Sonatype" + url = uri("https://oss.sonatype.org/service/local/") + credentials { + username = System.getenv("SONATYPE_USERNAME") + password = System.getenv("SONATYPE_PASSWORD") + } + } + // GitHub Maven Repo // maven { // this.name = "GitHubPackages" // this.url = uri("https://maven.pkg.github.com/input-output-hk/atala-prism-apollo") @@ -148,7 +144,15 @@ allprojects { // this.password = System.getenv("ATALA_GITHUB_TOKEN") // } // } -// } + } + } + } + + signing { + val base64EncodedAsciiArmoredSigningKey: String = System.getenv("BASE64_ARMORED_GPG_SIGNING_KEY_MAVEN") ?: "" + val signingKeyPassword: String = System.getenv("SIGNING_KEY_PASSWORD") ?: "" + useInMemoryPgpKeys(String(Base64.getDecoder().decode(base64EncodedAsciiArmoredSigningKey.toByteArray())), signingKeyPassword) + sign(publishing.publications) } } @@ -188,21 +192,3 @@ subprojects { rootProject.plugins.withType(NodeJsRootPlugin::class.java) { rootProject.extensions.getByType(NodeJsRootExtension::class.java).nodeVersion = "16.17.0" } - -nexusPublishing { - repositories { - sonatype { - nexusUrl.set(uri("https://oss.sonatype.org/service/local/")) - snapshotRepositoryUrl.set(uri("https://oss.sonatype.org/content/repositories/snapshots/")) - username.set(System.getenv("SONATYPE_USERNAME")) - password.set(System.getenv("SONATYPE_PASSWORD")) - } - } -} - -signing { - val base64EncodedAsciiArmoredSigningKey: String = System.getenv("BASE64_ARMORED_GPG_SIGNING_KEY_MAVEN") ?: "" - val signingKeyPassword: String = System.getenv("SIGNING_KEY_PASSWORD") ?: "" - useInMemoryPgpKeys(String(Base64.getDecoder().decode(base64EncodedAsciiArmoredSigningKey.toByteArray())), signingKeyPassword) - sign(publishing.publications) -} diff --git a/iOSLibs/build.gradle.kts b/iOSLibs/build.gradle.kts index 1bf2b8911..02cab9857 100644 --- a/iOSLibs/build.gradle.kts +++ b/iOSLibs/build.gradle.kts @@ -66,10 +66,16 @@ libraries.forEach { library -> } } -tasks.create("clean") { +val deleteBuildFolder by tasks.register("deleteBuildFolder") { group = "build" delete("$projectDir/build") libraries.forEach { delete("$projectDir/$it/build") } } + +afterEvaluate { + tasks.named("clean") { + dependsOn(deleteBuildFolder) + } +} diff --git a/secp256k1-kmp/build.gradle.kts b/secp256k1-kmp/build.gradle.kts index 83cfd1cc6..be3b4b691 100644 --- a/secp256k1-kmp/build.gradle.kts +++ b/secp256k1-kmp/build.gradle.kts @@ -107,24 +107,3 @@ kotlin { // compilations["main"].kotlinOptions.freeCompilerArgs += listOf("-include-binary", "$rootDir/secp256k1-kmp/native/build/ios/arm64-appletvos/libsecp256k1.a") // } } - -afterEvaluate { - // Disable publish of targets - if (currentOs.isMacOsX) { - tasks.named("publishIosX64PublicationToSonatypeRepository") { - this.enabled = false - } - tasks.named("publishIosArm64PublicationToSonatypeRepository") { - this.enabled = false - } - tasks.named("publishIosSimulatorArm64PublicationToSonatypeRepository") { - this.enabled = false - } - tasks.named("publishMacosArm64PublicationToSonatypeRepository") { - this.enabled = false - } - tasks.named("publishMacosX64PublicationToSonatypeRepository") { - this.enabled = false - } - } -} diff --git a/secp256k1-kmp/native/build.gradle.kts b/secp256k1-kmp/native/build.gradle.kts index 892c8d54c..d888fcc19 100644 --- a/secp256k1-kmp/native/build.gradle.kts +++ b/secp256k1-kmp/native/build.gradle.kts @@ -126,9 +126,13 @@ val buildSecp256k1TvOSArm64 by tasks.creating(Exec::class) { } } -val clean by tasks.creating { +val deleteBuildFolder by tasks.register("deleteBuildFolder") { group = "build" - doLast { - delete(projectDir.resolve("build")) + delete(projectDir.resolve("build")) +} + +afterEvaluate { + tasks.named("clean") { + dependsOn(deleteBuildFolder) } }