Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable publication if needed #563

Merged
merged 2 commits into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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<String>,
version: String,
) {
if (version.isNoPublish() && project.name in projects) {
tasks.withType<AbstractPublishToMaven> {
enabled = false
}
}
}

apiValidation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,22 @@ 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
val minSdkSampleApp = max(minSdkViewLibrary, minSdkComposeLibrary)
const val targetSdk = 34
const val compileSdk = 34
}

val multiplatformProjects = listOf("library")
val androidProjects = listOf("core", "data", "view", "compose")
4 changes: 2 additions & 2 deletions compose-multiplatform/library/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -112,5 +112,5 @@ android {
}

mavenPublishing {
coordinates(version = Versions.multiplatfrom)
coordinates(version = Version.multiplatfrom)
}
4 changes: 2 additions & 2 deletions compose/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -45,5 +45,5 @@ dependencies {
}

mavenPublishing {
coordinates(version = Versions.core)
coordinates(version = Version.android)
}
4 changes: 2 additions & 2 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -23,5 +23,5 @@ dependencies {
}

mavenPublishing {
coordinates(version = Versions.core)
coordinates(version = Version.android)
}
4 changes: 2 additions & 2 deletions data/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -27,5 +27,5 @@ dependencies {
}

mavenPublishing {
coordinates(version = Versions.core)
coordinates(version = Version.android)
}
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,9 @@ class CalendarViewTests {

@Test
fun findVisibleDaysAndMonthsWorksOnHorizontalOrientation() {
openExampleAt(5)
openExampleAt(0)

val calendarView = getView<CalendarView>(R.id.exSixCalendar)
val calendarView = getView<CalendarView>(R.id.exOneCalendar)

runOnMain {
// Scroll to a random date
Expand Down
4 changes: 2 additions & 2 deletions view/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -37,5 +37,5 @@ dependencies {
}

mavenPublishing {
coordinates(version = Versions.core)
coordinates(version = Version.android)
}
Loading