Skip to content

Latest commit

 

History

History
97 lines (82 loc) · 3.75 KB

README.adoc

File metadata and controls

97 lines (82 loc) · 3.75 KB

spring-factory

spring factory badge bom stable spring factory babel endpoint?style=flat&url=https%3A%2F%2Fbadge api.stryker mutator.io%2Fgithub spock mockable Conventional%20Commits 1.0.0 yellow pre-commit

Manage your spring factories (META-INF/spring.factories) by annotation much like AutoService does for META-INF/services.

Dependency Setup

bom?label=maven%20central

Gradle build.gradle
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
<build>
  <dependencies>
    <dependency>
      <groupId>io.github.joke.spring-factory</groupId>
      <artifactId>annotations</artifactId>
      <version>1.0.0</version>
    </dependency>
  </dependencies>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.8.1</version>
      <configuration>
        <source>1.8</source>
        <target>1.8</target>
        <annotationProcessorPaths>
          <path>
            <groupId>io.github.joke.spring-factory</groupId>
            <artifactId>processor</artifactId>
            <version>1.0.0</version>
          </path>
        </annotationProcessorPaths>
      </configuration>
    </plugin>
  </plugins>
</build>

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 AutoService but for Spring’s factory meta files.

Usage example
@SpringFactory(EnableAutoConfiguration.class)
public class MyAutoConfiguration {}

@SpringFactory({EnableAutoConfiguration.class, AutoConfigureDataMongo.class})
public class MyMongoAutoConfiguration {}
Generated output META-INF/spring.factories
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