protected ScriptEngine getEngine()

in src/main/java/org/apache/maven/plugins/scripting/ResourceScriptEvaluator.java [84:112]


    protected ScriptEngine getEngine(ScriptEngineManager manager) throws UnsupportedScriptEngineException {
        ScriptEngine result;

        if (engineName != null && !engineName.isEmpty()) {
            result = manager.getEngineByName(engineName);

            if (result == null) {
                throw new UnsupportedScriptEngineException("No engine found by name \"" + engineName + "\n");
            }
        } else {
            String name = resourceName;
            int fileSepIndex = name.lastIndexOf('/');
            if (fileSepIndex >= 0) {
                name = name.substring(fileSepIndex + 1);
            }

            String extension = name;
            int position = name.indexOf(".");
            if (position >= 0) {
                extension = name.substring(position + 1);
            }
            result = manager.getEngineByExtension(extension);

            if (result == null) {
                throw new UnsupportedScriptEngineException("No engine found by extension \"" + extension + "\n");
            }
        }
        return result;
    }