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

update BCV to 0.15.0 #44

Draft
wants to merge 38 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
5fa768d
update bcv to 0.14.0
aSemy Jan 29, 2024
4d4ba27
- update tests
aSemy Feb 15, 2024
c68833a
minor format log message
aSemy Feb 19, 2024
832ad11
wip implementation of bcv 0.15, supporting klibs
aSemy Apr 15, 2024
4d21585
wip
aSemy May 31, 2024
5f1ce30
Merge branch 'refs/heads/main' into update/bcv-0.15.0
aSemy May 31, 2024
9b395b7
add assign util fn for `Property<KLibSignatureVersion>`
aSemy May 31, 2024
d461fb7
add util for assigning klib.signatureVersion
aSemy May 31, 2024
c7dfe2d
fix signatureVersion convention for targets
aSemy May 31, 2024
9393e69
update test util message when no tasks are found
aSemy May 31, 2024
f076934
fixing integration tests...
aSemy May 31, 2024
50d9c56
filter out KLib targets where the klib doesn't exist
aSemy May 31, 2024
7dc0753
add BCVInternalApi to supportedByCurrentHost (should only be used in …
aSemy May 31, 2024
64846ec
add Kotlin version to generated BCVProperties
aSemy May 31, 2024
a561c21
configure klib defaults
aSemy May 31, 2024
5b8234c
update method of disabling KLib targets in tests
aSemy May 31, 2024
49c79ab
tidy log
aSemy May 31, 2024
d2fdd97
fixes
aSemy May 31, 2024
37762e1
tidy kdoc
aSemy Jun 1, 2024
899de2e
prep for klib extract
aSemy Jun 1, 2024
4f2a73f
NFC: extend top-level decls test case
aSemy Jun 1, 2024
049044a
don't cache dump task if api dir is invalid
aSemy Jun 2, 2024
f7bd2da
tidying...
aSemy Jun 2, 2024
1cdbcc0
enable build cache by default in tests (so they are faster!)
aSemy Jun 2, 2024
cd51900
rm old assertion
aSemy Jun 2, 2024
402a3f4
update dump
aSemy Jun 2, 2024
eb6c795
sort BCVTargets
aSemy Jun 2, 2024
0095fff
set gradle properties using `gradle.properties`, add `--parallel`
aSemy Jun 2, 2024
3056ff4
use stable temp dir for test projects
aSemy Jun 2, 2024
64298ad
bump memory for Apple targets test
aSemy Jun 2, 2024
878bfb8
fix test assertion to permit caching
aSemy Jun 2, 2024
04fb1d8
tidy logging/docs
aSemy Jun 2, 2024
7d5c4ca
change strict klib validation so it's not configurable per target, bu…
aSemy Jun 2, 2024
d994595
wip trying to get klib validation working for supported/unsupported t…
aSemy Jun 2, 2024
1c83c1f
fix adding gradle.properties to test projects
aSemy Jun 2, 2024
bf11bb7
mostly working... just a few failing klibs
aSemy Jul 15, 2024
745fc9d
update bcv to 0.15.1
aSemy Jul 15, 2024
ebd183c
tidy
aSemy Jul 15, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/run_publish_maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ jobs:
with:
runs-on: macos-latest # only macOS supports building all Kotlin targets
gradle-task: >-
publishAllPublicationsToSonatypeReleaseRepository --stacktrace --no-configuration-cache --no-parallel
publishAllPublicationsToSonatypeReleaseRepository --stacktrace --no-parallel
checkout-ref: ${{ inputs.checkout-ref }}
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ or (**experimentally**) [as a Settings plugin](#settings-plugin) in `settings.gr

#### Requirements

The minimal supported Gradle version is 7.6.
The minimal supported Gradle version is 7.6.4.

By default, BCV-MU uses BCV version `0.13.2`, which can be overridden, but may introduce runtime
By default, BCV-MU uses BCV version `0.15.1`, which can be overridden, but may introduce runtime
errors.

### Build plugin
Expand All @@ -49,7 +49,7 @@ plugins {
}
```

To initialise the API declarations, run the Gradle task
To initialize the API declarations, run the Gradle task

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

plugins {
kotlin("jvm") version "1.8.10"
kotlin("jvm") version "1.9.22"
id("dev.adamko.kotlin.binary-compatibility-validator") version "$bcvMuVersion"
}

Expand All @@ -100,7 +100,7 @@ binaryCompatibilityValidator {
bcvEnabled.set(true)

// Override the default BCV version
kotlinxBinaryCompatibilityValidatorVersion.set("0.13.2")
kotlinxBinaryCompatibilityValidatorVersion.set("0.15.1")
}
```

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

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

Expand Down
28 changes: 20 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import buildsrc.utils.generatedKotlinDslAccessorDirs
import buildsrc.utils.excludeProjectConfigurationDirs
import buildsrc.utils.filterContains

plugins {
buildsrc.conventions.base
Expand All @@ -13,20 +14,17 @@ project.version = object {

idea {
module {
excludeDirs = excludeDirs +
layout.generatedKotlinDslAccessorDirs() +
layout.files(
".idea",
"gradle/wrapper",
)
excludeProjectConfigurationDirs(layout, providers)
}
}


val readmeCheck by tasks.registering {
group = LifecycleBasePlugin.VERIFICATION_GROUP
val readme = providers.fileContents(layout.projectDirectory.file("README.md")).asText
val supportedGradleVersion = libs.versions.supportedGradleVersion
val kotlinBcvVersion = libs.versions.kotlinx.bcv
val kgpVersion = embeddedKotlinVersion

doLast {
readme.get().let { readme ->
Expand All @@ -39,6 +37,20 @@ val readmeCheck by tasks.registering {
require("The minimal supported Gradle version is ${supportedGradleVersion.get()}" in readme) {
"Incorrect Gradle version in README"
}
readme.lines()
.filterContains("kotlin(\"jvm\") version ")
.forEach { line ->
require("kotlin(\"jvm\") version \"$kgpVersion\"" in line) {
"Incorrect Kotlin JVM plugin (expected $kgpVersion) version in README\n $line"
}
}
readme.lines()
.filterContains("""org.jetbrains.kotlin:kotlin-gradle-plugin-api:""")
.forEach { line ->
require("""classpath("org.jetbrains.kotlin:kotlin-gradle-plugin-api:$kgpVersion")""" in line) {
"Incorrect kotlin-gradle-plugin-api version (expected $kgpVersion) version in README\n $line"
}
}
}
}
}
Expand All @@ -50,7 +62,7 @@ tasks.check {
val projectVersion by tasks.registering {
description = "prints the project version"
group = "help"
val version = providers.provider { project.version }
val version = providers.provider { project.version.toString() }
inputs.property("version", version)
outputs.cacheIf("logging task, it should always run") { false }
doLast {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package buildsrc.conventions

import buildsrc.settings.MavenPublishingSettings


plugins {
`maven-publish`
signing
Expand All @@ -16,7 +17,7 @@ publishing {
publications.withType<MavenPublication>().configureEach {
pom {
name.convention("Binary Compatibility Validator MU")
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.")
description.convention("BCV-MU is a Gradle Plugin that validates the public API of libraries, to make sure that breaking changes are tracked.")
url.convention("https://github.com/adamko-dev/kotlin-binary-compatibility-validator-mu")

scm {
Expand Down Expand Up @@ -89,23 +90,35 @@ signing {
//endregion


//region Fix Gradle warning about signing tasks using publishing task outputs without explicit dependencies
// https://youtrack.jetbrains.com/issue/KT-46466 https://github.com/gradle/gradle/issues/26091
tasks.withType<AbstractPublishToMaven>().configureEach {

//region Fix Gradle warning about signing tasks using publishing task outputs without explicit dependencies
// https://youtrack.jetbrains.com/issue/KT-46466 https://github.com/gradle/gradle/issues/26091
val signingTasks = tasks.withType<Sign>()
mustRunAfter(signingTasks)
}
//endregion

//endregion

//region publishing logging
tasks.withType<AbstractPublishToMaven>().configureEach {
//region publishing logging
val publicationGAV = provider { publication?.run { "$group:$artifactId:$version" } }
doLast("log publication GAV") {
if (publicationGAV.isPresent) {
logger.info("[task: ${path}] ${publicationGAV.get()}")
}
}
//endregion
}


//region Maven Central can't handle parallel uploads, so limit parallel uploads with a service.
abstract class MavenPublishLimiter : BuildService<BuildServiceParameters.None>

val mavenPublishLimiter =
gradle.sharedServices.registerIfAbsent("mavenPublishLimiter", MavenPublishLimiter::class) {
maxParallelUsages = 1
}

tasks.withType<PublishToMavenRepository>().configureEach {
usesService(mavenPublishLimiter)
}
//endregion

Expand Down
21 changes: 0 additions & 21 deletions buildSrc/src/main/kotlin/buildsrc/utils/gradle.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package buildsrc.utils

import java.io.File
import org.gradle.api.Project
import org.gradle.api.artifacts.Configuration
import org.gradle.api.component.AdhocComponentWithVariants
import org.gradle.api.file.ProjectLayout
import org.gradle.api.file.RelativePath
import org.gradle.api.tasks.SourceSet
import org.gradle.kotlin.dsl.*
Expand Down Expand Up @@ -142,22 +140,3 @@ fun SourceSet.configurationNames() =
javadocElementsConfigurationName,
sourcesElementsConfigurationName,
)

/** exclude generated Gradle code, so it doesn't clog up search results */
fun ProjectLayout.generatedKotlinDslAccessorDirs(): Set<File> {

val generatedSrcDirs = listOf(
"kotlin-dsl-accessors",
"kotlin-dsl-external-plugin-spec-builders",
"kotlin-dsl-plugins",
)

return projectDirectory.dir("buildSrc/build/generated-sources")
.asFile
.walk()
.filter { it.isDirectory && it.parentFile.name in generatedSrcDirs }
.flatMap { file ->
file.walk().maxDepth(1).filter { it.isDirectory }.toList()
}
.toSet()
}
74 changes: 74 additions & 0 deletions buildSrc/src/main/kotlin/buildsrc/utils/intellij.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package buildsrc.utils

import java.io.File
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.ProjectLayout
import org.gradle.api.provider.ProviderFactory
import org.gradle.api.provider.ValueSource
import org.gradle.api.provider.ValueSourceParameters
import org.gradle.kotlin.dsl.*
import org.gradle.plugins.ide.idea.model.IdeaModule

/**
* Exclude directories containing
*
* - generated Gradle code,
* - IDE files,
* - Gradle config,
*
* so they don't clog up search results.
*/
fun IdeaModule.excludeProjectConfigurationDirs(
layout: ProjectLayout,
providers: ProviderFactory,
) {
val excludedDirs = providers.of(IdeaExcludedDirectoriesSource::class) {
parameters.projectDir.set(layout.projectDirectory)
}

excludeDirs.addAll(excludedDirs.get())
}

// We have to use a ValueSource to find the files, otherwise Gradle
// considers _all files_ an input for configuration cache 🙄
internal abstract class IdeaExcludedDirectoriesSource
: ValueSource<Set<File>, IdeaExcludedDirectoriesSource.Parameters> {

interface Parameters : ValueSourceParameters {
val projectDir: DirectoryProperty
}

override fun obtain(): Set<File> {
val projectDir = parameters.projectDir.get().asFile

val excludedDirs = setOf(
".git",
".gradle",
".idea",
".kotlin",
)

val generatedSrcDirs = listOf(
"kotlin-dsl-accessors",
"kotlin-dsl-external-plugin-spec-builders",
"kotlin-dsl-plugins",
)

val generatedDirs = projectDir
.walk()
.onEnter { it.name !in excludedDirs && it.parentFile.name !in generatedSrcDirs }
.filter { it.isDirectory }
.filter { it.parentFile.name in generatedSrcDirs }
.flatMap { file ->
file.walk().maxDepth(1).filter { it.isDirectory }.toList()
}
.toSet()

// can't use buildSet {} https://github.com/gradle/gradle/issues/28325
return mutableSetOf<File>().apply {
addAll(generatedDirs)
add(projectDir.resolve(".idea"))
add(projectDir.resolve("gradle/wrapper"))
}
}
}
3 changes: 3 additions & 0 deletions buildSrc/src/main/kotlin/buildsrc/utils/kotlinStdlib.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ fun String.titlecaseFirstChar(): String =
else -> it.toString()
}
}

fun List<String>.filterContains(substring: String): List<String> =
filter { substring in it }
6 changes: 2 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx4g -XX:+HeapDumpOnOutOfMemoryError

org.gradle.caching=true

org.gradle.unsafe.configuration-cache=true
org.gradle.unsafe.configuration-cache-problems=warn

org.gradle.configuration-cache=true
org.gradle.configuration-cache-problems=warn
org.gradle.parallel=true
org.gradle.welcome=never

Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ kotlinGradle = "1.9.24"
javaDiffUtils = "4.12"
junit = "5.10.2"
kotest = "5.9.0"
kotlinx-bcv = "0.13.2"
kotlinx-bcv = "0.15.1"

gradlePluginPublishPlugin = "1.2.1"
shadowPlugin = "8.1.1"
devPublish = "0.3.0"
bcvMu = "main-SNAPSHOT"

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

[libraries]

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
Loading