From 5fa013881792592761168fe819c0ece973f43b28 Mon Sep 17 00:00:00 2001 From: Kizito Nwose Date: Fri, 19 Jul 2024 14:47:34 +0200 Subject: [PATCH] Science --- build.gradle.kts | 20 +++++++++++++++++++ .../kizitonwose/calendar/buildsrc/Build.kt | 17 +++++++++++++--- .../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, 44 insertions(+), 13 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index d716f9e5..bf154b50 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 @@ -25,6 +29,22 @@ allprojects { } } } + afterEvaluate { + 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 6fccfb7c..ac67ed00 100644 --- a/buildSrc/src/main/java/com/kizitonwose/calendar/buildsrc/Build.kt +++ b/buildSrc/src/main/java/com/kizitonwose/calendar/buildsrc/Build.kt @@ -2,8 +2,12 @@ package com.kizitonwose.calendar.buildsrc +import com.kizitonwose.calendar.buildsrc.Version.isNoPublish import org.gradle.api.JavaVersion +import org.gradle.api.Project +import org.gradle.api.publish.maven.tasks.AbstractPublishToMaven import org.gradle.jvm.toolchain.JavaLanguageVersion +import org.gradle.kotlin.dsl.withType import kotlin.math.max object Config { @@ -11,11 +15,15 @@ object Config { val compatibleJavaLanguageVersion = JavaLanguageVersion.of(compatibleJavaVersion.majorVersion.toInt()) } -object Versions { - val core = "2.6.0-alpha04" - val multiplatfrom = "2.6.0-SNAPSHOT" +object Version { + val android = VERSION_NO_PUBLISH + val multiplatfrom = "2.6.0-alpha04" + + 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 +31,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) }