Package javax.tools.JavaCompiler

Examples of javax.tools.JavaCompiler.CompilationTask


        }
    }

    void compile(DiagnosticChecker dc, JavaSource... sources) {
        try {
            CompilationTask ct = javacTool.getTask(null, null, dc,
                    Arrays.asList("-d", testDir.getAbsolutePath(), "-cp", testDir.getAbsolutePath()),
                    null, Arrays.asList(sources));
            ct.call();
        }
        catch (Exception e) {
            e.printStackTrace();
            error("Internal compilation error");
        }
View Full Code Here


        testDir.mkdirs();
        fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(testDir));

        JavaSource js = new JavaSource();
        System.err.println(js.getCharContent(false));
        CompilationTask t = comp.getTask(null, fm, null, null, null, Arrays.asList(js));
        if (!t.call())
            throw new Error("compilation failed");

        File testClass = new File(testDir, "Test.class");
        String out = javap(testClass);
View Full Code Here

        for (int i = 0; i < extraClassPath.length; i++) {
            if(i > 0)
                cp.append(File.pathSeparator);
            cp.append(extraClassPath[i]);
        }
        CompilationTask task = javaCompiler.getTask(null, null, null, Arrays.asList("-d", classesOutputFolder.getPath(),
                "-cp", cp.toString(),
                "-sourcepath", sourceFolder.getPath()), null, compilationUnits);
        assertEquals(Boolean.TRUE, task.call());
       
        File jarFolder = new File(jarOutputFolder, moduleName.replace('.', File.separatorChar)+File.separatorChar+moduleVersion);
        jarFolder.mkdirs();
        File jarFile = new File(jarFolder, moduleName+"-"+moduleVersion+".jar");
        // now jar it up
View Full Code Here

        List<CompilationTask> tasks = new ArrayList<CompilationTask>();
        for (int i = 1; i <= MAX_TASKS; i++) {
            File tmpDir = new File(tk + "_" + i);
            tmpDir.mkdirs();
            List<String> options = Arrays.asList( "-d", tmpDir.getPath() );
            CompilationTask t = comp.getTask(null, fm, null, options, null, files);
            ((JavacTask) t).setTaskListener(createTaskListener(tk, i));
            tasks.add(t);
        }

        for (CompilationTask t: tasks)
View Full Code Here

        Iterable<? extends JavaFileObject> files =
                fm.getJavaFileObjects(new File(testSrc, thisClassName + ".java"));
        File tmpDir = new File(first + "_" + second);
        tmpDir.mkdirs();
        List<String> options = Arrays.asList( "-d", tmpDir.getPath() );
        CompilationTask t = comp.getTask(null, fm, null, options, null, files);

        try {
            first.test(t);
            second.test(t);
            error("No exception thrown");
View Full Code Here

            if (fmOpts != null)
                fm = new FileManager(fm, fmOpts);

            Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjectsFromFiles(files);

            CompilationTask t = c.getTask(out, fm, dc, opts, null, fos);
            Boolean ok = t.call();

            if (keys != null) {
                for (Diagnostic<? extends JavaFileObject> d: dc.getDiagnostics()) {
                    scanForKeys((JCDiagnostic) d, keys);
                }
View Full Code Here

        JavaCompiler c = ToolProvider.getSystemJavaCompiler();
        List<String> opts = new ArrayList<String>();
        opts.add("-proc:only");
        opts.addAll(javac_extras);
        CompilationTask t = c.getTask(log, fileManager, diagnosticListener, opts, internalize(classes), null);
        JavahProcessor p = new JavahProcessor(g);
        t.setProcessors(Collections.singleton(p));

        boolean ok = t.call();
        if (p.exit != null)
            throw new Util.Exit(p.exit);
        return ok;
    }
View Full Code Here

        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
        StandardJavaFileManager fm =
                compiler.getStandardFileManager(null, null, null);
        File emptyFile = File.createTempFile("Empty", ".java");
        File[] files = new File[] { emptyFile, emptyFile };
        CompilationTask task = compiler.getTask(null, fm, diag,
                null, null, fm.getJavaFileObjects(files));
        if (! task.call()) {
            throw new AssertionError("compilation failed");
        }
    }
View Full Code Here

        File destdir = new File(tmpdir, "dest");
        write(srcdir, "pkg/X.java", "package pkg; class X {}");
        write(srcdir, "resources/file.txt", "hello");
        destdir.mkdirs();

        CompilationTask task = javac.getTask(null, null, null,
                Arrays.asList("-sourcepath", srcdir.toString(), "-d", destdir.toString()),
                Collections.singleton("pkg.X"), null);
        task.setProcessors(Collections.singleton(new AnnoProc()));
        boolean result = task.call();
        System.err.println("javac result with single source dir: " + result);
        expect(result, true);
    }
View Full Code Here

        File destdir = new File(tmpdir, "dest");
        write(srcdir, "pkg/X.java", "package pkg; class X {}");
        write(rsrcdir, "resources/file.txt", "hello");
        destdir.mkdirs();

        CompilationTask task = javac.getTask(null, null, null,
                Arrays.asList("-sourcepath", srcdir + File.pathSeparator + rsrcdir, "-d", destdir.toString()),
                Collections.singleton("pkg.X"), null);
        task.setProcessors(Collections.singleton(new AnnoProc()));
        boolean result = task.call();
        System.err.println("javac result with composite source path: " + result);
        expect(result, true);
    }
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.