use of com.mysema.codegen.SimpleCompiler in project querydsl by querydsl.
the class CompileUtils method assertCompiles.
public static void assertCompiles(String name, String source) {
URLClassLoader parent = (URLClassLoader) CompileUtils.class.getClassLoader();
SimpleCompiler compiler = new SimpleCompiler();
MemFileManager fileManager = new MemFileManager(parent, compiler.getStandardFileManager(null, null, null));
String classpath = SimpleCompiler.getClassPath(parent);
List<String> compilationOptions = Arrays.asList("-classpath", classpath, "-g:none");
// compile
SimpleJavaFileObject javaFileObject = new MemSourceFileObject(name, source);
Writer out = new StringWriter();
JavaCompiler.CompilationTask task = compiler.getTask(out, fileManager, null, compilationOptions, null, Collections.singletonList(javaFileObject));
if (!task.call()) {
Assert.fail("Compilation of " + source + " failed.\n" + out.toString());
}
}
use of com.mysema.codegen.SimpleCompiler in project querydsl by querydsl.
the class MetaDataSerializerTest method compile.
private void compile(MetaDataExporter exporter) {
JavaCompiler compiler = new SimpleCompiler();
Set<String> classes = exporter.getClasses();
int compilationResult = compiler.run(null, null, null, classes.toArray(new String[classes.size()]));
if (compilationResult == 0) {
System.out.println("Compilation is successful");
} else {
Assert.fail("Compilation Failed");
}
}
Aggregations