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

https://github.com/emilyy-dev/annotated-service-provider

Define Java service providers by annotating them directly
https://github.com/emilyy-dev/annotated-service-provider

annotation annotation-processor java service-provider serviceloader

Last synced: 3 months ago
JSON representation

Define Java service providers by annotating them directly

Awesome Lists containing this project

README

          

# Annotated Service Provider
### Define JVM service providers by annotating the provider class directly.
[![Maven Central](https://img.shields.io/maven-central/v/io.github.emilyy-dev/annotated-service-provider?color=yellowgreen&label=maven%20central)](https://search.maven.org/artifact/io.github.emilyy-dev/annotated-service-provider)
[![Snapshot](https://img.shields.io/nexus/s/io.github.emilyy-dev/annotated-service-provider?label=snapshot&server=https%3A%2F%2Fs01.oss.sonatype.org)](https://s01.oss.sonatype.org/content/repositories/snapshots/io/github/emilyy-dev/annotated-service-provider/)
[![License](https://img.shields.io/github/license/emilyy-dev/annotated-service-provider?color=blue)](https://github.com/emilyy-dev/annotated-service-provider/blob/main/LICENSE.txt)

This annotation processor will add to the class-path services deployment (`META-INF/services/`) provider types that are
annotated with the `@ProvidesService` annotation.

### Example usage
```java
package io.github.emilyydev.asp.demo;

import io.github.emilyydev.asp.ProvidesService;
import java.sql.Driver;

@ProvidesService(Driver.class)
public class SqlDriverImpl implements Driver {
// implementation...
}
```
The annotation processor will read the class, ensure it meets the required criterion specified by the
[ServiceLoader documentation](https://docs.oracle.com/javase/8/docs/api/java/util/ServiceLoader.html) and add the
provider type to the corresponding service file `META-INF/services/java.sql.Driver` as a new entry, in case that same
jar file provides multiple providers for the same service.

### Adding it to your project
ASP is released on Maven Central under two different artifacts:
* The annotation artifact: `io.github.emilyy-dev:annotated-service-provider:{version}`.
* The annotation processor artifact: `io.github.emilyy-dev:annotated-service-provider-processor:{version}`.
The current version released is shown at the top of this readme. Snapshot builds can be found in OSS sonatype
(https://s01.oss.sonatype.org/content/repositories/snapshots/)

Importing ASP to your project:
* Using Gradle
```groovy
repositories {
mavenCentral()
}

dependencies {
implementation("io.github.emilyy-dev:annotated-service-provider:{version}")
annotationProcessor("io.github.emilyy-dev:annotated-service-provider-processor:{version}")
}
```
> Note: if your project uses Kotlin you need to use [**`kapt`**](https://kotlinlang.org/docs/kapt.html) to use
> annotation processors instead.

* Using Maven
```xml






org.apache.maven.plugins
maven-compiler-plugin
3.8.1



io.github.emilyy-dev
annotated-service-provider-processor
{version}








io.github.emilyy-dev
annotated-service-provider
{version}
provided

```

### License
This project is licensed under the MIT license.