Package javax.tools.JavaCompiler

Examples of javax.tools.JavaCompiler.CompilationTask


    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
    StandardJavaFileManager fileManager =
      compiler.getStandardFileManager(null, null, null);
   
    CompilationTask cTask = compiler.getTask(null, fileManager, null, null,
        null,
        fileManager.getJavaFileObjects(
            javaFiles.toArray(new File[javaFiles.size()])));
    assertTrue(cTask.call());
  }
View Full Code Here


        files.putAll(findFiles(new File(dir), ".java"));
      }
      files.putAll(findFiles(additionalSourcesDir,".java"));
      if (files.size() > 0) {
        final Iterable<? extends JavaFileObject> compilationUnits1 = fileManager.getJavaFileObjectsFromFiles(files.values());
        final CompilationTask task = compiler.getTask(sw, fileManager, null, options, null, compilationUnits1);
        if (!task.call()) {
          logger.error(sw.toString());
          throw new CopperRuntimeException("Compilation failed, see logfile for details");
        }
      }
    }
View Full Code Here

      options.add("-cp");
      String classPath = buildClassPath(classPaths);
      options.add(classPath);
    }

    CompilationTask task = compiler.getTask(null, manager, null, options, null, javaObjects);
    if (!task.call()) { // compile error
      log.error("Compilation error");
      throw new RuntimeException("Compilation error");
    }

    long duration = System.currentTimeMillis() - startMillis;
View Full Code Here

    JavaFileObject compilationUnit = getCompilationUnit(sourcecode);

    //logger.debug("Compiling the following source code\n{}", sourcecode);
    // Run the compiler.
    try {
      CompilationTask task = compiler.getTask(null, fileManager, listener, getOptions(), null, Collections.singleton(compilationUnit));
      long n0 = System.nanoTime();
      if(!task.call()){
        throw new CompileException("Compilation failed", null);
      }
      long n1 = (System.nanoTime() - n0)/1000/1000;
     
    } catch (RuntimeException rte) {
View Full Code Here

    File[] files= javaDir.listFiles();
    JavaCompiler compiler= ToolProvider.getSystemJavaCompiler();
    StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null);
    Iterable<? extends JavaFileObject> compilationUnits= fileManager.getJavaFileObjectsFromFiles(Arrays.asList(files));
    DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<JavaFileObject>();
        CompilationTask task = compiler.getTask(null, null, diagnostics, null, null, compilationUnits);
        success = task.call();
        if (!success) {
            for (Diagnostic<? extends JavaFileObject> diag : diagnostics.getDiagnostics()) {
              Output.conerr.println(diag.toString());
            }
            return success;
View Full Code Here

    // compiling it
    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
    StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null);
    Iterable<? extends JavaFileObject> compilationUnits1 = fileManager.getJavaFileObjects(javaFile);
    CompilationTask task = compiler.getTask(null, fileManager, null, null, null, compilationUnits1);
    task.call();

    // here is the compiled file
    File classFile = new File(javaFile.getParentFile(), className+".class");
    Assert.assertTrue(classFile.exists());
View Full Code Here

    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
    StandardJavaFileManager fileManager =
      compiler.getStandardFileManager(null, null, null);
   
    CompilationTask cTask = compiler.getTask(null, fileManager, null, null,
        null,
        fileManager.getJavaFileObjects(
            javaFiles.toArray(new File[javaFiles.size()])));
    assertTrue(cTask.call());
  }
View Full Code Here

    protected boolean internalJava6Compile(JavaCompiler compiler, JavaFileManager fileManager,
                                           DiagnosticListener<JavaFileObject> listener,
                                           Iterable<? extends JavaFileObject> fileList) {
        List<String> args = new ArrayList<String>();
        addArgs(args);
        CompilationTask task = compiler.getTask(null, fileManager, listener, args, null, fileList);
        Boolean ret = task.call();
        try {
            fileManager.close();
        } catch (IOException e) {
            System.err.print("[ERROR] IOException during compiling.");
            e.printStackTrace();
View Full Code Here

                                                source);
            }
        }

        // Get a CompliationTask from the compiler and compile the sources
        final CompilationTask task = compiler.getTask(null, javaFileManager, diagnostics, options, null, sources);
        final Boolean result = task.call();
        if (result == null || !result.booleanValue()) {
            throw new JdkCompileException("Compilation failed.", classes.keySet(), diagnostics);
        }

        try {
View Full Code Here

    protected boolean internalJava6Compile(JavaCompiler compiler, JavaFileManager fileManager,
                                           DiagnosticListener<JavaFileObject> listener,
                                           Iterable<? extends JavaFileObject> fileList) {
        List<String> args = new ArrayList<String>();
        addArgs(args);
        CompilationTask task = compiler.getTask(null, fileManager, listener, args, null, fileList);
        Boolean ret = task.call();
        try {
            fileManager.close();
        } catch (IOException e) {
            System.err.print("[ERROR] IOException during compiling.");
            e.printStackTrace();
View Full Code Here

TOP

Related Classes of javax.tools.JavaCompiler.CompilationTask

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.