use of org.gradle.api.internal.tasks.compile.incremental.compilerapi.CompilerApiData 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);
}
use of org.gradle.api.internal.tasks.compile.incremental.compilerapi.CompilerApiData in project gradle by gradle.
the class IncrementalResultStoringCompiler method getCompilerApiData.
private CompilerApiData getCompilerApiData(JavaCompileSpec spec, WorkResult result) {
if (spec.getCompileOptions().supportsCompilerApi()) {
CompilerApiData previousCompilerApiData = null;
RecompilationSpec recompilationSpec = null;
if (result instanceof IncrementalCompilationResult) {
previousCompilerApiData = ((IncrementalCompilationResult) result).getPreviousCompilationData().getCompilerApiData();
recompilationSpec = ((IncrementalCompilationResult) result).getRecompilationSpec();
result = ((IncrementalCompilationResult) result).getCompilerResult();
}
Set<String> changedClasses = recompilationSpec == null ? Collections.emptySet() : recompilationSpec.getClassesToCompile();
ConstantToDependentsMapping previousConstantToDependentsMapping = previousCompilerApiData == null ? null : previousCompilerApiData.getConstantToClassMapping();
Map<String, Set<String>> previousSourceClassesMapping = previousCompilerApiData == null ? null : previousCompilerApiData.getSourceToClassMapping();
if (result instanceof ApiCompilerResult) {
ApiCompilerResult jdkJavaResult = (ApiCompilerResult) result;
ConstantToDependentsMapping newConstantsToDependentsMapping = jdkJavaResult.getConstantsAnalysisResult().getConstantToDependentsMapping().orElseThrow(() -> new GradleException("Constants to dependents mapping not present, but it should be"));
Map<String, Set<String>> newSourceClassesMapping = jdkJavaResult.getSourceClassesMapping();
Map<String, Set<String>> mergedSourceClassesMapping;
if (previousSourceClassesMapping == null) {
mergedSourceClassesMapping = newSourceClassesMapping;
} else {
mergedSourceClassesMapping = mergeSourceClassesMappings(previousSourceClassesMapping, newSourceClassesMapping, changedClasses);
}
ConstantToDependentsMapping mergedConstants = new ConstantToDependentsMappingMerger().merge(newConstantsToDependentsMapping, previousConstantToDependentsMapping, changedClasses);
if (spec.getCompileOptions().supportsConstantAnalysis()) {
return CompilerApiData.withConstantsMapping(mergedSourceClassesMapping, mergedConstants);
} else {
return CompilerApiData.withoutConstantsMapping(mergedSourceClassesMapping);
}
}
}
return CompilerApiData.unavailable();
}
Aggregations