Skip to content

Commit 7fc1b30

Browse files
committed
Add a document describing how to migrate a project to BCV 0.15.0
1 parent df5c4f9 commit 7fc1b30

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

docs/design/0.15.0-migration-guide.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
The major feature shipped with the release 0.15.0 of the Binary Compatibility Validator is Kotlin libraries (or KLibs)
2+
ABI validation support.
3+
4+
This support, however, comes with a few changes that break the plugin's compatibility:
5+
- ABI file names (`api/<project name>.api`) are no longer treated in a case-insensitive way;
6+
- Gradle tasks provided by the plugin changed their API.
7+
8+
If you neither configure BCV Gradle tasks manually nor have an ABI file with a name in a case different
9+
from how the project was named in the settings, these changes won't affect you.
10+
11+
Otherwise, the steps required for smooth migration are described below.
12+
13+
### ABI file names are no longer treated in a case-insensitive way
14+
15+
Starting from the version `0.15.0`, name of an ABI dump file stored in the project's directory
16+
has to match project's name. Previously, a project named `gradle-project` might use an ABI file
17+
named `Gradle-Project.api`, but now it has to be `gradle-project.api`.
18+
19+
On case-insensitive filesystems (Windows and macOS filesystems are case-insensitive) the change won't manifest itself,
20+
but on case-sensitive filesystems (Linux filesystems) the validation will start failing due to a missing ABI dump file
21+
error.
22+
23+
You can either rename the existing file or delete it and run `apiDump` task.
24+
25+
If you're using git SCV, it's highly recommended to use `git mv` command to rename a file, or a pair of `git rm` and
26+
`git add` commands, if you're deleting the old file and then generating a new one. When done differently, git may
27+
not reflect changes in a repository index (it's specific to case-insensitive filesystems).
28+
29+
If you're using another SCV, please consult its documentation for details on how to deal with file renaming on
30+
case-insensitive filesystems.
31+
32+
### Gradle tasks provided by the plugin changed their API
33+
34+
All Gradle tasks that existed before are still presented and in use, but some of them changed
35+
their API to use Gradle Properties-based configuration. There are several advantages of using Gradle Property
36+
instead of regular Kotlin properties, but the main one is that it improves dependency tracking between tasks.
37+
You can [Gradle docs](https://docs.gradle.org/current/userguide/lazy_configuration.html) for more details
38+
on the subject.
39+
40+
The following task-classes changed their API:
41+
- KotlinApiBuildTask
42+
- `ignoredPackages`, `nonPublicMarkers`, `ignoredClasses`, `publicPackages`, `publicMarkers`, `publicClasses` are
43+
all `SetProperty<String>` instances now;
44+
- `outputApiDir` was renamed to `outputApiFile` and became `RegularFileProperty` instance; now it should point to
45+
the generated file instead of a directory holding it;
46+
- `inputClassesDirs` and `inputDependencies` are both `ConfigurableFileCollection` instances now.
47+
- KotlinApiCompareTask
48+
- `projectApiFile` and `generatedApiFile` are both `RegularFileProperty` instances now.
49+
50+
If you were configuring `KotlinApiBuildTask.outputApiDir`, `KotlinApiCompareTask.projectApiFile` or
51+
`KotlinApiCompareTask.generatedApiFile` by assigning a file instance to it, now these properties could only
52+
be configured by using [RegularFileProperty setters](https://docs.gradle.org/current/javadoc/org/gradle/api/file/RegularFileProperty.html).
53+
54+
Value assignments to `KotlinApiBuildTask.inputClassesDirs` and `KotlinApiBuildTask.inputDependencies` properties have
55+
to be replaced with [ConfigurableFileCollection setters](https://docs.gradle.org/current/javadoc/org/gradle/api/file/ConfigurableFileCollection.html).
56+
57+
All `KotlinApiBuildTask`'s filters could be configured by using [SetProperty setters](https://docs.gradle.org/current/javadoc/org/gradle/api/provider/SetProperty.html)
58+
now.
59+
60+
Below is an example of how task configuration needs to be updated:
61+
```kotlin
62+
// Old configuration
63+
val buildTask = tasks.register("buildApi", KotlinApiBuildTask::class.java) {
64+
val classes = compilation.output.classesDirs
65+
66+
it.inputClassesDirs = files(classes)
67+
it.inputDependencies = files(classes)
68+
it.outputApiDir = project.layout.buildDirectory.get().asFile
69+
it.ignoredPackages = setOf("org.example")
70+
}
71+
72+
val checkTask = tasks.register("checkApi", KotlinApiCompareTask::class.java) {
73+
it.projectApiFile = project.layout.projectDirectory.dir("api").file("gradle-project.api").asFile
74+
it.generatedApiFile = project.layout.buildDirectory.get().asFile.resolve("dump.api")
75+
76+
it.dependsOn(buildTask)
77+
}
78+
```
79+
80+
```kotlin
81+
// New configuration
82+
val buildTask = tasks.register("buildApi", KotlinApiBuildTask::class.java) {
83+
val classes = compilation.output.classesDirs
84+
85+
it.inputClassesDirs.from(classes)
86+
it.inputDependencies.from(classes)
87+
it.outputApiFile.set(project.layout.buildDirectory.map { it.file("gradle-project.api") })
88+
it.ignoredPackages.set(setOf("org.example"))
89+
}
90+
val checkTask = tasks.register("checkApi", KotlinApiCompareTask::class.java) {
91+
it.projectApiFile.set(project.layout.projectDirectory.dir("api").file("gradle-project.api"))
92+
it.generatedApiFile.set(buildTask.flatMap { it.outputApiFile })
93+
}
94+
```

0 commit comments

Comments
 (0)