Skip to content

Commit 6dd028c

Browse files
committed
additional readme docs
1 parent 00589de commit 6dd028c

File tree

3 files changed

+91
-5
lines changed

3 files changed

+91
-5
lines changed

README.md

Lines changed: 88 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ BCV-MU is a re-imagined [Gradle](https://gradle.org/) Plugin for
66
This plugin validates the public JVM binary API of libraries to make sure that breaking changes are
77
tracked.
88

9+
Read more in the BCV project:
10+
11+
* [What constitutes the public API?](https://github.com/Kotlin/binary-compatibility-validator/#what-constitutes-the-public-api)
12+
* [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)
13+
914
(The [Mirror Universe](https://en.wikipedia.org/wiki/Mirror_Universe) tag was chosen because I hope
1015
to banish this plugin as soon the improvements here are merged upstream.)
1116

@@ -14,8 +19,6 @@ to banish this plugin as soon the improvements here are merged upstream.)
1419
Under-the-hood BCV-MU still uses the signature-generation code from BCV, but the Gradle plugin has
1520
been refactored to better follow the Gradle API, and generate API signatures more flexibly.
1621

17-
### Quick start
18-
1922
BCV-MU plugin can either be [applied as to a Project](#build-plugin) in any `build.gradle(.kts)`,
2023
or (**experimentally**) [as a Settings plugin](#settings-plugin) in `settings.gradle(.kts)`.
2124

@@ -26,15 +29,96 @@ The minimal supported Gradle version is 7.6.
2629
By default, BCV-MU uses BCV version `0.13.0`, which can be overridden, but may introduce runtime
2730
errors.
2831

29-
#### Build plugin
32+
### Build plugin
33+
34+
BCV-MU can be applied to each subproject as a standard Gradle plugin.
35+
36+
```kotlin
37+
// build.gradle.kts
38+
39+
plugins {
40+
id("dev.adamko.kotlin.binary-compatibility-validator") version "$bcvMuVersion"
41+
}
42+
```
43+
44+
To initialise the API declarations, run the Gradle task
45+
46+
```shell
47+
./gradlew apiDump
48+
```
49+
50+
This will produce API files into the `./api` directory of subprojects with the BCV-MU plugin.
51+
These API declarations files must be committed to the repository.
52+
53+
To verify that the API declarations is up-to-date, run the Gradle task
54+
55+
```shell
56+
./gradlew apiCheck
57+
```
58+
59+
The `apiCheck` task will also be run whenever the `check` task is run.
60+
61+
##### Configuration
62+
63+
BCV-MU can be configured in a similar manner to BCV:
3064

31-
BCV-MU can be applied to each subproject.
65+
```kotlin
66+
// build.gradle.kts
67+
68+
plugins {
69+
kotlin("jvm") version "1.8.10"
70+
id("dev.adamko.kotlin.binary-compatibility-validator") version "$bcvMuVersion"
71+
}
72+
73+
binaryCompatibilityValidator {
74+
// Packages that are excluded from public API dumps even if they contain public API.
75+
ignoredPackages.add("kotlinx.coroutines.internal")
76+
// Classes (fully qualified) that are excluded from public API dumps even if they contain public API.
77+
ignoredClasses.add("com.company.BuildConfig")
78+
// Set of annotations that exclude API from being public.
79+
// Typically, it is all kinds of `@InternalApi` annotations that mark
80+
// effectively private API that cannot be actually private for technical reasons.
81+
ignoredMarkers.add("my.package.MyInternalApiAnnotation")
82+
83+
// Disable or enable all BCV-MU tasks for this project
84+
bcvEnabled.set(true)
85+
86+
// Override the default BCV version
87+
kotlinxBinaryCompatibilityValidatorVersion.set("0.13.0")
88+
}
89+
```
90+
91+
##### Advanced configuration
92+
93+
BCV automatically generates 'targets' for each Kotlin/JVM target that it finds.
94+
These targets can be specifically modified, or manually defined, for fine-grained control.
3295

3396
```kotlin
3497
// build.gradle.kts
3598

3699
plugins {
100+
kotlin("jvm") version "1.8.10"
37101
id("dev.adamko.kotlin.binary-compatibility-validator") version "$bcvMuVersion"
102+
`java-test-fixtures`
103+
}
104+
105+
binaryCompatibilityValidator {
106+
// these are the default values that will be used in all Targets
107+
ignoredMarkers.add("my.package.MyFirstInternalApiAnnotation")
108+
ignoredClasses.add("com.company.BuildConfig")
109+
110+
// BCV will automatically generate targets for each Kotlin/JVM target,
111+
// and each can be configured manually for fine-grained control.
112+
targets.configureEach {
113+
// values can be appended to the default values
114+
ignoredMarkers.add("my.package.MySecondInternalApiAnnotation")
115+
// Or overridden
116+
ignoredClasses.set(listOf())
117+
}
118+
// BCV Targets can also be manually defined
119+
targets.register("testFixtures") {
120+
inputJar.set(tasks.testFixturesJar)
121+
}
38122
}
39123
```
40124

build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ val readmeCheck by tasks.registering {
3131
require("BCV version `${kotlinBcvVersion.get()}`" in readme) {
3232
"Incorrect BCV version in README"
3333
}
34+
require("kotlinxBinaryCompatibilityValidatorVersion.set(\"${kotlinBcvVersion.get()}\")" in readme) {
35+
"Incorrect BCV version in README"
36+
}
3437
require("The minimal supported Gradle version is ${minimumGradleTestVersion.get()}" in readme) {
3538
"Incorrect Gradle version in README"
3639
}

modules/bcv-gradle-plugin/src/main/kotlin/BCVProjectPlugin.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,5 +169,4 @@ abstract class BCVProjectPlugin @Inject constructor(
169169
}
170170
}
171171
}
172-
173172
}

0 commit comments

Comments
 (0)