protected ScriptEngine getEngine()

in src/main/java/org/apache/maven/plugins/scripting/FileScriptEvaluator.java [80:103]


    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 extension = scriptFile.getName();
            int position = extension.indexOf(".");

            if (position >= 0) {
                extension = extension.substring(position + 1);
            }
            result = manager.getEngineByExtension(extension);

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