Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/manosbatsis/kotlin-utils

KotlinPoet Annotation Processor Utilities
https://github.com/manosbatsis/kotlin-utils

Last synced: about 2 months ago
JSON representation

KotlinPoet Annotation Processor Utilities

Awesome Lists containing this project

README

        

# Kotlin Utils [![Maven Central](https://img.shields.io/maven-central/v/com.github.manosbatsis.kotlin-utils/kotlin-utils-api.svg)](https://repo1.maven.org/maven2/com/github/manosbatsis/kotlin-utils/kotlin-utils-api/)

## Utils API

Commons utilities for code generated by [Utils Kapt](#utils-kapt) or Kotlin apps in general.

## Utils Kapt

KotlinPoet/Kapt utilities for Kotlin annotation processor (sub)components.

Add to your build:

```groovy

dependencies {
// ...
api("com.github.manosbatsis.kotlin-utils:kotlin-utils-kapt:$kotlinpoetutils_version")
}
```

To use, add the `ProcessingEnvironmentAware` to your annotation processor:

```kotlin
import javax.annotation.processing.AbstractProcessor.AbstractProcessor
import com.github.manosbatsis.kotlin.utils.ProcessingEnvironmentAware

class MyAnnotationProcessor : AbstractProcessor(), ProcessingEnvironmentAware {


/**
* Implement [ProcessingEnvironmentAware.processingEnvironment]
* for access to a [ProcessingEnvironment]
*/
override val processingEnvironment: ProcessingEnvironment by lazy {
processingEnv
}
}
```

... or sub-component:

```kotlin
import javax.annotation.processing.AbstractProcessor.AbstractProcessor
import com.github.manosbatsis.kotlin.utils.ProcessingEnvironmentAware

class MyCustomAnnotationProcessingComponent(
override val processingEnvironment: ProcessingEnvironment
) : ProcessingEnvironmentAware {

fun doSometing(){
// Do it!
}

}
```