public void compile() throws IOException, CompilationException { VirtualFileManager fileManager = new VirtualFileManager( javaCompiler.getStandardFileManager(null, null, null), sourcePath, classPaths, sourceOutput, classOutput ); compile(fileManager, getFromSourcePath(fileManager.sourcePath)); }
public void compile() throws IOException, CompilationException { VirtualFileManager fileManager = new VirtualFileManager( javaCompiler.getStandardFileManager(null, null, null), sourcePath, classPaths, sourceOutput, classOutput ); compile(fileManager, getFromSourcePath(fileManager.sourcePath)); }
public void compile(String... compilationUnits) throws IOException, CompilationException { // Copy anything that is not a java file RAMFileSystem sourcePath1 = new RAMFileSystem(); sourcePath.copy(new Filter() { public boolean acceptDir(Object dir, String name) throws IOException { return true; } public boolean acceptFile(Object file, String name) throws IOException { return !name.endsWith(".java"); } }, sourcePath1); // VirtualFileManager fileManager = new VirtualFileManager( javaCompiler.getStandardFileManager(null, null, null), sourcePath1, classPaths, sourceOutput, classOutput ); // Collection<JavaFileObject> files = getFromSourcePath(sourcePath, compilationUnits); // compile(fileManager, files); }
public void compile(String... compilationUnits) throws IOException, CompilationException { // Copy anything that is not a java file RAMFileSystem sourcePath1 = new RAMFileSystem(); sourcePath.copy(new Filter() { public boolean acceptDir(Object dir, String name) throws IOException { return true; } public boolean acceptFile(Object file, String name) throws IOException { return !name.endsWith(".java"); } }, sourcePath1); // VirtualFileManager fileManager = new VirtualFileManager( javaCompiler.getStandardFileManager(null, null, null), sourcePath1, classPaths, sourceOutput, classOutput ); // Collection<JavaFileObject> files = getFromSourcePath(sourcePath, compilationUnits); // compile(fileManager, files); }
void compile() throws IOException, CompilationException { compiler = builder().build(); compiler.compile(); } }
void compile() throws IOException, CompilationException { compiler = builder().build(); compiler.compile(); } }
addClassPath(classPath).build(); compiler.addAnnotationProcessor(new MainProcessor()); compiler.compile();
addClassPath(classPath).build(); compiler.addAnnotationProcessor(new MainProcessor()); compiler.compile();
@Test public void testGetResourceFromClassPath() throws Exception { File fic = File.createTempFile("test", ".jar"); fic.deleteOnExit(); JavaArchive jar = ShrinkWrap.create(JavaArchive.class); jar.addAsResource(new StringAsset("the_resource"), "resource.txt"); jar.as(ZipExporter.class).exportTo(fic, true); JarFileSystem classpath = new JarFileSystem(new JarFile(fic)); RAMFileSystem output = new RAMFileSystem(); Compiler compiler = Compiler.builder(). javaCompiler(compilerProvider). config(new CompilerConfig().force(true)). addClassPath(classpath). sourcePath(new RAMFileSystem()). output(output).build(); GetResource processor = new GetResource(StandardLocation.CLASS_PATH, FileKey.newResourceName("", "resource.txt")); compiler.addAnnotationProcessor(processor); compiler.compile(); processor.assertResource("the_resource"); }
@Test public void testGetResourceFromClassPath() throws Exception { File fic = File.createTempFile("test", ".jar"); fic.deleteOnExit(); JavaArchive jar = ShrinkWrap.create(JavaArchive.class); jar.addAsResource(new StringAsset("the_resource"), "resource.txt"); jar.as(ZipExporter.class).exportTo(fic, true); JarFileSystem classpath = new JarFileSystem(new JarFile(fic)); RAMFileSystem output = new RAMFileSystem(); Compiler compiler = Compiler.builder(). javaCompiler(compilerProvider). config(new CompilerConfig().force(true)). addClassPath(classpath). sourcePath(new RAMFileSystem()). output(output).build(); GetResource processor = new GetResource(StandardLocation.CLASS_PATH, FileKey.newResourceName("", "resource.txt")); compiler.addAnnotationProcessor(processor); compiler.compile(); processor.assertResource("the_resource"); }
compiler.compile(); fail();
compiler.compile(); fail();
compiler.addAnnotationProcessor(processor); try { compiler.compile();
compiler.addAnnotationProcessor(processor); try { compiler.compile();
compiler.compile();
compiler.compile();
@Test public void testGetResourceFromSourcePath() throws Exception { DiskFileSystem input = diskFS("compiler.getresource"); RAMFileSystem output = new RAMFileSystem(); Compiler compiler = Compiler.builder().javaCompiler(compilerProvider).sourcePath(input).output(output).build(); GetResource processor = new GetResource(StandardLocation.SOURCE_PATH, FileKey.newResourceName("compiler.getresource", "A.txt")); compiler.addAnnotationProcessor(processor); compiler.compile(); assertEquals(1, output.size(ReadFileSystem.FILE)); processor.assertResource("value"); }
@Test public void testGetResourceFromSourcePath() throws Exception { DiskFileSystem input = diskFS("compiler.getresource"); RAMFileSystem output = new RAMFileSystem(); Compiler compiler = Compiler.builder().javaCompiler(compilerProvider).sourcePath(input).output(output).build(); GetResource processor = new GetResource(StandardLocation.SOURCE_PATH, FileKey.newResourceName("compiler.getresource", "A.txt")); compiler.addAnnotationProcessor(processor); compiler.compile(); assertEquals(1, output.size(ReadFileSystem.FILE)); processor.assertResource("value"); }