-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from Taewan-P/feat/maven-release
Publish to Maven
- Loading branch information
Showing
1 changed file
with
112 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,51 @@ | ||
import java.util.Properties | ||
|
||
plugins { | ||
id("com.android.library") | ||
id("org.jetbrains.kotlin.android") | ||
`maven-publish` | ||
signing | ||
} | ||
|
||
val groupName = "app.priceguard" | ||
val packageName = "materialchart" | ||
val versionCode = "0.1.1" | ||
|
||
group = "$groupName.$packageName" | ||
version = versionCode | ||
|
||
extra["signing.keyId"] = null | ||
ext["signing.password"] = null | ||
ext["signing.secretKeyRingFile"] = null | ||
ext["ossrhUsername"] = null | ||
ext["ossrhPassword"] = null | ||
|
||
val secretPropsFile = project.rootProject.file("local.properties") | ||
if (secretPropsFile.exists()) { | ||
secretPropsFile.reader().use { | ||
Properties().apply { | ||
load(it) | ||
} | ||
}.onEach { (name, value) -> | ||
ext[name.toString()] = value | ||
} | ||
} else { | ||
ext["signing.keyId"] = System.getenv("SIGNING_KEY_ID") | ||
ext["signing.password"] = System.getenv("SIGNING_PASSWORD") | ||
ext["signing.secretKeyRingFile"] = System.getenv("SIGNING_SECRET_KEY_RING_FILE") | ||
ext["ossrhUsername"] = System.getenv("OSSRH_USERNAME") | ||
ext["ossrhPassword"] = System.getenv("OSSRH_PASSWORD") | ||
println(ext["ossrhUsername"]) | ||
} | ||
|
||
val javadocJar by tasks.registering(Jar::class) { | ||
archiveClassifier.set("javadoc") | ||
} | ||
|
||
fun getExtraString(name: String) = ext[name]?.toString() | ||
|
||
android { | ||
namespace = "app.priceguard.materialchart" | ||
namespace = "$groupName.$packageName" | ||
compileSdk = 34 | ||
|
||
defaultConfig { | ||
|
@@ -31,14 +72,80 @@ android { | |
kotlinOptions { | ||
jvmTarget = JavaVersion.VERSION_17.toString() | ||
} | ||
|
||
publishing { | ||
singleVariant("release") { | ||
withSourcesJar() | ||
withJavadocJar() | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
publishing { | ||
publications { | ||
afterEvaluate { | ||
create<MavenPublication>("release") { | ||
from(components["release"]) | ||
groupId = groupName | ||
artifactId = packageName | ||
version = versionCode | ||
|
||
pom { | ||
name.set(artifactId) | ||
description.set("Simple Material You style Android line chart library.") | ||
url.set("https://github.com/Taewan-P/material-android-chart") | ||
licenses { | ||
license { | ||
name.set("MIT License") | ||
url.set("https://opensource.org/license/mit/") | ||
} | ||
} | ||
developers { | ||
developer { | ||
name.set("Taewan Park") | ||
email.set("[email protected]") | ||
} | ||
} | ||
scm { | ||
url.set(pom.url.get()) | ||
connection.set("scm:git:${url.get()}.git") | ||
developerConnection.set("scm:git:${url.get()}.git") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
repositories { | ||
maven { | ||
name = "SonatypeSnapshot" | ||
setUrl("https://s01.oss.sonatype.org/content/repositories/snapshots/") | ||
credentials { | ||
username = getExtraString("ossrhUsername") | ||
password = getExtraString("ossrhPassword") | ||
} | ||
} | ||
|
||
maven { | ||
name = "Sonatype" | ||
setUrl("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") | ||
credentials { | ||
username = getExtraString("ossrhUsername") | ||
password = getExtraString("ossrhPassword") | ||
} | ||
} | ||
} | ||
} | ||
|
||
signing { | ||
afterEvaluate { | ||
sign(publishing.publications["release"]) | ||
} | ||
} | ||
|
||
|
||
dependencies { | ||
implementation("androidx.core:core-ktx:1.12.0") | ||
implementation("androidx.appcompat:appcompat:1.6.1") | ||
implementation("com.google.android.material:material:1.10.0") | ||
testImplementation("junit:junit:4.13.2") | ||
androidTestImplementation("androidx.test.ext:junit:1.1.5") | ||
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") | ||
} |