This plugin scans your class files looking for the configured annotations and then validating any Spring Expressions that you have in the annotations.
- Find syntax errors in expressions that you might not otherwise find until runtime
- Basic static analysis on the expressions to see if they're correcting invoke a context root's method.
- Parse the expression into a SpelExpression
- Optionally validate any top level method references to the configured context root.
- Does not validate Bean References
@myBean.foo
or Variables#foo.bar
and likely won't ever - Does not currently validate Type References
T(fully.qualified.name.Type).isFoo()
but these seem like a good candidate to add next.
- The plugin uses the classpath for the project in order to load the configured annotations and optional root contexts.
- The Reflections API https://github.com/ronmamo/reflections is used to locate all methods annotated with the configured annotations
- Each annotation is checked to see if its configured attribute has a string value
- The string value is parsed into a SpelExpression or recorded as an error it it fails.
- If a context root was configured for the annotation, then we'll also scan the SpelExpression for any top level method references to see if they resolve against the root.
- A summary of the number of annotations tested, passed, and failed is available in target/spel-maven-plugin/report.json.
<plugin>
<groupId>com.massfords</groupId>
<artifactId>spel-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<failOnError>false</failOnError>
<annotations>
<SpelAnnotation>
<name>org.springframework.security.access.prepost.PreAuthorize</name>
<expressionRoot>org.springframework.security.access.expression.SecurityExpressionRoot</expressionRoot>
</SpelAnnotation>
</annotations>
</configuration>
<executions>
<execution>
<id>spel-plugin-integration</id>
<phase>process-classes</phase>
<goals>
<goal>spel</goal>
</goals>
</execution>
</executions>
</plugin>
mvn clean install
mvn clean install -Prun-its
Please post any issues on the Github's Issue tracker. Pull requests are welcome!
Apache 2.0