當前位置: 首頁>>代碼示例>>Java>>正文


Java CompilerConfiguration.setTargetDirectory方法代碼示例

本文整理匯總了Java中org.codehaus.groovy.control.CompilerConfiguration.setTargetDirectory方法的典型用法代碼示例。如果您正苦於以下問題:Java CompilerConfiguration.setTargetDirectory方法的具體用法?Java CompilerConfiguration.setTargetDirectory怎麽用?Java CompilerConfiguration.setTargetDirectory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.codehaus.groovy.control.CompilerConfiguration的用法示例。


在下文中一共展示了CompilerConfiguration.setTargetDirectory方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: compileToDir

import org.codehaus.groovy.control.CompilerConfiguration; //導入方法依賴的package包/類
@Override
public void compileToDir(ScriptSource source, ClassLoader classLoader, File classesDir, File metadataDir, CompileOperation<?> extractingTransformer,
                         Class<? extends Script> scriptBaseClass, Action<? super ClassNode> verifier) {
    Timer clock = Timers.startTimer();
    GFileUtils.deleteDirectory(classesDir);
    GFileUtils.mkdirs(classesDir);
    CompilerConfiguration configuration = createBaseCompilerConfiguration(scriptBaseClass);
    configuration.setTargetDirectory(classesDir);
    try {
        compileScript(source, classLoader, configuration, metadataDir, extractingTransformer, verifier);
    } catch (GradleException e) {
        GFileUtils.deleteDirectory(classesDir);
        GFileUtils.deleteDirectory(metadataDir);
        throw e;
    }

    logger.debug("Timing: Writing script to cache at {} took: {}", classesDir.getAbsolutePath(), clock.getElapsed());
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:19,代碼來源:DefaultScriptCompilationHandler.java

示例2: getLoader

import org.codehaus.groovy.control.CompilerConfiguration; //導入方法依賴的package包/類
private static GroovyClassLoader getLoader(String targetDirectory) {
	final CompilerConfiguration myConfiguration = new CompilerConfiguration();
	if (targetDirectory != null) {
		myConfiguration.setTargetDirectory(targetDirectory);
	}
	
	return AccessController.doPrivileged(new PrivilegedAction<GroovyClassLoader>() {
           public GroovyClassLoader run() {
               return new GroovyClassLoader(GroovyShell.class.getClassLoader(), myConfiguration);
           }
       });
}
 
開發者ID:mganzarcik,項目名稱:fabulae,代碼行數:13,代碼來源:GroovyUtil.java

示例3: create

import org.codehaus.groovy.control.CompilerConfiguration; //導入方法依賴的package包/類
private GroovyScriptEngine create() {
  // custom the configuration of the compiler
  CompilerConfiguration cc = new CompilerConfiguration();
  cc.setTargetDirectory(new File(applicationDirectories.getTemporaryDirectory(), "groovy-classes"));
  cc.setSourceEncoding("UTF-8");
  cc.addCompilationCustomizers(secureASTCustomizer());
  GroovyClassLoader gcl = new GroovyClassLoader(classLoader, cc);

  engine = new GroovyScriptEngine(gcl);

  // HACK: For testing
  log.info("Created engine: {}", engine);

  return engine;
}
 
開發者ID:sonatype,項目名稱:nexus-public,代碼行數:16,代碼來源:GroovyScriptEngineFactory.java

示例4: GroovyCodeBlockCompiler

import org.codehaus.groovy.control.CompilerConfiguration; //導入方法依賴的package包/類
private GroovyCodeBlockCompiler() {

        CompilerConfiguration conf = new CompilerConfiguration(CompilerConfiguration.DEFAULT);

        ImportCustomizer imports = new ImportCustomizer();
        imports.addStarImports("org.voltdb");
        imports.addImports(
                "org.voltdb.groovy.TableBuilder",
                "org.voltdb.groovy.Tuplerator",
                "org.voltdb.VoltProcedure.VoltAbortException"
                 );
        imports.addStaticStars("org.voltdb.VoltProcedure","org.voltdb.VoltType");

        conf.addCompilationCustomizers(imports);
        // conf.getOptimizationOptions().put("int", false);
        // conf.getOptimizationOptions().put("indy", true);
        conf.setScriptBaseClass(DelegatingScript.class.getName());

        File groovyOut = createGroovyOutDirectory();

        List<String> classPath = conf.getClasspath();
        classPath.add(groovyOut.getAbsolutePath());
        conf.setClasspathList(classPath);

        conf.setTargetDirectory(groovyOut);

        gcl = new GroovyClassLoader(Thread.currentThread().getContextClassLoader(), conf);
    }
 
開發者ID:anhnv-3991,項目名稱:VoltDB,代碼行數:29,代碼來源:GroovyCodeBlockCompiler.java

示例5: setUp

import org.codehaus.groovy.control.CompilerConfiguration; //導入方法依賴的package包/類
protected void setUp() throws Exception {
    File dir = new File("target/test-generated-classes");
    dir.mkdirs();

    CompilerConfiguration config = new CompilerConfiguration();
    config.setTargetDirectory(dir);
    config.setDebug(dumpClass);

    compiler = new Compiler(config);
}
 
開發者ID:apache,項目名稱:groovy,代碼行數:11,代碼來源:CompilerTest.java

示例6: setUp

import org.codehaus.groovy.control.CompilerConfiguration; //導入方法依賴的package包/類
protected void setUp() throws Exception {
    File dir = new File("target/test-generated-classes");
    dir.mkdirs();
    Map options = new HashMap();
    options.put("stubDir", dir);

    CompilerConfiguration configuration = new CompilerConfiguration();
    configuration.setTargetDirectory(dir);
    configuration.setVerbose(dumpClass);
    configuration.setJointCompilationOptions(options);

    compiler = new FileSystemCompiler(configuration);
}
 
開發者ID:apache,項目名稱:groovy,代碼行數:14,代碼來源:FileSystemCompilerTest.java

示例7: generateCompilerConfigurationFromOptions

import org.codehaus.groovy.control.CompilerConfiguration; //導入方法依賴的package包/類
public static CompilerConfiguration generateCompilerConfigurationFromOptions(CommandLine cli) throws IOException {
    // Setup the configuration data
    CompilerConfiguration configuration = new CompilerConfiguration();

    if (cli.hasOption("classpath")) {
        configuration.setClasspath(cli.getOptionValue("classpath"));
    }

    if (cli.hasOption('d')) {
        configuration.setTargetDirectory(cli.getOptionValue('d'));
    }

    configuration.setParameters(cli.hasOption("pa"));

    if (cli.hasOption("encoding")) {
        configuration.setSourceEncoding(cli.getOptionValue("encoding"));
    }

    if (cli.hasOption("basescript")) {
        configuration.setScriptBaseClass(cli.getOptionValue("basescript"));
    }

    // joint compilation parameters
    if (cli.hasOption('j')) {
        Map<String, Object> compilerOptions = new HashMap<String, Object>();

        String[] namedValues = cli.getOptionValues("J");
        compilerOptions.put("namedValues", namedValues);

        String[] flags = cli.getOptionValues("F");
        if (flags != null && cli.hasOption("pa")){
            flags = Arrays.copyOf(flags, flags.length + 1);
            flags[flags.length - 1] = "parameters";
        }
        compilerOptions.put("flags", flags);

        configuration.setJointCompilationOptions(compilerOptions);
    }

    if (cli.hasOption("indy")) {
        configuration.getOptimizationOptions().put("int", false);
        configuration.getOptimizationOptions().put("indy", true);
    }

    String configScripts = System.getProperty("groovy.starter.configscripts", null);
    if (cli.hasOption("configscript") || (configScripts != null && !configScripts.isEmpty())) {
        List<String> scripts = new ArrayList<String>();
        if (cli.hasOption("configscript")) {
            scripts.add(cli.getOptionValue("configscript"));
        }
        if (configScripts != null) {
            scripts.addAll(StringGroovyMethods.tokenize((CharSequence) configScripts, ','));
        }
        processConfigScripts(scripts, configuration);
    }

    return configuration;
}
 
開發者ID:apache,項目名稱:groovy,代碼行數:59,代碼來源:FileSystemCompiler.java


注:本文中的org.codehaus.groovy.control.CompilerConfiguration.setTargetDirectory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。