Search in sources :

Example 1 with AnnotationProcessingData

use of org.gradle.api.internal.tasks.compile.incremental.processing.AnnotationProcessingData in project gradle by gradle.

the class IncrementalResultStoringCompiler method getAnnotationProcessingData.

private AnnotationProcessingData getAnnotationProcessingData(JavaCompileSpec spec, WorkResult result) {
    Set<AnnotationProcessorDeclaration> processors = spec.getEffectiveAnnotationProcessors();
    if (processors.isEmpty()) {
        return new AnnotationProcessingData();
    }
    AnnotationProcessingData previousAnnotationProcessingData = null;
    RecompilationSpec recompilationSpec = null;
    if (result instanceof IncrementalCompilationResult) {
        previousAnnotationProcessingData = ((IncrementalCompilationResult) result).getPreviousCompilationData().getAnnotationProcessingData();
        recompilationSpec = ((IncrementalCompilationResult) result).getRecompilationSpec();
        result = ((IncrementalCompilationResult) result).getCompilerResult();
    }
    Set<String> changedClasses = recompilationSpec == null ? Collections.emptySet() : recompilationSpec.getClassesToCompile();
    if (result instanceof ApiCompilerResult) {
        AnnotationProcessingResult processingResult = ((ApiCompilerResult) result).getAnnotationProcessingResult();
        AnnotationProcessingData newAnnotationProcessingData = new AnnotationProcessingData(processingResult.getGeneratedTypesWithIsolatedOrigin(), processingResult.getAggregatedTypes(), processingResult.getGeneratedAggregatingTypes(), processingResult.getGeneratedResourcesWithIsolatedOrigin(), processingResult.getGeneratedAggregatingResources(), processingResult.getFullRebuildCause());
        if (previousAnnotationProcessingData == null) {
            return newAnnotationProcessingData;
        }
        return mergeAnnotationProcessingData(previousAnnotationProcessingData, newAnnotationProcessingData, changedClasses);
    }
    return new AnnotationProcessingData(ImmutableMap.of(), ImmutableSet.of(), ImmutableSet.of(), ImmutableMap.of(), ImmutableSet.of(), "the chosen compiler did not support incremental annotation processing");
}
Also used : AnnotationProcessingData(org.gradle.api.internal.tasks.compile.incremental.processing.AnnotationProcessingData) RecompilationSpec(org.gradle.api.internal.tasks.compile.incremental.recomp.RecompilationSpec) IncrementalCompilationResult(org.gradle.api.internal.tasks.compile.incremental.recomp.IncrementalCompilationResult) AnnotationProcessingResult(org.gradle.api.internal.tasks.compile.incremental.processing.AnnotationProcessingResult) ApiCompilerResult(org.gradle.api.internal.tasks.compile.ApiCompilerResult) AnnotationProcessorDeclaration(org.gradle.api.internal.tasks.compile.processing.AnnotationProcessorDeclaration)

Example 2 with AnnotationProcessingData

use of org.gradle.api.internal.tasks.compile.incremental.processing.AnnotationProcessingData in project gradle by gradle.

the class IncrementalResultStoringCompiler method storeResult.

private void storeResult(JavaCompileSpec spec, WorkResult result) {
    ClassSetAnalysisData outputSnapshot = classpathSnapshotter.analyzeOutputFolder(spec.getDestinationDir());
    ClassSetAnalysisData classpathSnapshot = classpathSnapshotter.getClasspathSnapshot(Iterables.concat(spec.getCompileClasspath(), spec.getModulePath()));
    AnnotationProcessingData annotationProcessingData = getAnnotationProcessingData(spec, result);
    CompilerApiData compilerApiData = getCompilerApiData(spec, result);
    ClassSetAnalysisData minimizedClasspathSnapshot = classpathSnapshot.reduceToTypesAffecting(outputSnapshot, compilerApiData);
    PreviousCompilationData data = new PreviousCompilationData(outputSnapshot, annotationProcessingData, minimizedClasspathSnapshot, compilerApiData);
    File previousCompilationDataFile = Objects.requireNonNull(spec.getCompileOptions().getPreviousCompilationDataFile());
    previousCompilationAccess.writePreviousCompilationData(data, previousCompilationDataFile);
}
Also used : AnnotationProcessingData(org.gradle.api.internal.tasks.compile.incremental.processing.AnnotationProcessingData) CompilerApiData(org.gradle.api.internal.tasks.compile.incremental.compilerapi.CompilerApiData) ClassSetAnalysisData(org.gradle.api.internal.tasks.compile.incremental.deps.ClassSetAnalysisData) PreviousCompilationData(org.gradle.api.internal.tasks.compile.incremental.recomp.PreviousCompilationData) File(java.io.File)

Aggregations

AnnotationProcessingData (org.gradle.api.internal.tasks.compile.incremental.processing.AnnotationProcessingData)2 File (java.io.File)1 ApiCompilerResult (org.gradle.api.internal.tasks.compile.ApiCompilerResult)1 CompilerApiData (org.gradle.api.internal.tasks.compile.incremental.compilerapi.CompilerApiData)1 ClassSetAnalysisData (org.gradle.api.internal.tasks.compile.incremental.deps.ClassSetAnalysisData)1 AnnotationProcessingResult (org.gradle.api.internal.tasks.compile.incremental.processing.AnnotationProcessingResult)1 IncrementalCompilationResult (org.gradle.api.internal.tasks.compile.incremental.recomp.IncrementalCompilationResult)1 PreviousCompilationData (org.gradle.api.internal.tasks.compile.incremental.recomp.PreviousCompilationData)1 RecompilationSpec (org.gradle.api.internal.tasks.compile.incremental.recomp.RecompilationSpec)1 AnnotationProcessorDeclaration (org.gradle.api.internal.tasks.compile.processing.AnnotationProcessorDeclaration)1