throw new MessageOnlyException("Unable to compile " + context.scriptFile() + " to a class file.\n" + " The system java compiler is missing (are you running a JRE rather than a JDK?)\n" + " Either run this with a JDK or add \"org.eclipse.jdt.core.compiler:ecj:<version>\" to blaze.dependencies.");
throw new MessageOnlyException("Unable to compile " + context.scriptFile() + " to a class file.\n" + " The system java compiler is missing (are you running a JRE rather than a JDK?)\n" + " Either run this with a JDK or add \"org.eclipse.jdt.core.compiler:ecj:<version>\" to blaze.dependencies.");
public void execute(String task) throws Exception { if (task == null || task.equals("")) { task = context.config().value(Config.KEY_DEFAULT_TASK).getOr(Config.DEFAULT_TASK); } String scriptName = (context.scriptFile() != null ? context.scriptFile().toString() : ""); log.info("Executing {}:{}...", scriptName, task); Timer executeTimer = new Timer(); this.script.execute(task); log.info("Executed {}:{} in {} ms", scriptName, task, executeTimer.stop().millis()); }
public void execute(String task) throws Exception { if (task == null || task.equals("")) { task = context.config().value(Config.KEY_DEFAULT_TASK).getOr(Config.DEFAULT_TASK); } String scriptName = (context.scriptFile() != null ? context.scriptFile().toString() : ""); log.info("Executing {}:{}...", scriptName, task); Timer executeTimer = new Timer(); this.script.execute(task); log.info("Executed {}:{} in {} ms", scriptName, task, executeTimer.stop().millis()); }
@Override public BlazeNashornScript compile(Context context) throws BlazeException { try { ScriptEngine scriptEngine = this.scriptEngineManager.getEngineByName("nashorn"); Bindings bindings = scriptEngine.createBindings(); scriptEngine.setBindings(bindings, ScriptContext.ENGINE_SCOPE); // do NOT expose any functions as global... // expose functions as global variables to script //bindings.put("context", context); //bindings.put("log", context.logger()); //bindings.put("console", new Console()); scriptEngine.eval(new FileReader(context.scriptFile().toFile()), bindings); //log.debug("script class: {}", this.script.getClass().getCanonicalName()); Invocable invocable = (Invocable)scriptEngine; return new BlazeNashornScript(this, scriptEngine, bindings, invocable); } catch (ScriptException | FileNotFoundException e) { throw new BlazeException("Unable to evaluate nashorn script", e); } }
@Override public BlazeGroovyScript compile(Context context) throws BlazeException { try { // must be valid url... String path = context.scriptFile().toUri().toURL().toString(); Binding binding = new Binding(); // add small number of useful bindings // not sure its best practice to polute namespace at all //binding.setVariable("context", context); //binding.setVariable("log", context.logger()); //binding.setVariable("config", context.config()); Script script = script = this.groovy.createScript(path, binding); script.run(); return new BlazeGroovyScript(this, script); } catch (ResourceException | IOException | ScriptException e) { throw new BlazeException("Unable to compile groovy script", e); } } }
@Override public BlazeNashornScript compile(Context context) throws BlazeException { try { ScriptEngine scriptEngine = this.scriptEngineManager.getEngineByName("nashorn"); Bindings bindings = scriptEngine.createBindings(); scriptEngine.setBindings(bindings, ScriptContext.ENGINE_SCOPE); // do NOT expose any functions as global... // expose functions as global variables to script //bindings.put("context", context); //bindings.put("log", context.logger()); //bindings.put("console", new Console()); scriptEngine.eval(new FileReader(context.scriptFile().toFile()), bindings); //log.debug("script class: {}", this.script.getClass().getCanonicalName()); Invocable invocable = (Invocable)scriptEngine; return new BlazeNashornScript(this, scriptEngine, bindings, invocable); } catch (ScriptException | FileNotFoundException e) { throw new BlazeException("Unable to evaluate nashorn script", e); } }
fileManager.getJavaFileObjectsFromFiles(Arrays.asList(context.scriptFile().toFile())); throw new MessageOnlyException("Unable to compile " + context.scriptFile());
fileManager.getJavaFileObjectsFromFiles(Arrays.asList(context.scriptFile().toFile())); throw new MessageOnlyException("Unable to compile " + context.scriptFile());
@Override public BlazeJdkScript compile(Context context) throws BlazeException { String className = context.scriptFile().toFile().getName().replace(".java", ""); scriptHash = FileHelper.md5hash(context.scriptFile());
@Override public BlazeJdkScript compile(Context context) throws BlazeException { String className = context.scriptFile().toFile().getName().replace(".java", ""); scriptHash = FileHelper.md5hash(context.scriptFile());
@Override public BlazeKotlinScript compile(Context context) throws BlazeException { KotlinSourceFile sourceFile = new KotlinSourceFile(context.scriptFile()); scriptHash = FileHelper.md5hash(context.scriptFile()); } else { Kotlin1Compiler compiler = new Kotlin1Compiler(classLoader); compiler.compile(context.scriptFile(), classesDir, sourceFile.isScript());