Skip to content

Commit 832ad11

Browse files
committed
wip implementation of bcv 0.15, supporting klibs
1 parent c68833a commit 832ad11

File tree

110 files changed

+3457
-494
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+3457
-494
lines changed

.github/workflows/run_publish_maven.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ jobs:
4040
with:
4141
runs-on: macos-latest # only macOS supports building all Kotlin targets
4242
gradle-task: >-
43-
publishAllPublicationsToSonatypeReleaseRepository --stacktrace --no-configuration-cache --no-parallel
43+
publishAllPublicationsToSonatypeReleaseRepository --stacktrace --no-parallel
4444
checkout-ref: ${{ inputs.checkout-ref }}

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ or (**experimentally**) [as a Settings plugin](#settings-plugin) in `settings.gr
3232

3333
#### Requirements
3434

35-
The minimal supported Gradle version is 7.6.
35+
The minimal supported Gradle version is 7.6.4.
3636

37-
By default, BCV-MU uses BCV version `0.14.0`, which can be overridden, but may introduce runtime
37+
By default, BCV-MU uses BCV version `0.15.0-Beta.2`, which can be overridden, but may introduce runtime
3838
errors.
3939

4040
### Build plugin
@@ -49,7 +49,7 @@ plugins {
4949
}
5050
```
5151

52-
To initialise the API declarations, run the Gradle task
52+
To initialize the API declarations, run the Gradle task
5353

5454
```shell
5555
./gradlew apiDump
@@ -74,7 +74,7 @@ BCV-MU can be configured in a similar manner to BCV:
7474
// build.gradle.kts
7575

7676
plugins {
77-
kotlin("jvm") version "1.8.10"
77+
kotlin("jvm") version "1.9.22"
7878
id("dev.adamko.kotlin.binary-compatibility-validator") version "$bcvMuVersion"
7979
}
8080

@@ -100,7 +100,7 @@ binaryCompatibilityValidator {
100100
bcvEnabled.set(true)
101101

102102
// Override the default BCV version
103-
kotlinxBinaryCompatibilityValidatorVersion.set("0.14.0")
103+
kotlinxBinaryCompatibilityValidatorVersion.set("0.15.0-Beta.2")
104104
}
105105
```
106106

@@ -113,7 +113,7 @@ these `BCVTarget`s can be specifically modified, or manually defined, for fine-g
113113
// build.gradle.kts
114114

115115
plugins {
116-
kotlin("jvm") version "1.8.10"
116+
kotlin("jvm") version "1.9.22"
117117
id("dev.adamko.kotlin.binary-compatibility-validator") version "$bcvMuVersion"
118118
`java-test-fixtures`
119119
}
@@ -214,7 +214,7 @@ All subprojects are included by default, and can be excluded using BCV-MU config
214214
buildscript {
215215
dependencies {
216216
// BCV-MU requires the Kotlin Gradle Plugin classes are present
217-
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.8.10")
217+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.9.22")
218218
}
219219
}
220220

build.gradle.kts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import buildsrc.utils.generatedKotlinDslAccessorDirs
1+
import buildsrc.utils.excludeProjectConfigurationDirs
2+
import buildsrc.utils.filterContains
23

34
plugins {
45
buildsrc.conventions.base
@@ -13,20 +14,17 @@ project.version = object {
1314

1415
idea {
1516
module {
16-
excludeDirs = excludeDirs +
17-
layout.generatedKotlinDslAccessorDirs() +
18-
layout.files(
19-
".idea",
20-
"gradle/wrapper",
21-
)
17+
excludeProjectConfigurationDirs(layout, providers)
2218
}
2319
}
2420

21+
2522
val readmeCheck by tasks.registering {
2623
group = LifecycleBasePlugin.VERIFICATION_GROUP
2724
val readme = providers.fileContents(layout.projectDirectory.file("README.md")).asText
2825
val supportedGradleVersion = libs.versions.supportedGradleVersion
2926
val kotlinBcvVersion = libs.versions.kotlinx.bcv
27+
val kgpVersion = embeddedKotlinVersion
3028

3129
doLast {
3230
readme.get().let { readme ->
@@ -39,6 +37,20 @@ val readmeCheck by tasks.registering {
3937
require("The minimal supported Gradle version is ${supportedGradleVersion.get()}" in readme) {
4038
"Incorrect Gradle version in README"
4139
}
40+
readme.lines()
41+
.filterContains("kotlin(\"jvm\") version ")
42+
.forEach { line ->
43+
require("kotlin(\"jvm\") version \"$kgpVersion\"" in line) {
44+
"Incorrect Kotlin JVM plugin (expected $kgpVersion) version in README\n $line"
45+
}
46+
}
47+
readme.lines()
48+
.filterContains("""org.jetbrains.kotlin:kotlin-gradle-plugin-api:""")
49+
.forEach { line ->
50+
require("""classpath("org.jetbrains.kotlin:kotlin-gradle-plugin-api:$kgpVersion")""" in line) {
51+
"Incorrect kotlin-gradle-plugin-api version (expected $kgpVersion) version in README\n $line"
52+
}
53+
}
4254
}
4355
}
4456
}
@@ -50,7 +62,7 @@ tasks.check {
5062
val projectVersion by tasks.registering {
5163
description = "prints the project version"
5264
group = "help"
53-
val version = providers.provider { project.version }
65+
val version = providers.provider { project.version.toString() }
5466
inputs.property("version", version)
5567
outputs.cacheIf("logging task, it should always run") { false }
5668
doLast {

buildSrc/src/main/kotlin/buildsrc/conventions/gradle-plugin-variants.gradle.kts

Lines changed: 0 additions & 57 deletions
This file was deleted.

buildSrc/src/main/kotlin/buildsrc/conventions/maven-publishing.gradle.kts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package buildsrc.conventions
22

33
import buildsrc.settings.MavenPublishingSettings
44

5+
56
plugins {
67
`maven-publish`
78
signing
@@ -16,7 +17,7 @@ publishing {
1617
publications.withType<MavenPublication>().configureEach {
1718
pom {
1819
name.convention("Binary Compatibility Validator MU")
19-
description.convention("BCV-MU is a Gradle Plugin that validates the public JVM binary API of libraries, to make sure that breaking changes are tracked.")
20+
description.convention("BCV-MU is a Gradle Plugin that validates the public API of libraries, to make sure that breaking changes are tracked.")
2021
url.convention("https://github.com/adamko-dev/kotlin-binary-compatibility-validator-mu")
2122

2223
scm {
@@ -89,23 +90,35 @@ signing {
8990
//endregion
9091

9192

92-
//region Fix Gradle warning about signing tasks using publishing task outputs without explicit dependencies
93-
// https://youtrack.jetbrains.com/issue/KT-46466 https://github.com/gradle/gradle/issues/26091
9493
tasks.withType<AbstractPublishToMaven>().configureEach {
94+
95+
//region Fix Gradle warning about signing tasks using publishing task outputs without explicit dependencies
96+
// https://youtrack.jetbrains.com/issue/KT-46466 https://github.com/gradle/gradle/issues/26091
9597
val signingTasks = tasks.withType<Sign>()
9698
mustRunAfter(signingTasks)
97-
}
98-
//endregion
99-
99+
//endregion
100100

101-
//region publishing logging
102-
tasks.withType<AbstractPublishToMaven>().configureEach {
101+
//region publishing logging
103102
val publicationGAV = provider { publication?.run { "$group:$artifactId:$version" } }
104103
doLast("log publication GAV") {
105104
if (publicationGAV.isPresent) {
106105
logger.info("[task: ${path}] ${publicationGAV.get()}")
107106
}
108107
}
108+
//endregion
109+
}
110+
111+
112+
//region Maven Central can't handle parallel uploads, so limit parallel uploads with a service.
113+
abstract class MavenPublishLimiter : BuildService<BuildServiceParameters.None>
114+
115+
val mavenPublishLimiter =
116+
gradle.sharedServices.registerIfAbsent("mavenPublishLimiter", MavenPublishLimiter::class) {
117+
maxParallelUsages = 1
118+
}
119+
120+
tasks.withType<PublishToMavenRepository>().configureEach {
121+
usesService(mavenPublishLimiter)
109122
}
110123
//endregion
111124

buildSrc/src/main/kotlin/buildsrc/utils/gradle.kt

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package buildsrc.utils
22

3-
import java.io.File
43
import org.gradle.api.Project
54
import org.gradle.api.artifacts.Configuration
65
import org.gradle.api.component.AdhocComponentWithVariants
7-
import org.gradle.api.file.ProjectLayout
86
import org.gradle.api.file.RelativePath
97
import org.gradle.api.tasks.SourceSet
108
import org.gradle.kotlin.dsl.*
@@ -142,19 +140,3 @@ fun SourceSet.configurationNames() =
142140
javadocElementsConfigurationName,
143141
sourcesElementsConfigurationName,
144142
)
145-
146-
/** exclude generated Gradle code, so it doesn't clog up search results */
147-
fun ProjectLayout.generatedKotlinDslAccessorDirs(): Set<File> {
148-
149-
val generatedSrcDirs = listOf(
150-
"kotlin-dsl-accessors",
151-
"kotlin-dsl-external-plugin-spec-builders",
152-
"kotlin-dsl-plugins",
153-
)
154-
155-
return projectDirectory.asFile.walk()
156-
.filter { it.isDirectory && it.parentFile.name in generatedSrcDirs }
157-
.flatMap { file ->
158-
file.walk().maxDepth(1).filter { it.isDirectory }.toList()
159-
}.toSet()
160-
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,74 @@
11
package buildsrc.utils
22

33
import java.io.File
4+
import org.gradle.api.file.DirectoryProperty
45
import org.gradle.api.file.ProjectLayout
6+
import org.gradle.api.provider.ProviderFactory
7+
import org.gradle.api.provider.ValueSource
8+
import org.gradle.api.provider.ValueSourceParameters
9+
import org.gradle.kotlin.dsl.*
10+
import org.gradle.plugins.ide.idea.model.IdeaModule
11+
12+
/**
13+
* Exclude directories containing
14+
*
15+
* - generated Gradle code,
16+
* - IDE files,
17+
* - Gradle config,
18+
*
19+
* so they don't clog up search results.
20+
*/
21+
fun IdeaModule.excludeProjectConfigurationDirs(
22+
layout: ProjectLayout,
23+
providers: ProviderFactory,
24+
) {
25+
val excludedDirs = providers.of(IdeaExcludedDirectoriesSource::class) {
26+
parameters.projectDir.set(layout.projectDirectory)
27+
}
28+
29+
excludeDirs.addAll(excludedDirs.get())
30+
}
31+
32+
// We have to use a ValueSource to find the files, otherwise Gradle
33+
// considers _all files_ an input for configuration cache 🙄
34+
internal abstract class IdeaExcludedDirectoriesSource
35+
: ValueSource<Set<File>, IdeaExcludedDirectoriesSource.Parameters> {
36+
37+
interface Parameters : ValueSourceParameters {
38+
val projectDir: DirectoryProperty
39+
}
40+
41+
override fun obtain(): Set<File> {
42+
val projectDir = parameters.projectDir.get().asFile
43+
44+
val excludedDirs = setOf(
45+
".git",
46+
".gradle",
47+
".idea",
48+
".kotlin",
49+
)
50+
51+
val generatedSrcDirs = listOf(
52+
"kotlin-dsl-accessors",
53+
"kotlin-dsl-external-plugin-spec-builders",
54+
"kotlin-dsl-plugins",
55+
)
56+
57+
val generatedDirs = projectDir
58+
.walk()
59+
.onEnter { it.name !in excludedDirs && it.parentFile.name !in generatedSrcDirs }
60+
.filter { it.isDirectory }
61+
.filter { it.parentFile.name in generatedSrcDirs }
62+
.flatMap { file ->
63+
file.walk().maxDepth(1).filter { it.isDirectory }.toList()
64+
}
65+
.toSet()
66+
67+
// can't use buildSet {} https://github.com/gradle/gradle/issues/28325
68+
return mutableSetOf<File>().apply {
69+
addAll(generatedDirs)
70+
add(projectDir.resolve(".idea"))
71+
add(projectDir.resolve("gradle/wrapper"))
72+
}
73+
}
74+
}

buildSrc/src/main/kotlin/buildsrc/utils/kotlinStdlib.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ fun String.titlecaseFirstChar(): String =
77
else -> it.toString()
88
}
99
}
10+
11+
fun List<String>.filterContains(substring: String): List<String> =
12+
filter { substring in it }

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
org.gradle.jvmargs=-Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError
1+
org.gradle.jvmargs=-Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError -Xmx2g -XX:MaxMetaspaceSize=512m
22

33
org.gradle.caching=true
44

5-
org.gradle.unsafe.configuration-cache=true
6-
org.gradle.unsafe.configuration-cache-problems=warn
5+
org.gradle.configuration-cache=true
6+
org.gradle.configuration-cache-problems=warn
77

88
org.gradle.parallel=true
99
org.gradle.welcome=never

gradle/libs.versions.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
[versions]
22

3-
kotlinGradle = "1.9.22"
3+
kotlinGradle = "1.9.23"
44

55
javaDiffUtils = "4.12"
6-
junit = "5.10.1"
7-
kotest = "5.8.0"
8-
kotlinx-bcv = "0.14.0"
6+
junit = "5.10.2"
7+
kotest = "5.8.1"
8+
kotlinx-bcv = "0.15.0-Beta.2"
99

1010
gradlePluginPublishPlugin = "1.2.1"
1111
shadowPlugin = "8.1.1"
1212
devPublish = "0.2.0"
1313
bcvMu = "main-SNAPSHOT"
1414

15-
supportedGradleVersion = "7.6" # the minimal supported Gradle plugin version, used in functional tests
15+
supportedGradleVersion = "7.6.4" # the minimal supported Gradle plugin version, used in functional tests
1616

1717
[libraries]
1818

0 commit comments

Comments
 (0)