public final class PluginUtils extends java.lang.Object
Static utility methods supporting Grails plugin discovery, metadata extraction, configuration lookup, and compatibility checks.
This class centralizes the low-level operations used by bootstrap-time discovery, including scanning
grails-plugin.xml descriptors, deriving logical plugin names, reading plugin class metadata, and
evaluating environment and version constraints.
| Modifiers | Name | Description |
|---|---|---|
record |
PluginUtils.PluginDependencies |
Holds both the dependency names and the raw dependency map extracted from a plugin. |
| Modifiers | Name | Description |
|---|---|---|
static java.util.List<java.lang.String> |
DEFAULT_CONFIG_IGNORE_LIST |
Default config keys to ignore when loading plugin configuration. |
static java.lang.String |
GRAILS_PLUGIN_SUFFIX |
The naming suffix required for Grails plugin implementation classes. |
static java.lang.String |
PLUGIN_GRAILS_VERSION_FIELD |
The plugin property that declares the supported Grails version expression. |
static java.lang.String |
PLUGIN_GROOVY_CONFIG |
The filename for Groovy ConfigSlurper-based plugin configuration. |
static java.lang.String |
PLUGIN_GROOVY_CONFIG_PATH |
The relative lookup path for Groovy-based plugin configuration. |
static java.lang.String |
PLUGIN_XML_PATTERN |
The classpath location of the Grails plugin descriptor XML files. |
static java.lang.String |
PLUGIN_YML_CONFIG |
The filename for YAML-based plugin configuration. |
static java.lang.String |
PLUGIN_YML_CONFIG_PATH |
The relative lookup path for YAML-based plugin configuration. |
static java.lang.String |
WILDCARD_OBSERVER_PATTERN |
The wildcard pattern used to indicate that a plugin observes all other plugins, i.e., it should be notified of events from all plugins regardless of name. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public static PluginInfo |
createPluginInfo(java.lang.Class<?> pluginClass, Resource descriptorResource, boolean dynamic)Creates a PluginInfo for a single plugin class using a synthetic descriptor. |
|
public static PluginInfo |
createPluginInfoByDescriptor(java.lang.Class<?> pluginClass, PluginDescriptor descriptor, boolean dynamic)Creates a PluginInfo for a plugin class using the supplied descriptor. |
|
public static java.util.Map<java.lang.String, java.util.Set<java.lang.Object>> |
evaluateIncludeExcludeProperty(java.lang.Object pluginBean, java.lang.String name, java.util.function.Function<java.lang.Object, java.lang.Object> converter)Evaluates an include/exclude style plugin property into a normalized lookup map. |
|
public static java.lang.String[] |
evaluateObservedPlugins(BeanWrapper beanWrapper, java.lang.Object pluginInstance)Extracts the plugin names observed by the supplied plugin instance. |
|
public static PluginUtils.PluginDependencies |
evaluatePluginDependencies(BeanWrapper beanWrapper, java.lang.Object plugin)Extracts the declared plugin dependencies. |
|
public static java.util.Map<java.lang.String, java.util.Set<java.lang.Object>> |
evaluatePluginEnvironments(BeanWrapper beanWrapper, java.lang.Object pluginInstance)Extracts the environment include/exclude configuration declared by the supplied plugin. |
|
public static java.lang.String[] |
evaluatePluginEvictionPolicy(BeanWrapper beanWrapper, java.lang.Object pluginInstance)Extracts the plugin names evicted by the supplied plugin. |
|
public static java.lang.String[] |
evaluatePluginLoadAfters(BeanWrapper beanWrapper, java.lang.Object pluginInstance)Extracts the plugin names this plugin prefers to load after. |
|
public static java.lang.String[] |
evaluatePluginLoadBefores(BeanWrapper beanWrapper, java.lang.Object pluginInstance)Extracts the plugin names this plugin prefers to load before. |
|
public static java.lang.String |
evaluatePluginStatus(BeanWrapper beanWrapper, java.lang.Object plugin)Determines whether the supplied plugin is enabled. |
|
public static java.lang.String |
evaluatePluginVersion(BeanWrapper beanWrapper, java.lang.Object plugin, java.lang.String name)Extracts the declared plugin version. |
|
public static PluginMetadata |
extractPluginMetadata(java.lang.Class<?> pluginClass)Extracts plugin metadata ( loadAfter, loadBefore,
dependsOn) from a plugin class without requiring a full
GrailsApplication or plugin manager. |
|
public static Resource |
getConfigurationResource(java.lang.Class<?> pluginClass, java.lang.String configPath)Finds a plugin configuration resource at the given path relative to the plugin class, delegating to IOUtils#findResourceRelativeToClass#findResourceRelativeToClass. |
|
public static java.lang.String |
getLogicalPluginName(java.lang.Class<?> pluginClass)Derives the logical plugin name from the plugin class, following Grails conventions. |
|
public static java.lang.String |
getLogicalPluginNameFromClassName(java.lang.String name)Derives the logical plugin name from a plugin class name. |
|
public static boolean |
isGrailsPluginClassNamedCorrectly(java.lang.Class<?> pluginClass)Determines whether the supplied class follows Grails plugin naming conventions. |
|
public static boolean |
isGrailsPluginLoadable(java.lang.Class<?> pluginClass)Determines whether the supplied class can be loaded as a Grails plugin. |
|
public static boolean |
isPluginVersionCompatible(java.lang.String pluginVersion, java.lang.String pluginSupportedVersionRange, java.lang.String grailsVersion, java.lang.String pluginDescription)Determines whether a plugin's declared Grails version range is compatible with the target Grails version. |
|
public static java.lang.String |
normalizePluginName(java.lang.String name)Normalizes a plugin name into a Grails logical property form. |
|
public static Resource |
readPluginConfiguration(java.lang.Class<?> pluginClass)Resolves the plugin configuration resource relative to the supplied plugin class. |
|
public static java.util.List<PluginDescriptor> |
scanPluginDescriptorResources(java.lang.ClassLoader classLoader)Scans all META-INF/grails-plugin.xml resources visible to the supplied class loader. |
|
public static java.util.List<java.lang.String> |
scanPluginDescriptors(java.lang.ClassLoader classLoader)Convenience method that scans all META-INF/grails-plugin.xml
resources and returns just the plugin class names. |
|
public static boolean |
supportsValueInIncludeExcludeMap(java.util.Map<java.lang.String, java.util.Set<java.lang.Object>> includeExcludeMap, java.lang.Object value)Determines whether a value is permitted by a normalized include/exclude map. |
| 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) |
Default config keys to ignore when loading plugin configuration.
The naming suffix required for Grails plugin implementation classes.
The plugin property that declares the supported Grails version expression.
The filename for Groovy ConfigSlurper-based plugin configuration.
The relative lookup path for Groovy-based plugin configuration.
The classpath location of the Grails plugin descriptor XML files.
The filename for YAML-based plugin configuration.
The relative lookup path for YAML-based plugin configuration.
The wildcard pattern used to indicate that a plugin observes all other plugins, i.e., it should be notified of events from all plugins regardless of name.
Creates a PluginInfo for a single plugin class using a synthetic descriptor.
pluginClass - the plugin implementation classdescriptorResource - the descriptor resource associated with the plugin, if anydynamic - whether the plugin originated from a dynamic plugin configurationCreates a PluginInfo for a plugin class using the supplied descriptor.
pluginClass - the plugin implementation classdescriptor - the descriptor that produced the plugindynamic - whether the plugin originated from a dynamic plugin configurationEvaluates an include/exclude style plugin property into a normalized lookup map.
The property may be declared either as a map containing includes and excludes entries,
or as a single include value. Values are converted through the supplied converter before being stored.
pluginBean - the plugin bean containing the propertyname - the property name to evaluateconverter - a converter applied to each include/exclude value before storageExtracts the plugin names observed by the supplied plugin instance.
beanWrapper - the wrapper used to inspect plugin propertiespluginInstance - the plugin instance being inspectedExtracts the declared plugin dependencies.
beanWrapper - the wrapper used to inspect plugin propertiesplugin - the plugin instance being inspectedExtracts the environment include/exclude configuration declared by the supplied plugin.
beanWrapper - the wrapper used to inspect plugin propertiespluginInstance - the plugin instance being inspectedExtracts the plugin names evicted by the supplied plugin.
beanWrapper - the wrapper used to inspect plugin propertiespluginInstance - the plugin instance being inspectedExtracts the plugin names this plugin prefers to load after.
beanWrapper - the wrapper used to inspect plugin propertiespluginInstance - the plugin instance being inspectedExtracts the plugin names this plugin prefers to load before.
beanWrapper - the wrapper used to inspect plugin propertiespluginInstance - the plugin instance being inspectedDetermines whether the supplied plugin is enabled.
beanWrapper - the wrapper used to inspect plugin propertiesplugin - the plugin instance being inspectedExtracts the declared plugin version.
beanWrapper - the wrapper used to inspect plugin propertiesplugin - the plugin instance being inspectedname - the logical plugin name used in error messages Extracts plugin metadata (loadAfter, loadBefore,
dependsOn) from a plugin class without requiring a full
GrailsApplication or plugin manager.
The plugin class is instantiated to read its properties via a
BeanWrapper, mirroring the approach used by
DefaultGrailsPlugin. The dependsOn property is a
Map<String, String> where keys are dependency plugin names and
values are version constraints; only the keys are extracted.
pluginClass - the plugin class to extract metadata fromnull if the class is
not a valid Grails pluginFinds a plugin configuration resource at the given path relative to the plugin class, delegating to IOUtils#findResourceRelativeToClass#findResourceRelativeToClass.
pluginClass - the plugin class to resolve relative toconfigPath - the path to probe (for example "/plugin.yml")null if no such resource existsDerives the logical plugin name from the plugin class, following Grails conventions.
For example, org.grails.plugins.CoreGrailsPlugin becomes
core. This delegates to
GrailsNameUtils#getLogicalPropertyName#getLogicalPropertyName with the
"GrailsPlugin" suffix.
pluginClass - the plugin classDerives the logical plugin name from a plugin class name.
name - the plugin class simple nameDetermines whether the supplied class follows Grails plugin naming conventions.
pluginClass - the class to inspecttrue if the class name ends with GRAILS_PLUGIN_SUFFIXDetermines whether the supplied class can be loaded as a Grails plugin.
pluginClass - the class to inspecttrue if the class is non-null, non-abstract, and not the framework base plugin classDetermines whether a plugin's declared Grails version range is compatible with the target Grails version.
This method supports exact version checks and version ranges as interpreted by
GrailsVersionUtils. Compatibility problems are logged and reported by returning false.
pluginVersion - the plugin version used in log messagespluginSupportedVersionRange - the Grails version or version range declared by the plugingrailsVersion - the target Grails version to test againstpluginDescription - the plugin description used in log messagestrue if the plugin should be considered compatible with the supplied Grails versionNormalizes a plugin name into a Grails logical property form.
Hyphen-separated names are converted to lower camel case so lookups can match either external plugin names
such as some-plugin or logical names such as somePlugin.
name - the plugin name to normalizeResolves the plugin configuration resource relative to the supplied plugin class.
The lookup probes for both plugin.yml and plugin.groovy. If both exist, a
java.lang.RuntimeException is thrown because a plugin may define only one configuration source.
pluginClass - the plugin class to resolve relative tonull if no config file is present Scans all META-INF/grails-plugin.xml resources visible to the supplied class loader.
Each descriptor is parsed with PluginXmlHandler and returned as a PluginDescriptor containing the descriptor resource, declared plugin implementation classes, and any provided class names. Invalid descriptors are logged and skipped, so discovery can continue.
classLoader - the class loader to scan for plugin descriptorsMETA-INF/grails-plugin.xml resource found on the
classpath Convenience method that scans all META-INF/grails-plugin.xml
resources and returns just the plugin class names.
classLoader - the class loader to scan for plugin descriptorsMETA-INF/grails-plugin.xml descriptorsDetermines whether a value is permitted by a normalized include/exclude map.
An empty map allows every value. If an include set is present, only included values are supported. Otherwise, values are rejected only when they appear in the exclude set.
includeExcludeMap - the include/exclude map to evaluatevalue - the value to testtrue if the value is permitted by the include/exclude rules