use of org.gradle.api.internal.tasks.compile.processing.AnnotationProcessorDeclaration in project gradle by gradle.
the class JdkJavaCompiler method createCompileTask.
private JavaCompiler.CompilationTask createCompileTask(JavaCompileSpec spec, JdkJavaCompilerResult result) {
List<String> options = new JavaCompilerArgumentsBuilder(spec).build();
JavaCompiler compiler = javaHomeBasedJavaCompilerFactory.create();
MinimalJavaCompileOptions compileOptions = spec.getCompileOptions();
StandardJavaFileManager standardFileManager = compiler.getStandardFileManager(null, null, compileOptions.getEncoding() != null ? Charset.forName(compileOptions.getEncoding()) : null);
Iterable<? extends JavaFileObject> compilationUnits = standardFileManager.getJavaFileObjectsFromFiles(spec.getSource());
StandardJavaFileManager fileManager = standardFileManager;
if (JavaVersion.current().isJava9Compatible() && emptySourcepathIn(options)) {
fileManager = (StandardJavaFileManager) SourcepathIgnoringProxy.proxy(standardFileManager, StandardJavaFileManager.class);
}
JavaCompiler.CompilationTask task = compiler.getTask(null, fileManager, null, options, spec.getClasses(), compilationUnits);
Set<AnnotationProcessorDeclaration> annotationProcessors = spec.getEffectiveAnnotationProcessors();
if (annotationProcessors != null) {
task = new IncrementalAnnotationProcessingCompileTask(task, annotationProcessors, spec.getAnnotationProcessorPath(), result.getAnnotationProcessingResult());
}
return task;
}
use of org.gradle.api.internal.tasks.compile.processing.AnnotationProcessorDeclaration in project gradle by gradle.
the class IncrementalAnnotationProcessingCompiler method getEffectiveAnnotationProcessors.
/**
* Scans the processor path for processor declarations. Filters them if the explicit <code>-processor</code> argument is given.
* Treats explicit processors that didn't have a matching declaration on the path as non-incremental.
*/
private Set<AnnotationProcessorDeclaration> getEffectiveAnnotationProcessors(JavaCompileSpec spec) {
Map<String, AnnotationProcessorDeclaration> declarations = annotationProcessorDetector.detectProcessors(spec.getAnnotationProcessorPath());
List<String> compilerArgs = spec.getCompileOptions().getCompilerArgs();
int processorIndex = compilerArgs.lastIndexOf("-processor");
if (processorIndex == -1) {
return Sets.newLinkedHashSet(declarations.values());
}
Collection<String> explicitProcessors = Splitter.on(',').splitToList(compilerArgs.get(processorIndex + 1));
Set<AnnotationProcessorDeclaration> effectiveProcessors = Sets.newLinkedHashSet();
for (String explicitProcessor : explicitProcessors) {
AnnotationProcessorDeclaration declaration = declarations.get(explicitProcessor);
if (declaration != null) {
effectiveProcessors.add(declaration);
} else {
effectiveProcessors.add(new AnnotationProcessorDeclaration(explicitProcessor, IncrementalAnnotationProcessorType.UNKNOWN));
}
}
return effectiveProcessors;
}
use of org.gradle.api.internal.tasks.compile.processing.AnnotationProcessorDeclaration in project gradle by gradle.
the class IncrementalCompilerDecorator method warnAboutNonIncrementalProcessors.
private void warnAboutNonIncrementalProcessors(List<AnnotationProcessorDeclaration> nonIncrementalProcessors) {
if (LOG.isInfoEnabled()) {
StringBuilder processorListing = new StringBuilder();
for (AnnotationProcessorDeclaration processor : nonIncrementalProcessors) {
processorListing.append(TextUtil.getPlatformLineSeparator()).append('\t').append(processor);
}
LOG.info("{} - is not incremental. The following annotation processors don't support incremental compilation:{}", displayName, processorListing);
}
}
use of org.gradle.api.internal.tasks.compile.processing.AnnotationProcessorDeclaration in project gradle by gradle.
the class IncrementalCompilerDecorator method getNonIncrementalProcessors.
private List<AnnotationProcessorDeclaration> getNonIncrementalProcessors() {
Map<String, AnnotationProcessorDeclaration> allProcessors = annotationProcessorDetector.detectProcessors(annotationProcessorPath);
List<AnnotationProcessorDeclaration> nonIncrementalProcessors = Lists.newArrayListWithCapacity(allProcessors.size());
for (AnnotationProcessorDeclaration processor : allProcessors.values()) {
if (!processor.getType().isIncremental()) {
nonIncrementalProcessors.add(processor);
}
}
return nonIncrementalProcessors;
}
use of org.gradle.api.internal.tasks.compile.processing.AnnotationProcessorDeclaration in project gradle by gradle.
the class IncrementalCompilerDecorator method getCompiler.
private Compiler<JavaCompileSpec> getCompiler(IncrementalTaskInputs inputs, CompilationSourceDirs sourceDirs) {
if (!inputs.isIncremental()) {
LOG.info("{} - is not incremental (e.g. outputs have changed, no previous execution, etc.).", displayName);
return cleaningCompiler;
}
if (!sourceDirs.canInferSourceRoots()) {
LOG.info("{} - is not incremental. Unable to infer the source directories.", displayName);
return cleaningCompiler;
}
List<AnnotationProcessorDeclaration> nonIncrementalProcessors = getNonIncrementalProcessors();
if (!nonIncrementalProcessors.isEmpty()) {
warnAboutNonIncrementalProcessors(nonIncrementalProcessors);
return cleaningCompiler;
}
ClassSetAnalysisData data = compileCaches.getLocalClassSetAnalysisStore().get();
if (data == null) {
LOG.info("{} - is not incremental. No class analysis data available from the previous build.", displayName);
return cleaningCompiler;
}
PreviousCompilation previousCompilation = new PreviousCompilation(new ClassSetAnalysis(data), compileCaches.getLocalJarClasspathSnapshotStore(), compileCaches.getJarSnapshotCache(), compileCaches.getAnnotationProcessorPathStore());
return new SelectiveCompiler(inputs, previousCompilation, cleaningCompiler, staleClassDetecter, compilationInitializer, jarClasspathSnapshotMaker);
}
Aggregations