Search in sources :

Example 1 with GenerateProtoTask

use of com.google.protobuf.gradle.GenerateProtoTask in project curiostack by curioswitch.

the class GrpcApiPluginTest method normal.

@Test
public void normal() throws Exception {
    Project project = ProjectBuilder.builder().withName("api").build();
    project.setGroup("org.curioswitch.test");
    project.getPluginManager().apply(DependencyManagementPlugin.class);
    DependencyManagementExtension dependencyManagement = project.getExtensions().getByType(DependencyManagementExtension.class);
    dependencyManagement.dependencies(handler -> {
        handler.dependency("io.grpc:grpc-core:5.0.0");
        handler.dependency("io.grpc:grpc-protobuf:5.0.0");
        handler.dependency("io.grpc:grpc-stub:5.0.0");
        handler.dependency("com.google.protobuf:protoc:6.0.0");
    });
    project.getPluginManager().apply("org.curioswitch.gradle-grpc-api-plugin");
    project.setProperty("archivesBaseName", "curio-test-api");
    ((DefaultProject) project).evaluate();
    Task task = project.getTasks().findByName("generateProto");
    assertThat(task).isInstanceOf(GenerateProtoTask.class).isNotNull();
    GenerateProtoTask generateProtoTask = (GenerateProtoTask) task;
    assertThat(generateProtoTask.getGenerateDescriptorSet()).isTrue();
    assertThat(generateProtoTask.getDescriptorSetOptions().getIncludeSourceInfo()).isTrue();
    assertThat(generateProtoTask.getDescriptorSetOptions().getIncludeImports()).isTrue();
    assertThat(generateProtoTask.getDescriptorSetOptions().getPath().toString()).isEqualTo(project.getBuildDir() + "/resources/main/META-INF/armeria/grpc/org.curioswitch.test.curio-test-api.dsc");
    ProtobufConfigurator protobuf = project.getConvention().getPlugin(ProtobufConvention.class).getProtobuf();
    protobuf.protoc(LambdaClosure.of((ExecutableLocator locator) -> assertThat(locator.getArtifact()).isEqualTo("com.google.protobuf:protoc:6.0.0")));
    protobuf.plugins(LambdaClosure.of((NamedDomainObjectContainer<ExecutableLocator> locators) -> assertThat(locators.getByName("grpc").getArtifact()).isEqualTo("io.grpc:protoc-gen-grpc-java:5.0.0")));
}
Also used : ProtobufConvention(com.google.protobuf.gradle.ProtobufConvention) Project(org.gradle.api.Project) DefaultProject(org.gradle.api.internal.project.DefaultProject) GenerateProtoTask(com.google.protobuf.gradle.GenerateProtoTask) Task(org.gradle.api.Task) ExecutableLocator(com.google.protobuf.gradle.ExecutableLocator) DefaultProject(org.gradle.api.internal.project.DefaultProject) DependencyManagementExtension(io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension) GenerateProtoTask(com.google.protobuf.gradle.GenerateProtoTask) ProtobufConfigurator(com.google.protobuf.gradle.ProtobufConfigurator) Test(org.junit.Test)

Aggregations

ExecutableLocator (com.google.protobuf.gradle.ExecutableLocator)1 GenerateProtoTask (com.google.protobuf.gradle.GenerateProtoTask)1 ProtobufConfigurator (com.google.protobuf.gradle.ProtobufConfigurator)1 ProtobufConvention (com.google.protobuf.gradle.ProtobufConvention)1 DependencyManagementExtension (io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension)1 Project (org.gradle.api.Project)1 Task (org.gradle.api.Task)1 DefaultProject (org.gradle.api.internal.project.DefaultProject)1 Test (org.junit.Test)1