Skip to content

Commit

Permalink
Cleanup build scripts (#23)
Browse files Browse the repository at this point in the history
* Cleanup build-plugins

* Configure shared java source set in applyDefaultHierarchyTemplate

---------

Co-authored-by: Sergej Shafarenka <[email protected]>
  • Loading branch information
sergejsha and Sergej Shafarenka authored Jul 29, 2024
1 parent 9f10e7b commit d07d3e8
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 37 deletions.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,45 @@ if (canSign) {
}

// fix for: https://github.com/gradle/gradle/issues/26091
// https://youtrack.jetbrains.com/issue/KT-46466 is fixed
// and https://youtrack.jetbrains.com/issue/KT-46466
tasks.withType<AbstractPublishToMaven>().configureEach {
dependsOn(project.tasks.withType(Sign::class.java))
}

open class LoggerPublishingPluginExtension(
private val _description: (String) -> Unit,
) {
fun description(value: String) {
_description(value)
}
}

project.extensions
.create<LoggerPublishingPluginExtension>(
"loggerPublishing",
::description,
)

private fun description(value: String) {
publishing {
publications.withType<MavenPublication> {
pom {
description.set(value)
}
}
}
applyDefaultTaskDependencies()
}

private fun applyDefaultTaskDependencies() {
// https://youtrack.jetbrains.com/issue/KT-61313
tasks.withType<Sign>().configureEach {
val publicationName = name.removePrefix("sign").removeSuffix("Publication")
tasks.findByName("linkDebugTest$publicationName")?.let {
mustRunAfter(it)
}
tasks.findByName("compileTestKotlin$publicationName")?.let {
mustRunAfter(it)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ plugins {

allprojects {
group = "de.halfbit"
version = "0.6"
version = "0.7-SNAPSHOT"
}
45 changes: 11 additions & 34 deletions logger/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,15 @@ kotlin {
iosArm64()
iosSimulatorArm64()

applyDefaultHierarchyTemplate()
@OptIn(ExperimentalKotlinGradlePluginApi::class)
applyDefaultHierarchyTemplate {
common {
group("java") {
withJvm()
withAndroidNative()
}
}
}

sourceSets {
commonMain.dependencies {
Expand All @@ -71,21 +79,6 @@ kotlin {
commonTest.dependencies {
implementation(libs.kotlin.test)
}

val androidUnitTest by getting

val javaMain by creating {
dependsOn(commonMain.get())
androidMain.get().dependsOn(this)
jvmMain.get().dependsOn(this)
}
val javaTest by creating {
androidUnitTest.dependsOn(this)
jvmTest.get().dependsOn(this)
dependencies {
implementation(libs.kotlin.test.junit)
}
}
}
}

Expand All @@ -103,22 +96,6 @@ android {
}
}

// Customization of module.publications
publishing {
publications.withType<MavenPublication> {
pom {
description.set("Minimalistic Logger for Kotlin Multiplatform")
}
}
}

// https://youtrack.jetbrains.com/issue/KT-61313
tasks.withType<Sign>().configureEach {
val publicationName = name.removePrefix("sign").removeSuffix("Publication")
tasks.findByName("linkDebugTest$publicationName")?.let {
mustRunAfter(it)
}
tasks.findByName("compileTestKotlin$publicationName")?.let {
mustRunAfter(it)
}
loggerPublishing {
description("Minimalistic, fast and configurable Logger for Kotlin Multiplatform")
}
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pluginManagement {
includeBuild("convention-plugins")
repositories {
google()
mavenCentral()
Expand All @@ -16,6 +15,7 @@ dependencyResolutionManagement {
}

rootProject.name = "logger"
includeBuild("build-plugins")
include(":logger")
include(":sample-apps:shared")
include(":sample-apps:composeApp")

0 comments on commit d07d3e8

Please sign in to comment.