This project uses Semantic Versioning
FWrap is a Kotlin compiler plugin that allows you to provide callbacks for arbitrary function that will be called before and after its execution.
To get callbacks before and after function execution you just need to register provider with an identifier. Then you can use it to wrap function using @Wrap
annotation.
registerProvider(
id = "foo",
callBefore = { println("Hello from function `${it.name}()`.") },
callAfter = { println("Goodbye, return value was `$it`.") }
)
@Wrap(["foo"])
fun bar() = 42
Executing function bar
will produce following output:
Hello from function `bar()`.
Goodbye, return value was `42`.
You can find more usage examples in fwrap-samples
directory.
To use the plugin add following to your build.gradle
:
plugins {
id "fwrap.plugin" version "0.0.2"
}
//...
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
//...
dependencies {
implementation "com.github.staakk.fwrap:fwrap-lib:0.0.2"
}
Alternatively if you are using Gradle with Kotlin:
plugins {
id("fwrap.plugin") version "0.0.2"
}
//...
allprojects {
repositories {
maven(url = "https://jitpack.io")
}
}
//...
dependencies {
implementation("com.github.staakk.fwrap:fwrap-lib:0.0.2")
}