From bc7966e20eeb8fb05d803bc19a9576f7f6b433a0 Mon Sep 17 00:00:00 2001 From: Kizito Nwose Date: Sat, 20 Jul 2024 11:28:44 +0200 Subject: [PATCH 1/2] Disable publication if needed --- build.gradle.kts | 21 +++++++++++++++++++ .../kizitonwose/calendar/buildsrc/Build.kt | 11 ++++++++-- .../library/build.gradle.kts | 4 ++-- compose/build.gradle.kts | 4 ++-- core/build.gradle.kts | 4 ++-- data/build.gradle.kts | 4 ++-- view/build.gradle.kts | 4 ++-- 7 files changed, 40 insertions(+), 12 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 39dd17f5..dd8a9e78 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,3 +1,7 @@ +import com.kizitonwose.calendar.buildsrc.Version +import com.kizitonwose.calendar.buildsrc.Version.isNoPublish +import com.kizitonwose.calendar.buildsrc.androidProjects +import com.kizitonwose.calendar.buildsrc.multiplatformProjects import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension import org.jetbrains.kotlin.gradle.plugin.KotlinBasePlugin @@ -30,6 +34,23 @@ allprojects { // https://docs.gradle.org/8.8/userguide/performance.html#execute_tests_in_parallel maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1) } + afterEvaluate { + // Android and Multiplatform libraries are published separately + // See https://github.com/kizitonwose/Calendar/pull/561 + disableMavenPublicationsIfNeeded(multiplatformProjects, Version.multiplatfrom) + disableMavenPublicationsIfNeeded(androidProjects, Version.android) + } +} + +fun Project.disableMavenPublicationsIfNeeded( + projects: List, + version: String, +) { + if (version.isNoPublish() && project.name in projects) { + tasks.withType { + enabled = false + } + } } apiValidation { diff --git a/buildSrc/src/main/java/com/kizitonwose/calendar/buildsrc/Build.kt b/buildSrc/src/main/java/com/kizitonwose/calendar/buildsrc/Build.kt index 69ba66a0..a360d6e5 100644 --- a/buildSrc/src/main/java/com/kizitonwose/calendar/buildsrc/Build.kt +++ b/buildSrc/src/main/java/com/kizitonwose/calendar/buildsrc/Build.kt @@ -11,11 +11,15 @@ object Config { val compatibleJavaLanguageVersion = JavaLanguageVersion.of(compatibleJavaVersion.majorVersion.toInt()) } -object Versions { - val core = "2.6.0-SNAPSHOT" +object Version { + val android = "2.6.0-SNAPSHOT" val multiplatfrom = "2.6.0-SNAPSHOT" + + fun String.isNoPublish() = this == VERSION_NO_PUBLISH } +private val VERSION_NO_PUBLISH = "NO_PUBLISH" + object Android { const val minSdkViewLibrary = 19 const val minSdkComposeLibrary = 21 @@ -23,3 +27,6 @@ object Android { const val targetSdk = 34 const val compileSdk = 34 } + +val multiplatformProjects = listOf("library") +val androidProjects = listOf("core", "data", "view", "compose") diff --git a/compose-multiplatform/library/build.gradle.kts b/compose-multiplatform/library/build.gradle.kts index e405c8e1..a13f535f 100644 --- a/compose-multiplatform/library/build.gradle.kts +++ b/compose-multiplatform/library/build.gradle.kts @@ -1,6 +1,6 @@ import com.kizitonwose.calendar.buildsrc.Android import com.kizitonwose.calendar.buildsrc.Config -import com.kizitonwose.calendar.buildsrc.Versions +import com.kizitonwose.calendar.buildsrc.Version import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl @@ -112,5 +112,5 @@ android { } mavenPublishing { - coordinates(version = Versions.multiplatfrom) + coordinates(version = Version.multiplatfrom) } diff --git a/compose/build.gradle.kts b/compose/build.gradle.kts index 778e1eec..bd55c5ec 100644 --- a/compose/build.gradle.kts +++ b/compose/build.gradle.kts @@ -1,7 +1,7 @@ import com.kizitonwose.calendar.buildsrc.Android import com.kizitonwose.calendar.buildsrc.Config -import com.kizitonwose.calendar.buildsrc.Versions +import com.kizitonwose.calendar.buildsrc.Version plugins { alias(libs.plugins.androidLibrary) @@ -45,5 +45,5 @@ dependencies { } mavenPublishing { - coordinates(version = Versions.core) + coordinates(version = Version.android) } diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 8d78089f..c3daf731 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -1,5 +1,5 @@ import com.kizitonwose.calendar.buildsrc.Config -import com.kizitonwose.calendar.buildsrc.Versions +import com.kizitonwose.calendar.buildsrc.Version plugins { alias(libs.plugins.kotlinJvm) @@ -23,5 +23,5 @@ dependencies { } mavenPublishing { - coordinates(version = Versions.core) + coordinates(version = Version.android) } diff --git a/data/build.gradle.kts b/data/build.gradle.kts index 7e73d147..c3150500 100644 --- a/data/build.gradle.kts +++ b/data/build.gradle.kts @@ -1,6 +1,6 @@ import com.kizitonwose.calendar.buildsrc.Config -import com.kizitonwose.calendar.buildsrc.Versions +import com.kizitonwose.calendar.buildsrc.Version plugins { alias(libs.plugins.kotlinJvm) @@ -27,5 +27,5 @@ dependencies { } mavenPublishing { - coordinates(version = Versions.core) + coordinates(version = Version.android) } diff --git a/view/build.gradle.kts b/view/build.gradle.kts index d0528fae..b2d80676 100644 --- a/view/build.gradle.kts +++ b/view/build.gradle.kts @@ -1,6 +1,6 @@ import com.kizitonwose.calendar.buildsrc.Android import com.kizitonwose.calendar.buildsrc.Config -import com.kizitonwose.calendar.buildsrc.Versions +import com.kizitonwose.calendar.buildsrc.Version plugins { alias(libs.plugins.androidLibrary) @@ -37,5 +37,5 @@ dependencies { } mavenPublishing { - coordinates(version = Versions.core) + coordinates(version = Version.android) } From 6d09e51b2f22baa1a6b07e9809047690c752ce0c Mon Sep 17 00:00:00 2001 From: Kizito Nwose Date: Sat, 20 Jul 2024 12:15:18 +0200 Subject: [PATCH 2/2] Fix flaky test --- .../java/com/kizitonwose/calendar/sample/CalendarViewTests.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sample/src/androidTest/java/com/kizitonwose/calendar/sample/CalendarViewTests.kt b/sample/src/androidTest/java/com/kizitonwose/calendar/sample/CalendarViewTests.kt index 0505b08a..96f6141e 100644 --- a/sample/src/androidTest/java/com/kizitonwose/calendar/sample/CalendarViewTests.kt +++ b/sample/src/androidTest/java/com/kizitonwose/calendar/sample/CalendarViewTests.kt @@ -266,9 +266,9 @@ class CalendarViewTests { @Test fun findVisibleDaysAndMonthsWorksOnHorizontalOrientation() { - openExampleAt(5) + openExampleAt(0) - val calendarView = getView(R.id.exSixCalendar) + val calendarView = getView(R.id.exOneCalendar) runOnMain { // Scroll to a random date