|
| 1 | +import java.util.Properties |
| 2 | + |
| 3 | +plugins { |
| 4 | + id("io.github.gradle-nexus.publish-plugin") version "2.0.0" |
| 5 | + id("com.android.library") version "9.1.1" apply false |
| 6 | + id("com.android.application") version "9.1.1" apply false |
| 7 | +} |
| 8 | + |
| 9 | +version = System.getenv("SDK_VERSION") ?: "0.0.0" |
| 10 | + |
| 11 | +tasks.register<Delete>("clean") { |
| 12 | + delete(rootProject.layout.buildDirectory) |
| 13 | +} |
| 14 | + |
| 15 | +val signingKeyId: String = System.getenv("SIGNING_KEY_ID") ?: "" |
| 16 | +val signingPassword: String = System.getenv("SIGNING_PASSWORD") ?: "" |
| 17 | +val signingSecretKeyRingFile: String = System.getenv("SIGNING_SECRET_KEY_RING_FILE") ?: "" |
| 18 | +val ossrhUsername: String = System.getenv("OSSRH_USERNAME") ?: "" |
| 19 | +val ossrhPassword: String = System.getenv("OSSRH_PASSWORD") ?: "" |
| 20 | +val sonatypeStagingProfileId: String = System.getenv("SONATYPE_STAGING_PROFILE_ID") ?: "" |
| 21 | + |
| 22 | +val secretPropsFile = project.rootProject.file("local.properties") |
| 23 | +val localProperties = Properties().apply { |
| 24 | + if (secretPropsFile.exists()) { |
| 25 | + secretPropsFile.inputStream().use { load(it) } |
| 26 | + } |
| 27 | +} |
| 28 | + |
| 29 | +extra["signing.keyId"] = signingKeyId.ifEmpty { localProperties.getProperty("signing.keyId", "") } |
| 30 | +extra["signing.password"] = signingPassword.ifEmpty { localProperties.getProperty("signing.password", "") } |
| 31 | +extra["signing.secretKeyRingFile"] = signingSecretKeyRingFile.ifEmpty { localProperties.getProperty("signing.secretKeyRingFile", "") } |
| 32 | + |
| 33 | +nexusPublishing { |
| 34 | + repositories { |
| 35 | + sonatype { |
| 36 | + stagingProfileId.set(sonatypeStagingProfileId.ifEmpty { localProperties.getProperty("sonatypeStagingProfileId", "") }) |
| 37 | + username.set(ossrhUsername.ifEmpty { localProperties.getProperty("ossrhUsername", "") }) |
| 38 | + password.set(ossrhPassword.ifEmpty { localProperties.getProperty("ossrhPassword", "") }) |
| 39 | + nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/")) |
| 40 | + snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/")) |
| 41 | + } |
| 42 | + } |
| 43 | +} |
0 commit comments