https://github.com/joke/spring-factory
Annotation processor for spring factories META-INF/spring.factories
https://github.com/joke/spring-factory
annotation-processor java spring-boot
Last synced: 6 months ago
JSON representation
Annotation processor for spring factories META-INF/spring.factories
- Host: GitHub
- URL: https://github.com/joke/spring-factory
- Owner: joke
- License: apache-2.0
- Created: 2020-08-30T17:38:57.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2026-01-12T21:57:22.000Z (6 months ago)
- Last Synced: 2026-01-13T01:57:40.547Z (6 months ago)
- Topics: annotation-processor, java, spring-boot
- Language: Java
- Homepage:
- Size: 279 KB
- Stars: 6
- Watchers: 3
- Forks: 1
- Open Issues: 8
-
Metadata Files:
- Readme: README.adoc
- Contributing: CONTRIBUTING.adoc
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
= `spring-factory`
:icons: font
image:https://badgen.net/github/license/joke/spring-factory[]
image:https://github.com/joke/spring-factory/workflows/build/badge.svg?branch=master[]
image:https://badgen.net/maven/v/maven-central/io.github.joke.spring-factory/bom[link=https://search.maven.org/search?q=g:io.github.joke.spring-factory]
image:https://badgen.net/github/release/joke/spring-factory/stable[]
image:https://badgen.net/github/dependabot/joke/spring-factory[]
image:https://badgen.net/codecov/c/github/babel/babel[link=https://codecov.io/gh/joke/spring-factory]
image:https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fjoke%2Fspring-factory%2Fmaster)[link=https://dashboard.stryker-mutator.io/reports/github.com/joke/spring-factory/master]
image:https://badgen.net/github/dependabot/joke/spock-mockable[]
image:https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg[link=https://conventionalcommits.org]
image:https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit[pre-commit, link=https://github.com/pre-commit/pre-commit]
Manage your spring factories (`META-INF/spring.factories`) by annotation much like `link:https://github.com/google/auto/tree/master/service[AutoService]` does for `META-INF/services`.
* @SpringFactory accepts multiple classes
* link:https://docs.gradle.org/current/userguide/java_plugin.html#sec:incremental_annotation_processing[Gradle incremental annotation processing] supported
* Separate artifacts for annotation processor and annotations
* Bill of Materials artifact included
== Dependency Setup
image:https://img.shields.io/maven-central/v/io.github.joke.spring-factory/bom?label=maven%20central[link=https://search.maven.org/search?q=g:io.github.joke.spring-factory]
.Gradle build.gradle
[source,groovy]
----
dependencies {
annotationProcessor platform('io.github.joke.spring-factory:bom:1.0.0')
annotationProcessor 'io.github.joke.spring-factory:processor'
compileOnly platform('io.github.joke.spring-factory:bom:1.0.0')
compileOnly 'io.github.joke.spring-factory:annotations'
}
----
.Maven pom.xml
[source,xml]
----
io.github.joke.spring-factory
annotations
1.0.0
org.apache.maven.plugins
maven-compiler-plugin
3.8.1
1.8
1.8
io.github.joke.spring-factory
processor
1.0.0
----
== Usage
Manage your Spring auto `META-INF/spring.factories` by annotation.
Simply annotate your classes and let the annotation processor do the rest.
This works in the same fashion as `link:https://github.com/google/auto/tree/master/service[AutoService]`
but for Spring's factory meta files.
.Usage example
[source,java]
----
@SpringFactory(EnableAutoConfiguration.class)
public class MyAutoConfiguration {}
@SpringFactory({EnableAutoConfiguration.class, AutoConfigureDataMongo.class})
public class MyMongoAutoConfiguration {}
----
.Generated output `META-INF/spring.factories`
[source,properties]
----
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
package.name.of.first.class.MyAutoConfiguration,\
package.name.of.second.class.MyMongoAutoConfiguration
org.springframework.boot.test.autoconfigure.data.mongo.AutoConfigureDataMongo=\
package.name.of.second.class.MyMongoAutoConfiguration
----