Skip to content

Commit

Permalink
[Oztechan/CCC#3020] Remove library publishing from submodules
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafaozhan committed Dec 21, 2023
1 parent 62868ed commit f4c9cb2
Showing 1 changed file with 0 additions and 118 deletions.
118 changes: 0 additions & 118 deletions basemob/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
/*
* Copyright (c) 2020 Mustafa Ozhan. All rights reserved.
*/
import java.io.IOException
import java.util.Properties

plugins {
libs.plugins.apply {
alias(androidLibrary)
alias(kotlinAndroid)
`maven-publish`
signing
}
}
Expand Down Expand Up @@ -37,118 +34,3 @@ dependencies {
implementation(androidMaterial)
}
}

tasks {
register("androidJavadocJar", Jar::class) {
archiveClassifier.set("javadoc")
from("${layout.buildDirectory}/javadoc")
}

register("androidSourcesJar", Jar::class) {
archiveClassifier.set("sources")
from(android.sourceSets.getByName("main").kotlin.srcDirs().toString())
}
}

publishing {
publications {
register<MavenPublication>("mavenAndroid") {
Library.apply {
group = GROUP
version = ProjectSettings.getVersionName(project)

afterEvaluate {
artifact(tasks.getByName("bundleReleaseAar"))

extensions.findByType<PublishingExtension>()?.apply {
repositories {
maven {
url = uri(if (isReleaseBuild) RELEASE_URL else SNAPSHOT_URL)
credentials {
username = getSecret("MAVEN_USERNAME")
password = getSecret("MAVEN_PASSWORD")
}
}
}
}

extensions.findByType<PublishingExtension>()?.let { publishing ->
val key = getSecret("GPG_KEY").replace("\\n", "\n")
val password = getSecret("GPG_PASSWORD")

extensions.findByType<SigningExtension>()?.apply {
useInMemoryPgpKeys(key, password)
sign(publishing.publications)
}
}

tasks.withType<Sign>().configureEach {
onlyIf { isReleaseBuild }
}
}

artifact(tasks.getByName("androidJavadocJar"))
artifact(tasks.getByName("androidSourcesJar"))

pom {

name.set(NAME)
description.set(DESCRIPTION)
url.set(URL)

licenses {
license {
name.set(LICENSE_NAME)
url.set(LICENSE_URL)
distribution.set(LICENSE_DISTRIBUTION)
}
}
developers {
developer {
id.set(DEVELOPER_ID)
name.set(DEVELOPER_NAME)
email.set(DEVELOPER_EMAIL)
}
}
scm { url.set(URL) }
}
}
}
}
}

val isReleaseBuild: Boolean
get() = System.getenv("GPG_KEY") != null

fun getSecret(
key: String,
default: String = "secret" // these values can not be public
): String = System.getenv(key).let {
if (it.isNullOrEmpty()) {
getSecretProperties()?.get(key)?.toString() ?: default
} else {
it
}
}

fun getSecretProperties() = try {
Properties().apply { load(file("$projectDir/key.properties").inputStream()) }
} catch (e: IOException) {
logger.debug(e.message, e)
null
}

object Library {
const val GROUP = "com.github.submob"
const val URL = "https://github.com/SubMob/BaseMob"
const val NAME = "BaseMob"
const val DESCRIPTION = "Set of base classes for Android"
const val DEVELOPER_NAME = "Mustafa Ozhan"
const val DEVELOPER_ID = "mustafaozhan"
const val DEVELOPER_EMAIL = "[email protected]"
const val LICENSE_NAME = "The Apache Software License, Version 2.0"
const val LICENSE_URL = "http://www.apache.org/licenses/LICENSE-2.0.txt"
const val LICENSE_DISTRIBUTION = "repo"
const val RELEASE_URL = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2"
const val SNAPSHOT_URL = "https://s01.oss.sonatype.org/content/repositories/snapshots"
}

0 comments on commit f4c9cb2

Please sign in to comment.