code: @Nullable
      public static Path findRootPathForResource(String resourceName, ClassLoader classLoader)  {
          Objects.requireNonNull(resourceName, "resourceName");
          Objects.requireNonNull(classLoader, "classLoader");
  
          URL resource = classLoader.getResource(resourceName);
          if (resource != null) {
              String protocol = resource.getProtocol();
              if (protocol.equals("jar")) {
                  return getJarPathFromUrl(resource);
              } else if (protocol.equals("file")) {
                  return getRootPathFromDirectory(resourceName, resource);
              } else {
                  throw new IllegalStateException("Unsupported URL protocol: " + protocol);
              }
          }
          return null;
      }
docs: Find the root path for the given resource. If the resource is found in a Jar file, then the
  result will be an absolute path to the jar file. If the resource is found in a directory,
  then the result will be the parent path of the given resource.
  
  For example, if the resourceName is given as "scripts/myscript.groovy", and the path to the file is
  "/root/sub1/script/myscript.groovy", then this method will return "/root/sub1"
  
  @param resourceName relative path of the resource to search for. E.G. "scripts/myscript.groovy"
  @param classLoader the {@link ClassLoader} to search
  @return absolute path of the root of the resource.