diff --git a/devtools/gradle/src/main/java/io/quarkus/gradle/QuarkusPlugin.java b/devtools/gradle/src/main/java/io/quarkus/gradle/QuarkusPlugin.java index 8f0c332075fdc8..22a1f6add90d97 100644 --- a/devtools/gradle/src/main/java/io/quarkus/gradle/QuarkusPlugin.java +++ b/devtools/gradle/src/main/java/io/quarkus/gradle/QuarkusPlugin.java @@ -191,6 +191,18 @@ public void execute(Task test) { project.getPlugins().withId("org.jetbrains.kotlin.jvm", plugin -> { tasks.getByName("compileKotlin").dependsOn(quarkusGenerateCode); tasks.getByName("compileTestKotlin").dependsOn(quarkusGenerateCodeTests); + + // Register the quarkus-generated-code + SourceSetContainer sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class) + .getSourceSets(); + SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME); + SourceSet testSourceSet = sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME); + SourceSet generatedSourceSet = sourceSets.getByName(QuarkusGenerateCode.QUARKUS_GENERATED_SOURCES); + SourceSet generatedTestSourceSet = sourceSets.getByName(QuarkusGenerateCode.QUARKUS_TEST_GENERATED_SOURCES); + for (String provider : QuarkusGenerateCode.CODE_GENERATION_PROVIDER) { + mainSourceSet.getJava().srcDir(new File(generatedSourceSet.getJava().getOutputDir(), provider)); + testSourceSet.getJava().srcDir(new File(generatedTestSourceSet.getJava().getOutputDir(), provider)); + } }); } diff --git a/devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusGenerateCode.java b/devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusGenerateCode.java index 6be319e680d7ae..f52d900bffcf49 100644 --- a/devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusGenerateCode.java +++ b/devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusGenerateCode.java @@ -29,6 +29,8 @@ public class QuarkusGenerateCode extends QuarkusTask { public static final String QUARKUS_GENERATED_SOURCES = "quarkus-generated-sources"; public static final String QUARKUS_TEST_GENERATED_SOURCES = "quarkus-test-generated-sources"; + // TODO dynamically load generation provider, or make them write code directly in quarkus-generated-sources + public static final String[] CODE_GENERATION_PROVIDER = new String[] { "grpc" }; public static final String INIT_AND_RUN = "initAndRun"; private Set sourcesDirectories; diff --git a/integration-tests/gradle/src/test/java/io/quarkus/gradle/KotlinGRPCProjectBuildTest.java b/integration-tests/gradle/src/test/java/io/quarkus/gradle/KotlinGRPCProjectBuildTest.java index 15e92e2468bdbb..1148f70087ca11 100644 --- a/integration-tests/gradle/src/test/java/io/quarkus/gradle/KotlinGRPCProjectBuildTest.java +++ b/integration-tests/gradle/src/test/java/io/quarkus/gradle/KotlinGRPCProjectBuildTest.java @@ -4,13 +4,11 @@ import java.io.File; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; public class KotlinGRPCProjectBuildTest extends QuarkusGradleWrapperTestBase { @Test - @Disabled public void testBasicMultiModuleBuild() throws Exception { final File projectDir = getProjectDir("kotlin-grpc-project"); final BuildResult build = runGradleWrapper(projectDir, "clean", "build"); diff --git a/integration-tests/gradle/src/test/resources/kotlin-grpc-project/src/main/kotlin/org/acme/ExampleResource.kt b/integration-tests/gradle/src/test/resources/kotlin-grpc-project/src/main/kotlin/org/acme/ExampleResource.kt index 0e08a592d2bb05..00c3c4f2a15c0f 100644 --- a/integration-tests/gradle/src/test/resources/kotlin-grpc-project/src/main/kotlin/org/acme/ExampleResource.kt +++ b/integration-tests/gradle/src/test/resources/kotlin-grpc-project/src/main/kotlin/org/acme/ExampleResource.kt @@ -5,10 +5,12 @@ import javax.ws.rs.Path import javax.ws.rs.Produces import javax.ws.rs.core.MediaType +import io.quarkus.example.HelloMsg + @Path("/hello") class ExampleResource { @GET @Produces(MediaType.TEXT_PLAIN) - fun hello() = "hello" + fun hello() = "hello" + HelloMsg.Status.TEST_ONE.getNumber() } \ No newline at end of file diff --git a/integration-tests/gradle/src/test/resources/kotlin-grpc-project/src/main/proto/hello.proto b/integration-tests/gradle/src/test/resources/kotlin-grpc-project/src/main/proto/hello.proto new file mode 100644 index 00000000000000..4ebcaf36db77ab --- /dev/null +++ b/integration-tests/gradle/src/test/resources/kotlin-grpc-project/src/main/proto/hello.proto @@ -0,0 +1,23 @@ +syntax = "proto3"; +package io.quarkus.example; + +option java_multiple_files = true; +option java_package = "io.quarkus.example"; + +import "google/protobuf/timestamp.proto"; + + +message HelloMsg { + enum Status { + UNKNOWN = 0; + NOT_SERVING = 1; + TEST_ONE = 2; + } + string message = 1; + google.protobuf.Timestamp date_time = 2; + Status status = 3; +} + +service DevModeService { + rpc Check(HelloMsg) returns (HelloMsg); +} \ No newline at end of file diff --git a/integration-tests/gradle/src/test/resources/kotlin-grpc-project/src/test/kotlin/org/acme/ExampleResourceTest.kt b/integration-tests/gradle/src/test/resources/kotlin-grpc-project/src/test/kotlin/org/acme/ExampleResourceTest.kt index 1545d38f1899f2..18d3c9c8013cb9 100644 --- a/integration-tests/gradle/src/test/resources/kotlin-grpc-project/src/test/kotlin/org/acme/ExampleResourceTest.kt +++ b/integration-tests/gradle/src/test/resources/kotlin-grpc-project/src/test/kotlin/org/acme/ExampleResourceTest.kt @@ -14,7 +14,7 @@ class ExampleResourceTest { .`when`().get("/hello") .then() .statusCode(200) - .body(`is`("hello")) + .body(`is`("hello2")) } } \ No newline at end of file