Search in sources :

Example 6 with StandardJavaFileManager

use of org.eclipse.ceylon.javax.tools.StandardJavaFileManager in project ceylon by eclipse.

the class BcTests method compileJava.

private CompilationTask compileJava(String... sourcePaths) {
    java.util.List<File> sourceFiles = new ArrayList<File>(sourcePaths.length);
    for (String file : sourcePaths) {
        sourceFiles.add(new File(getPackagePath(), file));
    }
    JavaCompiler runCompiler = ToolProvider.getSystemJavaCompiler();
    assertNotNull("Missing Java compiler, this test is probably being run with a JRE instead of a JDK!", runCompiler);
    StandardJavaFileManager runFileManager = runCompiler.getStandardFileManager(null, null, null);
    // make sure the destination repo exists
    new File(destDir).mkdirs();
    List<String> options = new LinkedList<String>();
    options.addAll(Arrays.asList("-sourcepath", getSourcePath(), "-d", destDir, "-cp", getClassPathAsPath()));
    Iterable<? extends JavaFileObject> compilationUnits1 = runFileManager.getJavaFileObjectsFromFiles(sourceFiles);
    return runCompiler.getTask(null, runFileManager, null, options, null, compilationUnits1);
}
Also used : ArrayList(java.util.ArrayList) JavaCompiler(org.eclipse.ceylon.javax.tools.JavaCompiler) StandardJavaFileManager(org.eclipse.ceylon.javax.tools.StandardJavaFileManager) File(java.io.File) LinkedList(java.util.LinkedList)

Aggregations

StandardJavaFileManager (org.eclipse.ceylon.javax.tools.StandardJavaFileManager)6 File (java.io.File)4 JavaCompiler (org.eclipse.ceylon.javax.tools.JavaCompiler)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)2 CompilationTask (org.eclipse.ceylon.javax.tools.JavaCompiler.CompilationTask)2 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 java.util (java.util)1 LinkedList (java.util.LinkedList)1 JarOutputStream (java.util.jar.JarOutputStream)1 ZipEntry (java.util.zip.ZipEntry)1 ZipFile (java.util.zip.ZipFile)1 ArtifactContext (org.eclipse.ceylon.cmr.api.ArtifactContext)1 RepositoryManager (org.eclipse.ceylon.cmr.api.RepositoryManager)1 SupportedAnnotationTypes (org.eclipse.ceylon.javax.annotation.processing.SupportedAnnotationTypes)1 org.eclipse.ceylon.javax.lang.model.util (org.eclipse.ceylon.javax.lang.model.util)1 JavaFileManager (org.eclipse.ceylon.javax.tools.JavaFileManager)1 Location (org.eclipse.ceylon.javax.tools.JavaFileManager.Location)1 JavaFileObject (org.eclipse.ceylon.javax.tools.JavaFileObject)1