abstract class GenerateAutoConfigurationImportsTask extends DefaultTask
Scans this project's own compiled main classes for @AutoConfiguration and writes
META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports, so the
file never needs to be hand-maintained. Mirrors how META-INF/grails-plugin.xml is already
generated from scanned *GrailsPlugin classes elsewhere in this build.
Class files are read directly with ASM rather than loaded. Loading required every supertype and
annotation of every candidate to be resolvable, and a candidate that failed to load could only be
warned about and skipped - so a genuine @AutoConfiguration could drop out of the generated
file while the build stayed green, which is the outcome this task exists to prevent. Reading the
annotation table needs nothing beyond the class file itself, so that failure mode is gone and
there is no scan classpath to get wrong.
| Type | Name and description |
|---|---|
static java.lang.String |
AUTO_CONFIGURATION_ANNOTATION |
static java.lang.String |
IMPORTS_RESOURCE_PATH |
| Constructor and description |
|---|
GenerateAutoConfigurationImportsTask() |
| Type Params | Return Type | Name and description |
|---|---|---|
|
void |
generate() |
|
abstract ConfigurableFileCollection |
getClassesDirs() |
|
abstract DirectoryProperty |
getOutputDirectory() |
|
abstract ConfigurableFileCollection |
getResourcesDirs()The module's own resource directories, checked for a hand-maintained copy of the imports file. |
|
static java.util.List<java.io.File> |
handMaintainedImportsFiles(java.util.Set<java.io.File> resourcesDirs)The hand-maintained copies of the imports file found among resourcesDirs. |
|
static java.util.SortedSet<java.lang.String> |
scan(java.util.Set<java.io.File> classesDirs)Static so it is directly unit-testable without running a real Gradle task. |
The module's own resource directories, checked for a hand-maintained copy of the imports file. This task's output lands at the same archive path, so a module keeping both would feed the resource into the jar twice.
The hand-maintained copies of the imports file found among resourcesDirs. Static so it
is directly unit-testable without running a real Gradle task.
resourcesDirs - the module's resource source directoriesMETA-INF/spring/...AutoConfiguration.imports among themStatic so it is directly unit-testable without running a real Gradle task.
classesDirs - directories of compiled .class files to inspect - a project's own
output only, never a dependency jar@AutoConfiguration,
sorted for a deterministic, diff-friendly output file