Skip to content

Commit

Permalink
Merge pull request #563 from kizitonwose/publication
Browse files Browse the repository at this point in the history
Disable publication if needed
  • Loading branch information
kizitonwose authored Jul 20, 2024
2 parents 5673c78 + 6d09e51 commit 4ba88c6
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 14 deletions.
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)
}

0 comments on commit 4ba88c6

Please sign in to comment.