/** * Performs the actual run. */ protected void doRun() { Object groovy; groovy = Groovy.newInstance(m_Owner.getFilename(), Object.class); if (hasMethod(groovy, "run")) Groovy.invoke(groovy, "run", new Class[]{String[].class}, new Object[]{getArgs()}); else if (hasMethod(groovy, "main")) Groovy.invoke(groovy, "main", new Class[]{String[].class}, new Object[]{getArgs()}); else throw new IllegalStateException("Neither 'run' nor 'main' method found!"); }
/** * Performs pre-execution checks. * <p/> * This method checks whether Groovy is available (throws an exception if not). * * @param args optional commandline arguments * @throws Exception if checks fail */ protected void preCheck(String[] args) throws Exception { super.preCheck(args); if (!Groovy.isPresent()) throw new Exception("Groovy classes are not present in CLASSPATH!"); }
/** * Returns whether scripts can be executed, i.e., Groovy is present. * * @return true if scripts can be executed */ protected boolean canExecuteScripts() { return Groovy.isPresent(); }