use of org.curioswitch.gradle.protobuf.tasks.GenerateProtoTask in project curiostack by curioswitch.
the class ProtobufPlugin method configureSourceSet.
private static SourceSetTasks configureSourceSet(String sourceSetName, Project project, ProtobufExtension extension) {
NamedDomainObjectProvider<SourceDirectorySet> sources = extension.getSources().register(sourceSetName);
Configuration protobufConfiguration = project.getConfigurations().create(SourceSetUtils.getConfigName(sourceSetName, "protobuf"), c -> {
c.setVisible(false);
c.setTransitive(true);
c.setExtendsFrom(ImmutableList.of());
});
TaskProvider<ExtractProtosTask> extract = project.getTasks().register("extract" + SourceSetUtils.getTaskSuffix(sourceSetName) + "Proto", ExtractProtosTask.class, t -> {
t.getFiles().from(protobufConfiguration);
t.setDestDir(project.file("build/extracted-protos/" + sourceSetName));
});
TaskProvider<ExtractProtosTask> extractInclude = project.getTasks().register("extractInclude" + SourceSetUtils.getTaskSuffix(sourceSetName) + "Proto", ExtractProtosTask.class, t -> t.setDestDir(project.file("build/extracted-include-protos/" + sourceSetName)));
TaskProvider<GenerateProtoTask> generateProto = project.getTasks().register("generate" + SourceSetUtils.getTaskSuffix(sourceSetName) + "Proto", GenerateProtoTask.class, sourceSetName, extension);
// To ensure languages are added in order, we have to make sure this is hooked up eagerly.
var languages = project.getObjects().listProperty(LanguageSettings.class).empty();
extension.getLanguages().all(languages::add);
generateProto.configure(t -> {
t.dependsOn(extract, extractInclude);
t.getSources().source(sources.get()).srcDir(extract.get().getDestDir());
t.include(extractInclude.get().getDestDir());
t.setLanguages(languages);
});
return ImmutableSourceSetTasks.builder().extractProtos(extract).extractIncludeProtos(extractInclude).generateProto(generateProto).build();
}
Aggregations