public final class AutoConfigurationImportsWriter extends java.lang.Object
Registers a generated auto-configuration in
META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports.
The class a beans closure compiles to is created during compilation and is not a source
file anyone can open. Leaving its registration to be written by hand made a plugin whose beans are
silently never registered the ordinary consequence of not knowing the class exists - and the name
to write is one only the compiler knows, since it follows from the descriptor's name and package.
Writing it where the class is created is the only point at which that name is known for certain.
A module that keeps the file by hand at {
That one conventional location is all a compiler can look in: a source set's resource
directories are a build-tool notion and are not among the things the compiler is told, so a module
that relocates them keeps a file this cannot see and gets a second copy generated, which the build
then reports as two resources at one path. FactoriesFileWriter reads
META-INF/grails.factories from the same fixed location for the same reason. Handling a
relocated one needs the build to say where it is.
Hand-authored entries have to remain possible: a module may register a class from another jar,
one annotated with a composed annotation, or one carrying no annotation at all, the imports file
being the registration and @AutoConfiguration only supplying ordering.
| Modifiers | Name | Description |
|---|---|---|
static java.lang.String |
IMPORTS_LOCATION |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public static boolean |
reconcile(java.io.File targetDirectory, java.lang.Object compilation, SourceUnit source)Drops entries naming classes this module no longer generates, adding none. |
|
public static boolean |
register(java.lang.String className, java.io.File targetDirectory, SourceUnit source, java.lang.Object compilation)Adds className to the generated imports file under targetDirectory, together
with anything an earlier source unit of the same compilation registered there. |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#equals(java.lang.Object), java.lang.Object#getClass(), java.lang.Object#hashCode(), java.lang.Object#notify(), java.lang.Object#notifyAll(), java.lang.Object#toString(), java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int) |
Drops entries naming classes this module no longer generates, adding none.
register prunes as it writes, but only runs when something is generated: a
descriptor that is deleted outright, loses its beans closure, or is left with an empty
one calls nothing at all, and the entry naming the class it used to generate would survive a
build that removed the class. This runs from the compilation itself rather than from the
generating of a class, so it happens either way.
targetDirectory - the compilation output directory holding the generated filecompilation - what scopes the names registered so far, so a class generated in this
compilation is not pruned before its class file is writtensource - the source being compiled, used to report a metadata write failuretrue when an entry was dropped Adds className to the generated imports file under targetDirectory, together
with anything an earlier source unit of the same compilation registered there. A module that
keeps the file by hand is warned instead, and its file is left as the only one.
className - the generated auto-configuration's binary nametargetDirectory - the compilation output directory, or null when the compiler did
not supply one - in which case there is nowhere to write and the class
stays registerable by handsource - the source being compiled, used for warnings and write errorscompilation - what scopes names registered before their class files are writtentrue when the file was written