code: public static String getStaticResourcePathForResource(Resource resource, String contextPath) {
  
          if (contextPath == null) contextPath = "";
          if (resource == null) return contextPath;
  
          String url;
          try {
              url = resource.getURL().toString();
          }
          catch (IOException e) {
              return contextPath;
          }
  
          Matcher m = PLUGIN_RESOURCE_PATTERN.matcher(url);
          if (m.find()) {
              return (contextPath.length() > 0 ? contextPath + "/" : "") + m.group(1);
          }
  
          return contextPath;
      }
docs: Retrieves the static resource path for the given Grails resource artifact (controller/taglib etc.)
  
  @param resource The Resource
  @param contextPath The additonal context path to prefix
  @return The resource path