@org.gradle.work.DisableCachingByDefault(because: Writing a handful of lines is cheaper than a build-cache round trip) @groovy.transform.CompileStatic abstract class GenerateI18nDescriptorTask extends DefaultTask
Writes the message-bundle descriptor an artifact contributes to Spring Boot's message source.
Grails applications and plugins both ship their bundles at the root of their jar, so at runtime
the only way to find them used to be a classpath*:*.properties scan. That scan is what
GraalVM native images cannot do, and it also costs start-up time on the JVM. Recording the answer
at build time removes the scan: the descriptor is read back through an exact-name
ClassLoader.getResources lookup, which works in a native image and needs no wildcard
resource metadata.
The generated META-INF/grails/i18n.properties is an internal build format, never
hand-authored:
format.version=1
artifact.type=plugin
artifact.name=spring-security-core
artifact.version=8.0.0
basenames=spring-security-core,spring-security-core-validation
locales=de,fr
The file-name interpretation itself lives in I18nBundleIndex, which also documents the base-name/locale convention and how to override it.
| Type | Name and description |
|---|---|
static java.lang.String |
DESCRIPTOR_PATHPath of the generated descriptor within the artifact. |
static java.lang.String |
FORMAT_VERSIONDescriptor format version, so a future reader can reject an artifact it does not understand. |
static java.lang.String |
TYPE_APPLICATIONartifact.type for an application. |
static java.lang.String |
TYPE_PLUGINartifact.type for a plugin. |
| Constructor and description |
|---|
GenerateI18nDescriptorTask() |
| Type Params | Return Type | Name and description |
|---|---|---|
|
void |
generate() |
|
abstract Property<java.lang.String> |
getArtifactName()The application or plugin name; for a plugin it also constrains the permitted base names. |
|
abstract Property<java.lang.String> |
getArtifactType()Either TYPE_APPLICATION or TYPE_PLUGIN. |
|
abstract Property<java.lang.String> |
getArtifactVersion()The artifact version, recorded for diagnostics only — it plays no part in ordering. |
|
abstract DirectoryProperty |
getBundleDirectory()The bundle sources, normally grails-app/i18n. |
|
abstract ListProperty<java.lang.String> |
getDeclaredBasenames()Base names declared through grails { i18n { basenames }}. |
|
abstract DirectoryProperty |
getOutputDirectory()Directory contributed to processResources; holds DESCRIPTOR_PATH. |
Path of the generated descriptor within the artifact.
Descriptor format version, so a future reader can reject an artifact it does not understand.
artifact.type for an application.
artifact.type for a plugin.
The application or plugin name; for a plugin it also constrains the permitted base names.
Either TYPE_APPLICATION or TYPE_PLUGIN.
The artifact version, recorded for diagnostics only — it plays no part in ordering.
The bundle sources, normally grails-app/i18n.
Only the file names matter, never the contents — native2ascii and the
EscapeUnicode filter rewrite bundle contents but leave names alone, so this task reads
the sources directly and never has to wait for, or read back, the processed resources.
Base names declared through grails { i18n { basenames }}.
Directory contributed to processResources; holds DESCRIPTOR_PATH.