/** * Retrieves the script name representation of the supplied class. For example * MyFunkyGrailsScript would be my-funky-grails-script. * * @param clazz The class to convert * @return The script name representation */ public static String getScriptName(Class<?> clazz) { return clazz == null ? null : getScriptName(clazz.getName()); }
/** * Returns the name of a plugin given the name of the *GrailsPlugin.groovy * descriptor file. For example, "DbUtilsGrailsPlugin.groovy" gives * "db-utils". * @param descriptorName The simple name of the plugin descriptor. * @return The plugin name for the descriptor, or <code>null</code> * if <i>descriptorName</i> is <code>null</code>, or an empty string * if <i>descriptorName</i> is an empty string. * @throws IllegalArgumentException if the given descriptor name is * not valid, i.e. if it doesn't end with "GrailsPlugin.groovy". */ public static String getPluginName(String descriptorName) { if (descriptorName == null || descriptorName.length() == 0) { return descriptorName; } if (!descriptorName.endsWith("GrailsPlugin.groovy")) { throw new IllegalArgumentException("Plugin descriptor name is not valid: " + descriptorName); } return getScriptName(descriptorName.substring(0, descriptorName.indexOf("GrailsPlugin.groovy"))); }