Skip to content

Commit

Permalink
Fix android publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
wingio committed Nov 22, 2023
1 parent dbcd291 commit ae52b4b
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 28 deletions.
18 changes: 11 additions & 7 deletions buildSrc/src/main/kotlin/Setup.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import com.android.build.gradle.BaseExtension
import com.android.build.gradle.LibraryExtension
import com.vanniktech.maven.publish.AndroidSingleVariantLibrary
import com.vanniktech.maven.publish.JavaLibrary
import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.KotlinMultiplatform
Expand All @@ -16,16 +17,14 @@ import org.gradle.jvm.tasks.Jar
private fun <T> Property<T>.assign(value: T) = set(value)

fun Project.setupAndroid(name: String) {
val androidExtension: BaseExtension = extensions.findByType<LibraryExtension>()
?: extensions.findByType<com.android.build.gradle.AppExtension>()
?: error("Could not found Android application or library plugin applied on module $name")
val androidExtension: LibraryExtension = extensions.findByType<LibraryExtension>()
?: error("Could not found Android library plugin applied on module $name")

androidExtension.apply {
namespace = "xyz.wingio.${name.replace("-", ".")}"
compileSdkVersion(34)
compileSdk = 34
defaultConfig {
minSdk = 21
targetSdk = 34
}
}
}
Expand All @@ -34,14 +33,19 @@ fun Project.setupAndroid(name: String) {
fun Project.setup(
libName: String,
moduleName: String,
moduleDescription: String
moduleDescription: String,
androidOnly: Boolean = false
) {
setupAndroid(moduleName)

val mavenPublishing = extensions.findByType<MavenPublishBaseExtension>() ?: error("Couldn't find maven publish plugin")

mavenPublishing.apply {
configure(KotlinMultiplatform(JavadocJar.Empty()))
if(androidOnly) {
configure(AndroidSingleVariantLibrary("release"))
} else {
configure(KotlinMultiplatform(JavadocJar.Empty()))
}
publishToMavenCentral(SonatypeHost.S01, automaticRelease = true)
signAllPublications()

Expand Down
31 changes: 10 additions & 21 deletions syntakts-android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
kotlin("multiplatform")
kotlin("android")
id("com.android.library")
id("com.vanniktech.maven.publish.base")
alias(libs.plugins.binary.compatibility)
Expand All @@ -8,31 +8,20 @@ plugins {
setup(
libName = "Syntakts for Android",
moduleName = "syntakts-android",
moduleDescription = "Support for Syntakts rendering on Android"
moduleDescription = "Support for Syntakts rendering on Android",
androidOnly = true
)

kotlin {
androidTarget {
publishLibraryVariants("release")
}

jvmToolchain(17)
explicitApi()
}

sourceSets {
val androidMain by named("androidMain") {
dependencies {
api(project(":syntakts-core"))
implementation(libs.androidx.core.ktx)
implementation(libs.kotlin.coroutines.core)
}
}
dependencies {
api(project(":syntakts-core"))
implementation(libs.androidx.core.ktx)
implementation(libs.kotlin.coroutines.core)

val androidTest by named("androidUnitTest") {
dependencies {
implementation(kotlin("test"))
implementation(libs.junit)
}
}
}
testImplementation(kotlin("test"))
testImplementation(libs.junit)
}

0 comments on commit ae52b4b

Please sign in to comment.