-
-
Notifications
You must be signed in to change notification settings - Fork 124
ABI filtering
v0.42.0 adds a new feature to the extension DSL.
dependencyAnalysis {
abi {
exclusions {
// Convenience helpers
ignoreSubPackage("internal")
ignoreInternalPackages()
ignoreGeneratedCode()
// Raw, regexp-based APIs
excludeAnnotations(".*\\.Generated")
excludeClasses(".*\\.internal\\..*")
}
}
}
To understand what this means, consider the following scenario.
package com.example.Example
import com.some.Thing
class Example {
fun thing(): Thing {
return Thing()
}
}
Where Example
is a class in a library* at com.example:library:1.0
, and Thing
is provided by library com.some:thing:1.0
. Thing
is part of the ABI (binary API) of com.example:library
, because it is exposed as a return type in a public function in a public class.
* it’s important that this is a library because applications have no logical ABI whatsoever.
Given this scenario, if the build script for com.example:library
contains
dependencies {
implementation "com.some:thing:1.0"
}
then the plugin will tell you that you should change that dependency to api
.
Now consider:
dependencyAnalysis {
abi {
exclusions {
excludeClasses("com\\.example\\.Example")
}
}
}
(Recalling this takes a regex.) Now if we run buildHealth
again, the plugin will no longer suggest that com.some:thing:1.0
be api
.