use of javax.annotation.processing.Processor in project androidannotations by androidannotations.
the class ProcessorTestHelper method compileFiles.
public CompileResult compileFiles(Collection<File> compilationUnits) {
DiagnosticCollector<JavaFileObject> diagnosticCollector = new DiagnosticCollector<>();
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
try (StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnosticCollector, null, null)) {
CompilationTask task = compiler.getTask(null, fileManager, diagnosticCollector, compilerOptions, null, fileManager.getJavaFileObjectsFromFiles(compilationUnits));
List<Processor> processors = new ArrayList<>();
for (Class<? extends Processor> processorClass : processorsClasses) {
try {
processors.add(processorClass.newInstance());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
task.setProcessors(processors);
task.call();
} catch (IOException e) {
// we should always be able to close the manager
}
return new CompileResult(diagnosticCollector.getDiagnostics());
}
use of javax.annotation.processing.Processor in project gradle by gradle.
the class IncrementalAnnotationProcessingCompileTask method setupProcessors.
private void setupProcessors() {
processorClassloader = new URLClassLoader(DefaultClassPath.of(annotationProcessorPath).getAsURLArray());
List<Processor> processors = new ArrayList<Processor>(processorDeclarations.size());
for (AnnotationProcessorDeclaration declaredProcessor : processorDeclarations) {
try {
Class<?> processorClass = processorClassloader.loadClass(declaredProcessor.getClassName());
Processor processor = (Processor) processorClass.newInstance();
processor = decorateIfIncremental(processor, declaredProcessor.getType());
processors.add(processor);
} catch (Exception e) {
throw new IllegalArgumentException(e);
}
}
delegate.setProcessors(processors);
}
Aggregations