Skip to content

Commit

Permalink
Fixed publishing with parallel build
Browse files Browse the repository at this point in the history
  • Loading branch information
milux committed Jun 13, 2024
1 parent bae127a commit aff0b11
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

import com.diffplug.gradle.spotless.SpotlessApply
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

buildscript {
Expand Down Expand Up @@ -50,6 +52,13 @@ allprojects {
}
}

// Create and register ExecutionService which enforces serial execution of assigned tasks
abstract class SerialExecutionService : BuildService<BuildServiceParameters.None>
val serialExecutionService =
gradle.sharedServices.registerIfAbsent("serialExecution", SerialExecutionService::class.java) {
this.maxParallelUsages.set(1)
}

val spotlessApplyAll: Task by tasks.creating

subprojects {
Expand Down Expand Up @@ -122,8 +131,8 @@ subprojects {
}

tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "11"
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
}
}

Expand Down Expand Up @@ -195,6 +204,11 @@ subprojects {
password = project.findProperty("deployPassword") as? String
}
}

// Prevent parallel publishing
tasks.withType<PublishToMavenRepository> {
usesService(serialExecutionService)
}
}
}
}
Expand Down

0 comments on commit aff0b11

Please sign in to comment.