code: public static <T> T executeScriptEngine(final String scriptFile, final Object[] args, final Class<T> clazz) {
          try {
              val engineName = getScriptEngineName(scriptFile);
              val engine = new ScriptEngineManager().getEngineByName(engineName);
              if (engine == null || StringUtils.isBlank(engineName)) {
                  LOGGER.warn("Script engine is not available for [{}]", engineName);
                  return null;
              }
  
              val resourceFrom = ResourceUtils.getResourceFrom(scriptFile);
              val theScriptFile = resourceFrom.getFile();
              if (theScriptFile.exists()) {
                  LOGGER.debug("Created object instance from class [{}]", theScriptFile.getCanonicalPath());
  
                  try (val reader = Files.newBufferedReader(theScriptFile.toPath(), StandardCharsets.UTF_8)) {
                      engine.eval(reader);
                  }
                  val invocable = (Invocable) engine;
                  LOGGER.debug("Executing script's run method, with parameters [{}]", args);
                  val result = invocable.invokeFunction("run", args);
                  LOGGER.debug("Groovy script result is [{}]", result);
                  return getGroovyScriptExecutionResultOrThrow(clazz, result);
              }
              LOGGER.warn("[{}] script [{}] does not exist, or cannot be loaded", StringUtils.capitalize(engineName), scriptFile);
          } catch (final Exception e) {
              LOGGER.error(e.getMessage(), e);
          }
          return null;
      }
docs: Execute groovy script engine t.
  
  @param <T>        the type parameter
  @param scriptFile the script file
  @param args       the args
  @param clazz      the clazz
  @return the t