code: private String getVersion(final ClassLoader classLoader, final String className, final String methodName) {
      log.trace("Getting version; class-loader: {}, class-name: {}, method-name: {}",
          classLoader, className, methodName);
  
      try {
        Class<?> type = classLoader.loadClass(className);
        Method method = type.getMethod(methodName);
        Object result = method.invoke(null);
        if (result != null) {
          return result.toString();
        }
      }
      catch (Throwable e) {
        log.trace("Unable determine version from: {}", className);
      }
  
      return null;
    }
docs: Get version from Groovy version helper utilities via reflection.