Skip to content

Commit

Permalink
Merge pull request #127 from halilozercan/halilozercan/fix-publish-wo…
Browse files Browse the repository at this point in the history
…rkflow

Fix publish workflow
  • Loading branch information
halilozercan authored Jan 4, 2024
2 parents fcce206 + a4f0037 commit edff0f6
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 34 deletions.
3 changes: 1 addition & 2 deletions android-sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.zachklipp.richtext.sample">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />

Expand Down
46 changes: 20 additions & 26 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
import com.android.build.gradle.LibraryExtension
import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties
import org.jetbrains.dokka.gradle.DokkaMultiModuleTask
import org.jetbrains.dokka.gradle.DokkaTaskPartial
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

buildscript {
Expand Down Expand Up @@ -64,6 +62,10 @@ subprojects {
return@afterEvaluate
}

tasks.withType<AbstractPublishToMaven>().configureEach {
dependsOn(tasks.withType<Sign>())
}

tasks.named<DokkaTaskPartial>("dokkaHtmlPartial").configure {
dokkaSourceSets.configureEach {
reportUndocumented.set(true)
Expand All @@ -81,27 +83,27 @@ subprojects {
archiveClassifier.set("javadoc")
from(tasks.dokkaJavadoc.flatMap { it.outputDirectory })
}
}

afterEvaluate {
val androidExtension = extensions.findByType<LibraryExtension>()
val multiplatformExtension = extensions.findByType<KotlinMultiplatformExtension>()

fun MavenPublication.configure() {
if (multiplatformExtension == null && androidExtension != null) {
val androidSourcesJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(androidExtension.sourceSets["main"].java.srcDirs)
}
artifact(androidSourcesJar.get())
from(components["release"])
if (tasks.names.contains("publishKotlinMultiplatformPublicationToMavenRepository")) {
tasks.named("publishKotlinMultiplatformPublicationToMavenRepository").configure {
dependsOn("signJvmPublication")
}
}

artifact(tasks.named("javadocJar").get())
if (tasks.names.contains("publishAndroidReleasePublicationToMavenRepository")) {
tasks.named("publishAndroidReleasePublicationToMavenRepository").configure {
dependsOn("signJvmPublication")
}
}
}

afterEvaluate {
fun MavenPublication.configure() {
groupId = property("GROUP").toString()
version = property("VERSION_NAME").toString()

artifact(tasks.named("javadocJar").get())

pom {
name.set(property("POM_NAME").toString())
description.set(property("POM_DESCRIPTION").toString())
Expand Down Expand Up @@ -157,16 +159,8 @@ subprojects {
}
}

if (multiplatformExtension != null) {
publications.withType<MavenPublication>().configureEach {
configure()
}
} else if (androidExtension != null) {
// Add publications for Android libraries.
// KMP libraries already have MavenPublications that are added by multiplatform plugin
publications.register<MavenPublication>("release") {
afterEvaluate { configure() }
}
publications.withType<MavenPublication>().configureEach {
configure()
}
}

Expand Down
6 changes: 6 additions & 0 deletions buildSrc/src/main/kotlin/richtext-android-library.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,10 @@ android {
composeOptions {
kotlinCompilerExtensionVersion = Compose.compilerVersion
}

publishing {
singleVariant("release") {
withSourcesJar()
}
}
}
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/richtext-kmp-library.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repositories {
kotlin {
jvm()
android {
publishLibraryVariants("release", "debug")
publishLibraryVariants("release")
compilations.all {
kotlinOptions.jvmTarget = "11"
}
Expand Down
2 changes: 1 addition & 1 deletion richtext-commonmark/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<manifest package="com.halilibo.richtext.markdown" />
<manifest />
2 changes: 1 addition & 1 deletion richtext-ui-material/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<manifest package="com.halilibo.richtext.ui.material" />
<manifest />
2 changes: 1 addition & 1 deletion richtext-ui-material3/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<manifest package="com.halilibo.richtext.ui.material3" />
<manifest />
2 changes: 1 addition & 1 deletion richtext-ui/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<manifest package="com.halilibo.richtext.ui" />
<manifest />
2 changes: 1 addition & 1 deletion slideshow/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<manifest package="com.zachklipp.richtext.ui.slideshow" />
<manifest />

0 comments on commit edff0f6

Please sign in to comment.