@CompileStatic class FactoriesFileWriter extends java.lang.Object
Writes factory registrations for compiled classes into a factories file in the compilation
target directory, merging any existing entries from previous compilation runs and from
hand-authored source registrations, and drops the registration of a class compiled again
once it no longer qualifies. The factories file location is supplied by the caller,
so the writer is shared by transformations targeting different registration files
(e.g. META-INF/grails.factories and META-INF/grails-cli.factories).
| Constructor and description |
|---|
FactoriesFileWriter() |
| Type Params | Return Type | Name and description |
|---|---|---|
|
static java.io.File |
findSourceDirectory(java.io.File compilationTargetDirectory) |
|
static boolean |
removeFromFactories(java.lang.String className, ClassNode superType, java.io.File compilationTargetDirectory, java.lang.String factoriesLocation, java.util.List<java.lang.String> sourceFactoriesLocations)Drops the class from the given super type's entry in the factories file, unless a hand-authored factories file registers it, and deletes the file once no entry is left. |
|
static boolean |
updateFactoriesWithType(ClassNode classNode, ClassNode superType, java.io.File compilationTargetDirectory, java.lang.String factoriesLocation, java.util.List<java.lang.String> sourceFactoriesLocations)Registers the class as an implementation of the given super type in the factories file when the class is a non-abstract subtype, and otherwise drops it from that type's entry (see removeFromFactories). |
| 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 the class from the given super type's entry in the factories file, unless a hand-authored factories file registers it, and deletes the file once no entry is left.
Incremental compilation recompiles a changed class without the others, so a class that is no longer a concrete subtype, or one its transformation no longer registers, would otherwise keep the entry written by the compilation that registered it.
className - the binary name of the compiled classsuperType - the factory type the class may have been registered undercompilationTargetDirectory - the compilation output directoryfactoriesLocation - the factories file path relative to the target directorysourceFactoriesLocations - project-relative paths of hand-authored factories filestrue when an entry was droppedRegisters the class as an implementation of the given super type in the factories file when the class is a non-abstract subtype, and otherwise drops it from that type's entry (see removeFromFactories).
classNode - the compiled classsuperType - the factory type to register the class undercompilationTargetDirectory - the compilation output directoryfactoriesLocation - the factories file path relative to the target directorysourceFactoriesLocations - project-relative paths of hand-authored factories files to mergetrue when the class was registered