Spring Configuration Validation Processor for Java 7 Runtimes

A Java 7 annotation processor to validate Spring @Configuration classes

License

License

Categories

Categories

config Application Layer Libs Configuration
GroupId

GroupId

com.github.pellaton.config-validation-processor
ArtifactId

ArtifactId

config-validation-processor-java7
Last Version

Last Version

3.0.8
Release Date

Release Date

Type

Type

jar
Description

Description

Spring Configuration Validation Processor for Java 7 Runtimes
A Java 7 annotation processor to validate Spring @Configuration classes

Download config-validation-processor-java7

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.pellaton.config-validation-processor/config-validation-processor-java7/ -->
<dependency>
    <groupId>com.github.pellaton.config-validation-processor</groupId>
    <artifactId>config-validation-processor-java7</artifactId>
    <version>3.0.8</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.pellaton.config-validation-processor/config-validation-processor-java7/
implementation 'com.github.pellaton.config-validation-processor:config-validation-processor-java7:3.0.8'
// https://jarcasting.com/artifacts/com.github.pellaton.config-validation-processor/config-validation-processor-java7/
implementation ("com.github.pellaton.config-validation-processor:config-validation-processor-java7:3.0.8")
'com.github.pellaton.config-validation-processor:config-validation-processor-java7:jar:3.0.8'
<dependency org="com.github.pellaton.config-validation-processor" name="config-validation-processor-java7" rev="3.0.8">
  <artifact name="config-validation-processor-java7" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.pellaton.config-validation-processor', module='config-validation-processor-java7', version='3.0.8')
)
libraryDependencies += "com.github.pellaton.config-validation-processor" % "config-validation-processor-java7" % "3.0.8"
[com.github.pellaton.config-validation-processor/config-validation-processor-java7 "3.0.8"]

Dependencies

compile (1)

Group / Artifact Type Version
org.springframework : spring-context jar 5.3.2

provided (1)

Group / Artifact Type Version
com.github.pellaton.config-validation-processor : config-validation-processor-core jar 3.0.8

test (4)

Group / Artifact Type Version
junit : junit jar 4.13.1
org.hamcrest : hamcrest-all jar 1.3
org.mockito : mockito-all jar 1.10.19
org.springframework : spring-test jar 5.3.2

Project Modules

There are no modules declared in this project.

spring-configuration-validation-processor Build Status

This project provides a Java 6 Annotation processor that emits compiler warnings and errors in case one of the following conditions is encountered in a Spring @Configuration class:

  • @Configuration classes must not be final.
  • @Configuration classes must have a visible no-arg constructor.
  • @Configuration class constructors must not be @Autowired.
  • Nested @Configuration classes must be static.
  • @Bean methods must not be private.
  • @Bean methods must not be final.
  • @Bean methods must have a non-void return type.
  • @Bean methods should be declared in classes annotated with @Configuration.
  • @Bean methods returning a BeanFactoryPostProcessor should be static.
  • Only @Bean methods returning a BeanFactoryPostProcessor should be static.

##Quick Start

Maven

  1. Add the following dependency to your Maven POM:
<dependencies>
    <dependency>
      <groupId>com.github.pellaton.config-validation-processor</groupId>
      <artifactId>config-validation-processor-java11</artifactId>
      <!-- For Java 8: <artifactId>config-validation-processor-java8</artifactId> -->
      <!-- For Java 7: <artifactId>config-validation-processor-java7</artifactId> -->
      <!-- For Java 6: <artifactId>config-validation-processor-java6</artifactId> -->
      <version>3.0.7</version>
    </dependency>
</dependencies>
  1. Configure the maven-compiler-plugin to run the annotation processor:
<build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>2.3.2</version>
          <configuration>
            <source>1.8</source>
            <target>1.8</target>
            <encoding>UTF-8</encoding>
            <annotationProcessors>
              <annotationProcessor>com.github.pellaton.springconfigvalidation.SpringConfigurationValidationProcessorJava11</annotationProcessor>
              <!-- For Java 8: <annotationProcessor>com.github.pellaton.springconfigvalidation.SpringConfigurationValidationProcessorJava8</annotationProcessor> -->
              <!-- For Java 7: <annotationProcessor>com.github.pellaton.springconfigvalidation.SpringConfigurationValidationProcessorJava7</annotationProcessor> -->
              <!-- For Java 6: <annotationProcessor>com.github.pellaton.springconfigvalidation.SpringConfigurationValidationProcessorJava6</annotationProcessor> -->
            </annotationProcessors>
          </configuration>
        </plugin>
    </plugins>
</build>

Gradle

Add the following to your gradle file:

configurations {
    annotationProcessor
}

task configureAnnotationProcessing(type: JavaCompile, group: 'build', description: 'Processes the @Configuration classes') {
  source = sourceSets.main.java
  classpath = configurations.compile + configurations.annotationProcessor
  options.compilerArgs = [
          "-proc:only",
          "-processor", "com.github.pellaton.springconfigvalidation.SpringConfigurationValidationProcessorJava8"
  ]
  destinationDir = buildDir
}

compileJava {
    dependsOn configureAnnotationProcessing
}

dependencies {
    annotationProcessor 'com.github.pellaton.config-validation-processor:config-validation-processor-java8:3.0.7'
}

Eclipse

  1. Enable annotation processing and annotation processing in editor in the Eclipse project properties (Java Compiler > Annotation Processing) Screenshot
  2. Configure the path to the processor's jar file (Java Compiler > Annotation Processing > Factory Path) Screenshot

IntelliJ IDEA (Maven Project)

In IntelliJ IDEA, the annotation processor works out if the box in Maven projects configuring the processor in the compiler plugin configuration. Unfortunately, this does not work for Gradle projects :-/

IntelliJ IDEA (Non Maven Project)

  1. Add the jar file containing the annotation processor to the module libraries
  2. Enable annotation processing in the global IntelliJ IDEAD compiler settings
  3. Add the fully qualified class name of the processor to the annotation processors list Screenshot

Netbeans (Maven Project)

In Netbeans, the annotation processor works out if the box in Maven projects configuring the processor in the compiler plugin configuration.

Netbeans (Non Maven Project)

  1. Add the jar file containing the annotation processor to the project libraries
  2. Enable annotation processing and annotation processing in editor in the project properties
  3. Add the fully qualified class name of the processor to the annotation processors list Screenshot

Perform a release

$ mvn release:prepare release:perform -Darguments=-Dgpg.passphrase=SECRET

Versions

Version
3.0.8
3.0.7
3.0.1
3.0.0