Skip to content

Commit 45dfc68

Browse files
authored
update BCV to 0.13.1 (#7)
- implement explicit-public properties - tidy up test data - minor README updates
1 parent b05170d commit 45dfc68

Some content is hidden

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

46 files changed

+497
-308
lines changed

README.md

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,22 @@
33

44
# Kotlin Binary Compatibility Validator (Mirror Universe)
55

6-
[BCV-MU](https://github.com/adamko-dev/kotlin-binary-compatibility-validator-mu) is a
7-
re-imagined [Gradle](https://gradle.org/) Plugin for
8-
[Kotlin/binary-compatibility-validator](https://github.com/Kotlin/binary-compatibility-validator).
6+
[BCV-MU](https://github.com/adamko-dev/kotlin-binary-compatibility-validator-mu)
7+
is a [Gradle](https://gradle.org/) Plugin that validates the public JVM binary API of libraries, to
8+
make sure that breaking changes are tracked.
99

10-
This plugin validates the public JVM binary API of libraries to make sure that breaking changes are
11-
tracked.
10+
BCV-MU is based on
11+
[Kotlin/binary-compatibility-validator](https://github.com/Kotlin/binary-compatibility-validator),
12+
and contains improvements to better work with the Gradle API, especially in large projects.
1213

13-
Read more in the BCV project:
14+
Read more about the validation of the public API in the BCV project:
1415

1516
* [What constitutes the public API?](https://github.com/Kotlin/binary-compatibility-validator/#what-constitutes-the-public-api)
1617
* [What makes an incompatible change to the public binary API?](https://github.com/Kotlin/binary-compatibility-validator/#what-makes-an-incompatible-change-to-the-public-binary-api)
1718

18-
(The [Mirror Universe](https://en.wikipedia.org/wiki/Mirror_Universe) tag was chosen because I hope
19-
to banish this plugin as soon the improvements here are merged upstream.)
19+
(The MU tag was chosen because I hope to banish this plugin to the
20+
[Mirror Universe](https://en.wikipedia.org/wiki/Mirror_Universe)
21+
as soon the improvements here are merged upstream.)
2022

2123
### Description
2224

@@ -30,7 +32,7 @@ or (**experimentally**) [as a Settings plugin](#settings-plugin) in `settings.gr
3032

3133
The minimal supported Gradle version is 7.6.
3234

33-
By default, BCV-MU uses BCV version `0.13.0`, which can be overridden, but may introduce runtime
35+
By default, BCV-MU uses BCV version `0.13.1`, which can be overridden, but may introduce runtime
3436
errors.
3537

3638
### Build plugin
@@ -75,6 +77,14 @@ plugins {
7577
}
7678

7779
binaryCompatibilityValidator {
80+
81+
// Explicitly include specific classes, markers, or packages.
82+
// If any class, marker, or package is defined then all other declarations will be excluded.
83+
// If no explicit public declarations are defined, then all declarations will be included by default.
84+
publicClasses.add("com.company.api.FooPublicClass")
85+
publicMarkers.add("com.company.api.ExplicitApiAnnotation")
86+
publicPackages.add("com.company.api")
87+
7888
// Packages that are excluded from public API dumps even if they contain public API.
7989
ignoredPackages.add("kotlinx.coroutines.internal")
8090
// Classes (fully qualified) that are excluded from public API dumps even if they contain public API.
@@ -88,14 +98,14 @@ binaryCompatibilityValidator {
8898
bcvEnabled.set(true)
8999

90100
// Override the default BCV version
91-
kotlinxBinaryCompatibilityValidatorVersion.set("0.13.0")
101+
kotlinxBinaryCompatibilityValidatorVersion.set("0.13.1")
92102
}
93103
```
94104

95105
##### Advanced configuration
96106

97-
BCV automatically generates 'targets' for each Kotlin/JVM target that it finds.
98-
These targets can be specifically modified, or manually defined, for fine-grained control.
107+
BCV automatically generates 'targets' for each Kotlin/JVM source set that it finds.
108+
these `BCVTarget`s can be specifically modified, or manually defined, for fine-grained control.
99109

100110
```kotlin
101111
// build.gradle.kts

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ kotlinGradle = "1.6.0"
55
javaDiffUtils = "4.12"
66
junit = "5.9.2"
77
kotest = "5.5.5"
8-
kotlinx-bcv = "0.13.0"
8+
kotlinx-bcv = "0.13.1"
99

1010
gradlePluginPublishPlugin = "1.1.0"
1111
shadowPlugin = "8.1.0"

modules/bcv-gradle-plugin-functional-tests/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ dependencies {
2323
testFixturesApi(testFixtures(projects.modules.bcvGradlePlugin))
2424
}
2525

26-
2726
@Suppress("UnstableApiUsage")
2827
testing.suites {
2928
withType<JvmTestSuite>().configureEach {

modules/bcv-gradle-plugin-functional-tests/src/functionalTest/kotlin/kotlinx/validation/test/JavaTestFixturesTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ private fun FunSpec.createTestFixturesProject(
125125
buildGradleKts = """
126126
|plugins {
127127
| kotlin("jvm") version "1.7.10"
128-
| id("dev.adamko.kotlin.binary-compatibility-validator") version "0.0.4-SNAPSHOT"
128+
| id("dev.adamko.kotlin.binary-compatibility-validator") version "0.0.5-SNAPSHOT"
129129
| `java-test-fixtures`
130130
|}
131131
|
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package kotlinx.validation.test
2+
3+
import dev.adamko.kotlin.binary_compatibility_validator.test.utils.api.*
4+
import dev.adamko.kotlin.binary_compatibility_validator.test.utils.build
5+
import dev.adamko.kotlin.binary_compatibility_validator.test.utils.shouldHaveTaskWithOutcome
6+
import org.gradle.testkit.runner.TaskOutcome.SUCCESS
7+
import org.junit.jupiter.api.Test
8+
9+
class MixedMarkersTest : BaseKotlinGradleTest() {
10+
11+
@Test
12+
fun testMixedMarkers() {
13+
val runner = test {
14+
buildGradleKts {
15+
resolve("/examples/gradle/base/withPlugin.gradle.kts")
16+
resolve("/examples/gradle/configuration/publicMarkers/mixedMarkers.gradle.kts")
17+
}
18+
19+
kotlin("MixedAnnotations.kt") {
20+
resolve("/examples/classes/MixedAnnotations.kt")
21+
}
22+
23+
apiFile(projectName = rootProjectDir.name) {
24+
resolve("/examples/classes/MixedAnnotations.dump")
25+
}
26+
27+
runner {
28+
arguments.add(":apiCheck")
29+
}
30+
}
31+
32+
runner.build {
33+
shouldHaveTaskWithOutcome(":apiCheck", SUCCESS)
34+
}
35+
}
36+
}

modules/bcv-gradle-plugin-functional-tests/src/functionalTest/kotlin/kotlinx/validation/test/NonPublicMarkersTest.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package kotlinx.validation.test
22

33
import dev.adamko.kotlin.binary_compatibility_validator.test.utils.api.*
44
import dev.adamko.kotlin.binary_compatibility_validator.test.utils.build
5-
import dev.adamko.kotlin.binary_compatibility_validator.test.utils.shouldHaveOutcome
65
import dev.adamko.kotlin.binary_compatibility_validator.test.utils.shouldHaveTaskWithOutcome
76
import org.gradle.testkit.runner.TaskOutcome.SUCCESS
87
import org.junit.jupiter.api.Test
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package kotlinx.validation.test
2+
3+
import dev.adamko.kotlin.binary_compatibility_validator.test.utils.api.*
4+
import dev.adamko.kotlin.binary_compatibility_validator.test.utils.build
5+
import dev.adamko.kotlin.binary_compatibility_validator.test.utils.shouldHaveTaskWithOutcome
6+
import org.gradle.testkit.runner.TaskOutcome.SUCCESS
7+
import org.junit.jupiter.api.Test
8+
9+
class PublicMarkersTest : BaseKotlinGradleTest() {
10+
11+
@Test
12+
fun testPublicMarkers() {
13+
val runner = test {
14+
buildGradleKts {
15+
resolve("/examples/gradle/base/withPlugin.gradle.kts")
16+
resolve("/examples/gradle/configuration/publicMarkers/markers.gradle.kts")
17+
}
18+
19+
kotlin("ClassWithPublicMarkers.kt") {
20+
resolve("/examples/classes/ClassWithPublicMarkers.kt")
21+
}
22+
23+
kotlin("ClassInPublicPackage.kt") {
24+
resolve("/examples/classes/ClassInPublicPackage.kt")
25+
}
26+
27+
apiFile(projectName = rootProjectDir.name) {
28+
resolve("/examples/classes/ClassWithPublicMarkers.dump")
29+
}
30+
31+
runner {
32+
arguments.add(":apiCheck")
33+
}
34+
}
35+
36+
runner.build {
37+
shouldHaveTaskWithOutcome(":apiCheck", SUCCESS)
38+
}
39+
}
40+
}

modules/bcv-gradle-plugin-functional-tests/src/functionalTest/kotlin/kotlinx/validation/test/SettingsPluginDslTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ buildscript {
154154
155155
156156
plugins {
157-
id("dev.adamko.kotlin.binary-compatibility-validator") version "0.0.4-SNAPSHOT"
157+
id("dev.adamko.kotlin.binary-compatibility-validator") version "0.0.5-SNAPSHOT"
158158
}
159159
160160
include(
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
/*
2-
* Copyright 2016-2020 JetBrains s.r.o.
3-
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file.
4-
*/
5-
61
package org.different.pack
72

83
public class BuildConfig {
9-
public val p1 = 1
4+
public val p1 = 1
105

11-
public fun f1() = p1
12-
}
6+
public fun f1() = p1
7+
}
Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
/*
2-
* Copyright 2016-2020 JetBrains s.r.o.
3-
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file.
4-
*/
5-
61
package com.company
72

83
public class BuildConfig {
9-
public val property = 1
4+
public val property = 1
105

11-
public fun function() = property
12-
}
6+
public fun function() = property
7+
}

0 commit comments

Comments
 (0)