From 7e078aedbe0e2799e1f9993e062a10ebb7f0372a Mon Sep 17 00:00:00 2001 From: Guillaume Le Floch Date: Fri, 3 Dec 2021 11:50:35 +0100 Subject: [PATCH] Make sure quarkusGenerateCode is run before tests --- .../src/main/java/io/quarkus/gradle/QuarkusPlugin.java | 1 + .../io/quarkus/gradle/QuarkusPluginFunctionalTest.java | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java index 6445b0894d22e..c2860d18b4e6f 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java @@ -177,6 +177,7 @@ public void execute(Task test) { }); tasks.named(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME, JavaCompile.class, compileTestJava -> { + compileTestJava.dependsOn(quarkusGenerateCode); compileTestJava.dependsOn(quarkusGenerateCodeTests); if (project.getGradle().getStartParameter().getTaskNames().contains(QUARKUS_DEV_TASK_NAME)) { compileTestJava.getOptions().setFailOnError(false); diff --git a/integration-tests/gradle/src/test/java/io/quarkus/gradle/QuarkusPluginFunctionalTest.java b/integration-tests/gradle/src/test/java/io/quarkus/gradle/QuarkusPluginFunctionalTest.java index bfc8c6d251456..fa25471402d78 100644 --- a/integration-tests/gradle/src/test/java/io/quarkus/gradle/QuarkusPluginFunctionalTest.java +++ b/integration-tests/gradle/src/test/java/io/quarkus/gradle/QuarkusPluginFunctionalTest.java @@ -151,6 +151,16 @@ public void canRunTest() throws Exception { assertThat(buildResult.getTasks().get(":test")).isEqualTo(BuildResult.SUCCESS_OUTCOME); } + @Test + public void generateCodeBeforeTests() throws Exception { + createProject(SourceType.JAVA); + + BuildResult firstBuild = runGradleWrapper(projectRoot, "test", "--stacktrace"); + assertThat(firstBuild.getOutput()).contains("Task :quarkusGenerateCode"); + assertThat(firstBuild.getOutput()).contains("Task :quarkusGenerateCodeTests"); + assertThat(firstBuild.getTasks().get(":test")).isEqualTo(BuildResult.SUCCESS_OUTCOME); + } + private void createProject(SourceType sourceType) throws Exception { Map context = new HashMap<>(); context.put("path", "/greeting");