@groovy.util.logging.Slf4j @groovy.transform.CompileStatic @org.codehaus.groovy.transform.GroovyASTTransformation class GlobalGrailsClassInjectorTransformation extends java.lang.Object implements org.codehaus.groovy.transform.ASTTransformation, groovy.transform.CompilationUnitAware, org.codehaus.groovy.transform.TransformWithPriority
Global AST transformation that applies Grails compiler injection to Grails project sources, including applications and plugins.
It identifies Grails artefacts, applies the relevant ClassInjector and
TraitInjector implementations, and registers artefact handlers
and injector implementations. When compiling a plugin descriptor, it also creates or updates
the META-INF/grails-plugin.xml descriptor and records transformed plugin resources.
| Modifiers | Name | Description |
|---|---|---|
static org.codehaus.groovy.ast.ClassNode |
ARTEFACT_CLASS_NODE |
|
static org.codehaus.groovy.ast.ClassNode |
ARTEFACT_HANDLER_CLASS |
|
static java.lang.String |
ISOLATED_BUILD_PROPERTY |
The system property signalling that a multi-project build compiles each project into its own isolated output directory. |
static org.codehaus.groovy.ast.ClassNode |
TRAIT_INJECTOR_CLASS |
| Type | Name and description |
|---|---|
org.codehaus.groovy.control.CompilationUnit |
compilationUnit |
| Constructor and description |
|---|
GlobalGrailsClassInjectorTransformation() |
| Type Params | Return Type | Name and description |
|---|---|---|
|
protected void |
generatePluginXml(org.codehaus.groovy.ast.ClassNode pluginClassNode, java.lang.String pluginVersion, java.util.Set<java.lang.String> transformedClassNames, java.io.File pluginXmlFile)Creates or updates the generated META-INF/grails-plugin.xml descriptor and carries
forward artefact classes collected during compilation. |
|
protected void |
handleExcludes(groovy.xml.slurpersupport.GPathResult pluginXml)Removes resources matching the configured plugin exclusion patterns from a parsed descriptor. |
|
static boolean |
isIsolatedBuild()Determines whether compilation is configured to use isolated project output directories. |
|
int |
priority()Returns the ordering position used to run this transformation relative to other global transformations. |
|
static java.io.File |
resolveCompilationTargetDirectory(org.codehaus.groovy.control.SourceUnit source)Resolves the output directory to which compiler-generated Grails metadata should be written. |
|
static java.io.File |
resolveCompilationTargetDirectory(org.codehaus.groovy.control.SourceUnit source, boolean isolatedBuild)Resolves the compilation target directory, using the Eclipse-specific resolution when compiling with Groovy-Eclipse and otherwise using the compiler configuration. |
|
static java.lang.String |
resolveGrailsVersionWithFrameworkVersion(java.util.Map pluginProperties, java.lang.String frameworkVersion) |
|
static boolean |
updateGrailsFactoriesWithType(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.ClassNode superType, java.io.File compilationTargetDirectory)Adds the compiled class to the META-INF/grails.factories entry for the supplied type
when it is a concrete subtype of that type. |
|
void |
updatePluginXml(org.codehaus.groovy.ast.ClassNode pluginClassNode, java.lang.String pluginVersion, java.io.File pluginXmlFile, java.util.Collection<java.lang.String> artefactClassNames)Updates an existing plugin descriptor with plugin metadata and newly discovered artefact resources. |
|
void |
visit(org.codehaus.groovy.ast.ASTNode[] nodes, org.codehaus.groovy.control.SourceUnit source)Applies Grails artefact and class injection to a project source and updates the generated plugin metadata for the compiled classes. |
|
void |
writePluginXml(org.codehaus.groovy.ast.ClassNode pluginClassNode, java.lang.String pluginVersion, java.io.File pluginXml, java.util.Collection<java.lang.String> artefactClassNames)Writes a new plugin descriptor from the plugin class metadata and supplied artefact classes. |
| 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) |
The system property signalling that a multi-project build compiles each project into its own isolated output directory. When set, the transform must never fall back to a shared or guessed location, which could leak one module's generated metadata into another.
Creates or updates the generated META-INF/grails-plugin.xml descriptor and carries
forward artefact classes collected during compilation.
pluginClassNode - the compiled plugin descriptor class, or null when none was foundpluginVersion - the plugin version, or null when no concrete plugin descriptor
is being generatedtransformedClassNames - the artefact classes transformed in the current source unitpluginXmlFile - the generated plugin descriptor fileRemoves resources matching the configured plugin exclusion patterns from a parsed descriptor.
pluginXml - the parsed plugin descriptorDetermines whether compilation is configured to use isolated project output directories.
true when the grails.isolated.build system property is trueReturns the ordering position used to run this transformation relative to other global transformations.
Resolves the output directory to which compiler-generated Grails metadata should be written.
source - the source unit being compiledResolves the compilation target directory, using the Eclipse-specific resolution when compiling with Groovy-Eclipse and otherwise using the compiler configuration.
source - the source unit being compiledisolatedBuild - whether falling back to the shared legacy directory is prohibited Adds the compiled class to the META-INF/grails.factories entry for the supplied type
when it is a concrete subtype of that type. Existing generated entries and matching
project-source entries are preserved, and the resulting factory file is written to the
compilation target directory.
classNode - the class being compiledsuperType - the factory interface or superclass whose implementations are registeredcompilationTargetDirectory - the compilation output directory containing the factory filetrue when classNode is a non-abstract subtype of superType and
was registered; false otherwiseUpdates an existing plugin descriptor with plugin metadata and newly discovered artefact resources. If the descriptor cannot be parsed or written, it is recreated; other failures propagate to abort compilation.
pluginClassNode - the plugin descriptor class, or null when only resources are updatedpluginVersion - the plugin version, or null when only resources are updatedpluginXmlFile - the existing plugin descriptor fileartefactClassNames - artefact class names to add as resourcesApplies Grails artefact and class injection to a project source and updates the generated plugin metadata for the compiled classes.
nodes - AST nodes supplied by Groovysource - the source unit being compiledWrites a new plugin descriptor from the plugin class metadata and supplied artefact classes.
pluginClassNode - the plugin descriptor classpluginVersion - the required plugin version when pluginClassNode is present, or
null when writing a resources-only descriptorpluginXml - the output descriptor fileartefactClassNames - artefact class names to include as resources