-
Notifications
You must be signed in to change notification settings - Fork 41
/
build.gradle.kts
141 lines (117 loc) · 4.35 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import kotlinx.team.infra.InfraExtension
import kotlinx.validation.ExperimentalBCVApi
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
import tasks.CheckReadmeTask
buildscript {
repositories {
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlinx/maven")
gradlePluginPortal()
addDevRepositoryIfEnabled(this, project)
}
dependencies {
classpath(libs.kotlinx.teamInfraGradlePlugin)
val kotlinVersion = providers.gradleProperty("kotlin_version").orNull
if (!kotlinVersion.isNullOrBlank()) {
// In addition to overriding the Kotlin version in the Version Catalog,
// also enforce the KGP version using a dependency constraint.
// Constraints are stricter than Version Catalog.
constraints {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
}
}
}
}
plugins {
id("base")
alias(libs.plugins.kotlin.multiplatform) apply false
alias(libs.plugins.kotlinx.binaryCompatibilityValidator)
}
apply(plugin = "kotlinx.team.infra")
extensions.configure<InfraExtension> {
publishing {
include(":kotlinx-benchmark-runtime")
libraryRepoUrl = "https://github.com/Kotlin/kotlinx-benchmark"
if (project.findProperty("publication_repository") == "sonatype") {
sonatype {
libraryStagingRepoDescription = project.name
}
}
}
}
// https://youtrack.jetbrains.com/issue/KT-48410
repositories {
mavenCentral()
}
// region Workarounds for https://github.com/gradle/gradle/issues/22335
tasks.register("apiDump") {
dependsOn(gradle.includedBuild("plugin").task(":apiDump"))
}
tasks.register("apiCheck") {
dependsOn(gradle.includedBuild("plugin").task(":apiCheck"))
}
afterEvaluate {
gradle.includedBuilds.forEach { included ->
project(":kotlinx-benchmark-runtime").tasks.named("publishToMavenLocal") { dependsOn(included.task(":publishToMavenLocal")) }
}
}
tasks.register("publishToMavenLocal") {
dependsOn(gradle.includedBuild("plugin").task(":publishToMavenLocal"))
}
//endregion
val currentKgpVersion = getKotlinPluginVersion()
logger.info("Using Kotlin Gradle Plugin $currentKgpVersion")
val kotlinVersionOverride = providers.gradleProperty("kotlin_version").getOrNull()
if (kotlinVersionOverride != null) {
val versionCatalogKotlinVersion = libs.versions.kotlin.asProvider().get()
if (kotlinVersionOverride != versionCatalogKotlinVersion) {
throw IllegalStateException("Kotlin version in Version Catalog was not overridden. Expected:$kotlinVersionOverride, actual:$versionCatalogKotlinVersion.")
}
if (kotlinVersionOverride != currentKgpVersion) {
throw IllegalStateException("Kotlin Gradle Plugin version was not overridden. Expected:$kotlinVersionOverride, actual:$currentKgpVersion.")
}
}
allprojects {
repositories {
addDevRepositoryIfEnabled(this, project)
}
tasks.withType<KotlinCompilationTask<*>>().configureEach {
compilerOptions {
getOverriddenKotlinLanguageVersion(project)?.let {
languageVersion = KotlinVersion.fromVersion(it)
freeCompilerArgs.add("-Xsuppress-version-warnings")
}
getOverriddenKotlinApiVersion(project)?.let {
apiVersion = KotlinVersion.fromVersion(it)
}
progressiveMode = true
allWarningsAsErrors = true
}
}
}
apiValidation {
ignoredProjects += listOf(
"examples",
"java",
"kotlin-jvm-separate-benchmark-source-set",
"kotlin-jvm",
"kotlin-multiplatform",
"integration",
)
nonPublicMarkers += listOf("kotlinx.benchmark.internal.KotlinxBenchmarkRuntimeInternalApi")
@OptIn(ExperimentalBCVApi::class)
klib {
enabled = true
}
}
val checkReadme by tasks.registering(CheckReadmeTask::class) {
enabled = providers.gradleProperty("min_supported_gradle_version").orNull.isNullOrBlank()
minSupportedGradleVersion = libs.versions.minSupportedGradle
minSupportedKotlinVersion = libs.versions.minSupportedKotlin
readme = file("README.md")
}
tasks.check {
dependsOn(checkReadme)
dependsOn(tasks.named("apiCheck"))
}