An open API service indexing awesome lists of open source software.

https://github.com/intuit/hooks

Hooks is a little module for plugins, in Kotlin
https://github.com/intuit/hooks

gradle-plugin hooks kotlin-compiler-plugin maven-plugin plugin-framework plugins

Last synced: 2 months ago
JSON representation

Hooks is a little module for plugins, in Kotlin

Awesome Lists containing this project

README

          


Hooks Logo




Hooks is a little module for plugins, in Kotlin


---


Auto Release
CircleCI
Maven Central
Gradle Plugin Portal

GitHub top language
KtLint
All Contributors


Hooks represent "pluggable" points in a software model. They provide a mechanism for tapping into such points to get updates, or apply additional functionality to some typed object. Included in the hooks library are:
- A variety of hooks to support different plugin behavior: `Basic, Waterfall, Bail, Loop`
- Asynchronous support built on Kotlin [coroutines](https://kotlinlang.org/docs/coroutines-guide.html)
- Support for additional [hook context](https://intuit.github.io/hooks/wiki/key-concepts/#hook-context) and [interceptors](https://intuit.github.io/hooks/wiki/key-concepts/#interceptors)

Along with the base library, we created a Kotlin symbol processor to enable hooks to be created with a simple typed-based DSL, limiting the redundancy and overhead required to subclass a hook.

Visit our [site](https://intuit.github.io/hooks/) for information about how to use hooks.

## Inspiration

At Intuit, we're big fans of [tapable](https://github.com/webpack/tapable). We use it in some of our core systems to
enable teams to augment and extend our frameworks to solve their customer problems. Since our backend systems are
primarily JVM-based, we really missed tapable when working in service code. Hooks is our implementation of tapable as a
library for the JVM plus an [Arrow Meta](https://meta.arrow-kt.io/) Compiler Plugin to make it easier to use.

## Structure

- [hooks](https://github.com/intuit/hooks/tree/main/hooks) - The actual implementation of the hooks
- [processor](https://github.com/intuit/hooks/tree/main/processor) - A Kotlin Symbol Processor that generates hook subclasses for you
- [gradle-plugin](https://github.com/intuit/hooks/tree/main/gradle-plugin) - A Gradle plugin to make using the processor easier
- [maven-plugin](https://github.com/intuit/hooks/tree/main/maven-plugin) - A Maven Kotlin plugin extension to make using the processor easier
- [example-library](https://github.com/intuit/hooks/tree/main/example-library) - A library that exposes extension points for consumers using the hooks' `call` function
- [example-application](https://github.com/intuit/hooks/tree/main/example-application) - The Application that demonstrates extending a library by calling the hooks' `tap` function

## :beers: Contributing :beers:

Feel free to make an [issue](https://github.com/intuit/hooks/issues) or open a [pull request](https://github.com/intuit/hooks/pulls) if you have an improvement and new plugin to propose!

Make sure to read our [code of conduct](./.github/CODE_OF_CONDUCT.md).

## :hammer: Start Developing :hammer:

To get set up, fork and clone the project.

### Build

Build and verify all checks:

```bash
./gradlew build
```

Publish locally to use in other projects:

```bash
./gradlew publishToMavenLocal
```

### Test

Recompile changes and run all tests:

```bash
./gradlew test
```

### Run example app

```bash
./gradlew run
```

### Cleaning

```bash
./gradlew clean
```

### Linting

Linting is done with [ktlint](https://github.com/pinterest/ktlint) and configured using [JLLeitschuh's ktlint Gradle plugin](https://github.com/JLLeitschuh/ktlint-gradle).

Format code according to linting standards:

```bash
./gradlew ktlintFormat
```

Verify code meets linting standards:

```bash
./gradlew ktlintCheck
```

### API Validation

To ensure that binary compatibility is maintained across non-breaking releases, the public API is validated using the Kotlin [binary compatibility validator](https://github.com/Kotlin/binary-compatibility-validator) tool.

Update the API dumps:

```bash
./gradlew apiDump
```

Verify the public API matches the API dumps:

```bash
./gradlew apiCheck
```

### Documentation

The docs site is built using the [Orchid](https://orchid.run/) tool and takes inspiration from the [stikt.io docs site](https://strikt.io/).

Run the docs locally:

```bash
./gradlew orchidServe
```

The [knit](https://github.com/Kotlin/kotlinx-knit) tool is also used to generate tests driven from markdown snippets to ensure documentation is maintained and up-to-date.

Update all generated markdown tests:

```bash
./gradlew knit
```

Verify the generated tests match the latest markdown changes:

```bash
./gradlew knitCheck
```

### Versioning

This project follows the [semantic versioning](https://semver.org/) strategy and uses [Auto](https://intuit.github.io/auto/) to automate releases on CI. PRs must be labeled with an appropriate Auto label to denote what type of release should occur when merged. With the binary compatibility validator tool, we can follow this set of rules to determine release types:

- Red on an API diff is breaking and requires a major bump
- Green on an API diff is a new feature and requires a minor bump
- No API diff, but has a code change requires a patch bump
- Else, apply the corresponding label for documentation or build, etc.

## Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):



Jeremiah Zucker

⚠️ 💻 📖 🚇

David Stone

📖 ⚠️ 💻

Andrew Lisowski

📖 🚇 ⚠️ 💻

Kelly Harrop

🎨

brocollie08

⚠️ 💻

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

## License

[![FOSSA Status](https://app.fossa.com/api/projects/custom%2B23410%2Fgit%40github.com%3Aintuit%2Fhooks.svg?type=large)](https://app.fossa.com/projects/custom%2B23410%2Fgit%40github.com%3Aintuit%2Fhooks?ref=badge_large)

This product includes software developed by the Apache Software Foundation (http://www.apache.org/).