Package org.codehaus.groovy.control

Examples of org.codehaus.groovy.control.CompilerConfiguration


            cachedDomainsWithoutPackage = createDomainClassMap();
        }
    }

    private GroovyClassLoader initGroovyClassLoader(ClassLoader parent) {
        CompilerConfiguration compConfig = new CompilerConfiguration();
        compConfig.setSourceEncoding(GroovyPageParser.GROOVY_SOURCE_CHAR_ENCODING);
        return new GroovyPageClassLoader(parent, compConfig);
    }
View Full Code Here


        this(null, importCustomizerProvider);
    }

    public GremlinGroovyScriptEngine(String scriptBaseClass, final ImportCustomizerProvider importCustomizerProvider) {
        Gremlin.load();
        final CompilerConfiguration conf = new CompilerConfiguration();
        if (scriptBaseClass != null) {
            conf.setScriptBaseClass(scriptBaseClass);
        }
        conf.addCompilationCustomizers(importCustomizerProvider.getImportCustomizer());
        conf.setSourceEncoding("UTF-8");
        this.loader = new GroovyClassLoader(getParentLoader(), conf);
    }
View Full Code Here

    checkNotNull(url);
    log.debug("URL: {}", url);

    Binding binding = new Binding();

    CompilerConfiguration cc = new CompilerConfiguration();
    cc.setTargetDirectory(classesDir);
    this.shell = new GroovyShell(classLoader, binding, cc);

    HttpTransport transport = new HttpTransport(url.toExternalForm());

    // provide transport with custom class-loader which includes generated classes
View Full Code Here

                TClassLoader tClassLoader = new TClassLoader();

                // Let's compile the groovy source
                final List<GroovyClass> groovyClassesForThisTemplate = new ArrayList<GroovyClass>();
                // ~~~ Please !
                CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
                compilerConfiguration.setSourceEncoding("utf-8"); // ouf
                CompilationUnit compilationUnit = new CompilationUnit(compilerConfiguration);
                compilationUnit.addSource(new SourceUnit(name, compiledSource, compilerConfiguration, tClassLoader, compilationUnit.getErrorCollector()));
                Field phasesF = compilationUnit.getClass().getDeclaredField("phaseOperations");
                phasesF.setAccessible(true);
                LinkedList[] phases = (LinkedList[]) phasesF.get(compilationUnit);
View Full Code Here

    public String evalGroovyExpression( String expression )
    {
        Binding binding = new Binding();
        binding.setVariable( "env", System.getenv() );
        binding.setVariable( "sys", System.getProperties() );
        CompilerConfiguration config = new CompilerConfiguration();
        GroovyShell shell = new GroovyShell( binding, config );
        Object result = shell.evaluate( "return \"" + expression + "\"" );
        if ( result == null )
        {
            return "";
View Full Code Here

     * @param loader The class loader to use.
     * @param props Additional properties to use when creating new projects.
     * @see org.grouplens.lenskit.eval.EvalProject#EvalProject(java.util.Properties)
     */
    public EvalScriptEngine(ClassLoader loader, @Nullable Properties props) {
        CompilerConfiguration compConfig = new CompilerConfiguration(CompilerConfiguration.DEFAULT);
        properties = props;

        compConfig.setScriptBaseClass("org.grouplens.lenskit.eval.script.EvalScript");

        ImportCustomizer imports = new ImportCustomizer();
        imports.addStarImports("org.grouplens.lenskit",
                               "org.grouplens.lenskit.params",
                               "org.grouplens.lenskit.baseline",
                               "org.grouplens.lenskit.norm",
                               "org.grouplens.lenskit.eval.metrics.predict",
                               "org.grouplens.lenskit.eval.metrics.recommend");
        compConfig.addCompilationCustomizers(imports);
        shell = new GroovyShell(loader, new Binding(), compConfig);
        classLoader = loader;

        loadExternalMethods();

View Full Code Here

     * @param loader The class loader to use.
     */
    public ConfigurationLoader(ClassLoader loader) {
        classLoader = loader;
        binding = new Binding();
        CompilerConfiguration config = new CompilerConfiguration();
        config.setScriptBaseClass(LenskitConfigScript.class.getName());
        ImportCustomizer imports = new ImportCustomizer();
        imports.addStarImports("org.grouplens.lenskit");
        config.addCompilationCustomizers(imports);
        shell = new GroovyShell(loader, binding, config);
        directory = ClassDirectory.forClassLoader(loader);
    }
View Full Code Here

   *                         file.
   */
  public GroovyScriptEngine(ScriptLocation script) throws EngineException {
    // Get groovy to compile the script and access the callable closure
    final ClassLoader parent = getClass().getClassLoader();
    CompilerConfiguration configuration = new CompilerConfiguration();
    configuration.setSourceEncoding("UTF-8");
    final GroovyClassLoader loader = new GroovyClassLoader(parent, configuration, true);
    try {
      m_groovyClass = loader.parseClass(script.getFile());
      m_grinderRunner = new GrinderContextExecutor(m_groovyClass);
      m_grinderRunner.runBeforeProcess();
View Full Code Here

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

            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

TOP

Related Classes of org.codehaus.groovy.control.CompilerConfiguration

Copyright © 2018 www.massapicom. 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.