Object (@NotNull String modelName, @NotNull Project project, @NotNull ModelBuilderContext context) { if (!canBuild(modelName)) { return null; } if (!isAtLeastGradle3_4) { return null; } final SourceSetContainer container = JavaPluginUtil.getSourceSetContainer(project); if (container == null) { return null; } Map<String, AnnotationProcessingConfig> sourceSetConfigs = new HashMap<>(); IdeaModule ideaModule = null; IdeaPlugin plugin = project.getPlugins().findPlugin(IdeaPlugin.class); if (plugin != null) { ideaModule = plugin.getModel().getModule(); } for (final SourceSet sourceSet : container) { String compileTaskName = sourceSet.getCompileJavaTaskName(); Task compileTask = project.getTasks().findByName(compileTaskName); if (compileTask instanceof JavaCompile) { CompileOptions options = ((JavaCompile)compileTask).getOptions(); FileCollection path = options.getAnnotationProcessorPath(); if (path != null) { final Set<File> files = path.getFiles(); if (!files.isEmpty()) { List<String> annotationProcessorArgs = new ArrayList<>(); List<String> args = isAtLeastGradle4_5 ? options.getAllCompilerArgs() : options.getCompilerArgs(); for (String arg : args) { if (arg.startsWith("-A")) { annotationProcessorArgs.add(arg); } } File generatedSourcesDirectory; if (isAtLeastGradle6_3) { generatedSourcesDirectory = options.getGeneratedSourceOutputDirectory().get().getAsFile(); } else if (isAtLeastGradle4_3) { generatedSourcesDirectory = options.getAnnotationProcessorGeneratedSourcesDirectory(); } else { generatedSourcesDirectory = null; } String output = generatedSourcesDirectory != null ? generatedSourcesDirectory.getAbsolutePath() : null; sourceSetConfigs.put(sourceSet.getName(), new AnnotationProcessingConfigImpl(files, annotationProcessorArgs, output, isTestSourceSet(sourceSet, ideaModule))); } } } } if (!sourceSetConfigs.isEmpty()) { return new AnnotationProcessingModelImpl(sourceSetConfigs); } return null; }