Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register generated output dir for kotlin gradle plugin #13569

Merged
merged 1 commit into from
Dec 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions devtools/gradle/src/main/java/io/quarkus/gradle/QuarkusPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add a TODO to get this list dynamically (if it's not easy enough to just do it ;) )?


public static final String INIT_AND_RUN = "initAndRun";
private Set<Path> sourcesDirectories;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Original file line number Diff line number Diff line change
@@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ExampleResourceTest {
.`when`().get("/hello")
.then()
.statusCode(200)
.body(`is`("hello"))
.body(`is`("hello2"))
}

}