public CompileStrategy( ReadWriteFileSystem<I> sourcePath, ReadWriteFileSystem<O> sourceOutput, ReadWriteFileSystem<O> classOutput) { // this.classPath = new LinkedList<ReadFileSystem<?>>(); this.sourcePath = sourcePath; this.sourceOutput = sourceOutput; this.classOutput = classOutput; this.config = new CompilerConfig().force(true); }
public CompileStrategy( ReadWriteFileSystem<I> sourcePath, ReadWriteFileSystem<O> sourceOutput, ReadWriteFileSystem<O> classOutput) { // this.classPath = new LinkedList<ReadFileSystem<?>>(); this.sourcePath = sourcePath; this.sourceOutput = sourceOutput; this.classOutput = classOutput; this.config = new CompilerConfig().force(true); }
@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"); }