protected void executeSassScript ( String sassScript ) throws MojoExecutionException , MojoFailureException { final Log log = this . getLog ( ) ; System . setProperty ( "org.jruby.embed.localcontext.scope" , "threadsafe" ) ; log . debug ( "Execute SASS Ruby Script:\n" + sassScript ) ; final ScriptEngineManager scriptEngineManager = new ScriptEngineManager ( ) ; final ScriptEngine jruby = scriptEngineManager . getEngineByName ( "jruby" ) ; try { CompilerCallback compilerCallback = new CompilerCallback ( log ) ; jruby . getBindings ( ScriptContext . ENGINE_SCOPE ) . put ( "compiler_callback" , compilerCallback ) ; jruby . eval ( sassScript ) ; if ( failOnError && compilerCallback . hadError ( ) ) { throw new MojoFailureException ( "SASS compilation encountered errors (see above for details)." ) ; } } catch ( final ScriptException e ) { throw new MojoExecutionException ( "Failed to execute SASS ruby script:\n" + sassScript , e ) ; } }
Execute the SASS Compilation Ruby Script