Examples of CompilerConfiguration


Examples of org.codehaus.groovy.control.CompilerConfiguration

    private GroovyShell createEngine(ExtendedEmailPublisherDescriptor descriptor, Map<String, Object> variables)
            throws FileNotFoundException, IOException {

        ClassLoader cl = Jenkins.getInstance().getPluginManager().uberClassLoader;
        ScriptSandbox sandbox = null;
        CompilerConfiguration cc = new CompilerConfiguration();
        cc.setScriptBaseClass(EmailExtScript.class.getCanonicalName());
        cc.addCompilationCustomizers(new ImportCustomizer().addStarImports(
                "jenkins",
                "jenkins.model",
                "hudson",
                "hudson.model"));

        if (descriptor.isSecurityEnabled()) {
            cc.addCompilationCustomizers(new SandboxTransformer());
            sandbox = new ScriptSandbox();
        }

        Binding binding = new Binding();
        for (Map.Entry<String, Object> e : variables.entrySet()) {
View Full Code Here

Examples of org.codehaus.groovy.control.CompilerConfiguration

        String script = ContentBuilder.transformText(presendScript, context, getRuntimeMacros(context));
        if (StringUtils.isNotBlank(script)) {
            debug(context.getListener().getLogger(), "Executing pre-send script");
            ClassLoader cl = Jenkins.getInstance().getPluginManager().uberClassLoader;
            ScriptSandbox sandbox = null;
            CompilerConfiguration cc = new CompilerConfiguration();
            cc.addCompilationCustomizers(new ImportCustomizer().addStarImports(
                    "jenkins",
                    "jenkins.model",
                    "hudson",
                    "hudson.model"));

            cl = expandClassLoader(cl, cc);
            if (getDescriptor().isSecurityEnabled()) {
                debug(context.getListener().getLogger(), "Setting up sandbox for pre-send script");
                cc.addCompilationCustomizers(new SandboxTransformer());
                sandbox = new ScriptSandbox();
            }

            Binding binding = new Binding();
            binding.setVariable("build", context.getBuild());
View Full Code Here

Examples of org.codehaus.groovy.control.CompilerConfiguration

          } else {
            icz.addImports(imports.get(i));
          }
        }
      }
      CompilerConfiguration config = new CompilerConfiguration().addCompilationCustomizers(icz);
      shell = new GroovyShell(newClassLoader(), new Binding(), config);
    }
View Full Code Here

Examples of org.codehaus.groovy.control.CompilerConfiguration

        //
        String groovyText = script.toString();

        //
        CompilerConfiguration config = new CompilerConfiguration();

        //
        byte[] bytes;
        try {
            config.setScriptBaseClass(BaseScript.class.getName());
            bytes = groovyText.getBytes(config.getSourceEncoding());
        } catch (UnsupportedEncodingException e) {
            throw new TemplateCompilationException(e, groovyText);
        }

        //
View Full Code Here

Examples of org.codehaus.groovy.control.CompilerConfiguration

        PrintStream origOut = System.out;
        PrintStream origErr = System.err;

        try
        {
            CompilerConfiguration config = new CompilerConfiguration( CompilerConfiguration.DEFAULT );

            if ( scriptOutput != null )
            {
                System.setErr( scriptOutput );
                System.setOut( scriptOutput );
                config.setOutput( new PrintWriter( scriptOutput ) );
            }

            ClassLoader loader = null;
            if ( classPath != null && !classPath.isEmpty() )
            {
View Full Code Here

Examples of org.codehaus.groovy.control.CompilerConfiguration

    private final Log log = LogFactory.getLog(GroovyJavaCompiler.class);
    private final GroovyJavaCompilerSettings defaultSettings;
   
    public GroovyJavaCompiler() {
        defaultSettings = new GroovyJavaCompilerSettings(new CompilerConfiguration());
    }
View Full Code Here

Examples of org.codehaus.groovy.control.CompilerConfiguration

            final ResourceStore pStore,
            final ClassLoader pClassLoader,
            final JavaCompilerSettings pSettings
            ) {

        final CompilerConfiguration configuration = ((GroovyJavaCompilerSettings) pSettings).getCompilerConfiguration();
        final ErrorCollector collector = new ErrorCollector(configuration);
        final GroovyClassLoader groovyClassLoader = new GroovyClassLoader(pClassLoader);
        final CompilationUnit unit = new CompilationUnit(configuration, null, groovyClassLoader);
        final SourceUnit[] source = new SourceUnit[pResourceNames.length];
        for (int i = 0; i < source.length; i++) {
View Full Code Here

Examples of org.codehaus.groovy.control.CompilerConfiguration

    /**
     * Parses the bean definition groovy script by first exporting the given {@link Binding}.
     */
    public void parse(InputStream script, Binding binding) {
        setBinding(binding);
        CompilerConfiguration cc = new CompilerConfiguration();
        cc.setScriptBaseClass(ClosureScript.class.getName());
        GroovyShell shell = new GroovyShell(classLoader,binding,cc);

        ClosureScript s = (ClosureScript)shell.parse(script);
        s.setDelegate(this);
        s.run();
View Full Code Here

Examples of org.codehaus.groovy.control.CompilerConfiguration

        }

        public String call() throws RuntimeException {
            // if we run locally, cl!=null. Otherwise the delegating classloader will be available as context classloader.
            if (cl==null)       cl = Thread.currentThread().getContextClassLoader();
            CompilerConfiguration cc = new CompilerConfiguration();
            cc.addCompilationCustomizers(new ImportCustomizer().addStarImports(
                    "jenkins",
                    "jenkins.model",
                    "hudson",
                    "hudson.model"));
            GroovyShell shell = new GroovyShell(cl,new Binding(),cc);
View Full Code Here

Examples of org.codehaus.groovy.control.CompilerConfiguration

        }
        return callGlobal(name, args);
    }

    private synchronized void createClassLoader() {
        final CompilerConfiguration conf = new CompilerConfiguration();
        conf.addCompilationCustomizers(this.importCustomizerProvider.getCompilationCustomizer());

        if (this.securityProvider.isPresent())
            conf.addCompilationCustomizers(this.securityProvider.get().getCompilationCustomizer());

        this.loader = new GremlinGroovyClassLoader(getParentLoader(), conf);
        this.securityProvider.ifPresent(SecurityCustomizerProvider::registerInterceptors);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.