Skip to content
This repository has been archived by the owner on Mar 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #4 from cheonjaewoong/setup-maven-publish
Browse files Browse the repository at this point in the history
Setup maven publish
  • Loading branch information
cheonjaeung authored Dec 7, 2022
2 parents 4bb4cdc + 817c04a commit a423008
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 1 deletion.
3 changes: 3 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ buildscript {
}

allprojects {
group = "io.woong.savedstate"
version = "1.0.0-alpha1"

repositories {
google()
mavenCentral()
Expand Down
80 changes: 79 additions & 1 deletion savedstate-ktx/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import java.util.Properties

plugins {
id("org.jetbrains.kotlin.android")
id("com.android.library")
id("maven-publish")
id("signing")
}

android {
namespace = "io.woong.savedstate"
namespace = "${project.group}"

compileSdk = 33
defaultConfig {
Expand All @@ -21,6 +25,13 @@ android {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}

publishing {
singleVariant("release") {
withSourcesJar()
withJavadocJar()
}
}
}

dependencies {
Expand All @@ -35,3 +46,70 @@ dependencies {
androidTestImplementation("androidx.appcompat:appcompat:1.5.1")
androidTestImplementation("androidx.activity:activity-ktx:1.6.1")
}

publishing {
repositories {
maven {
name = "sonatype"
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = localProperty("OSSRH_USERNAME")
password = localProperty("OSSRH_PASSWORD")
}
}
}

publications {
create<MavenPublication>("release") {
afterEvaluate {
from(components.getByName("release"))
}

groupId = "${project.group}"
artifactId = "savedstate-ktx"
version = "${project.version}"

pom {
name.set("savedstate-ktx")
description.set("Kotlin extensions for Android SavedStateHandle")
url.set("https://github.com/cheonjaewoong/savedstate-ktx")

licenses {
license {
name.set("MIT")
url.set("https://github.com/cheonjaewoong/savedstate-ktx/blob/master/LICENSE.txt")
}
}

developers {
developer {
id.set("cheonjaewoong")
name.set("Jaewoong Cheon")
email.set("cheonjaewoong@gmail.com")
}
}

scm {
url.set("https://github.com/cheonjaewoong/savedstate-ktx")
connection.set("scm:git:git://github.com/cheonjaewoong/savedstate-ktx.git")
developerConnection.set("scm:git:ssh://git@github.com/cheonjaewoong/savedstate-ktx.git")
}
}
}
}
}

signing {
sign(publishing.publications)
}

fun localProperty(name: String): String? {
val localPropertiesFile = project.rootProject.file("local.properties")
if (!localPropertiesFile.exists()) {
return null
}
val properties = localPropertiesFile.reader().use { reader ->
Properties().apply { load(reader) }
}
return properties.getProperty(name, null)
}

0 comments on commit a423008

Please sign in to comment.