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 17d2b72ea677d..6f6a72d104394 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 @@ -32,7 +32,7 @@ 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[] CODE_GENERATION_PROVIDER = new String[] { "grpc", "avpr", "avsc" }; public static final String INIT_AND_RUN = "initAndRun"; private Set sourcesDirectories; diff --git a/integration-tests/gradle/src/test/java/io/quarkus/gradle/devmode/AvroDevModeTest.java b/integration-tests/gradle/src/test/java/io/quarkus/gradle/devmode/AvroDevModeTest.java new file mode 100644 index 0000000000000..54ad10b820761 --- /dev/null +++ b/integration-tests/gradle/src/test/java/io/quarkus/gradle/devmode/AvroDevModeTest.java @@ -0,0 +1,22 @@ +package io.quarkus.gradle.devmode; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.google.common.collect.ImmutableMap; + +public class AvroDevModeTest extends QuarkusDevGradleTestBase { + @Override + protected String projectDirectoryName() { + return "avro-simple-project"; + } + + @Override + protected void testDevMode() throws Exception { + assertThat(getHttpResponse("/hello")).isEqualTo("MAIL,SMS"); + + replace("src/main/avro/hello.avpr", + ImmutableMap.of(" \"symbols\" : [\"MAIL\", \"SMS\"]", " \"symbols\" : [\"EMAIL\"]")); + + assertUpdatedResponseContains("/hello", "EMAIL"); + } +} diff --git a/integration-tests/gradle/src/test/resources/avro-simple-project/build.gradle b/integration-tests/gradle/src/test/resources/avro-simple-project/build.gradle new file mode 100644 index 0000000000000..f3f4e5850bdde --- /dev/null +++ b/integration-tests/gradle/src/test/resources/avro-simple-project/build.gradle @@ -0,0 +1,30 @@ +plugins { + id 'java' + id 'io.quarkus' +} + +repositories { + // in case a custom local repo is configured we are going to use that instead of the default mavenLocal() + if (System.properties.containsKey('maven.repo.local')) { + maven { + url System.properties.get('maven.repo.local') + } + } else { + mavenLocal() + } + mavenCentral() + gradlePluginPortal() +} + +dependencies { + implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}") + implementation 'io.quarkus:quarkus-resteasy' + implementation 'io.quarkus:quarkus-avro' +} + +group 'org.acme' +version '1.0.0-SNAPSHOT' + +test { + systemProperty "java.util.logging.manager", "org.jboss.logmanager.LogManager" +} \ No newline at end of file diff --git a/integration-tests/gradle/src/test/resources/avro-simple-project/gradle.properties b/integration-tests/gradle/src/test/resources/avro-simple-project/gradle.properties new file mode 100644 index 0000000000000..ec2b6ef199c2c --- /dev/null +++ b/integration-tests/gradle/src/test/resources/avro-simple-project/gradle.properties @@ -0,0 +1,2 @@ +quarkusPlatformArtifactId=quarkus-bom +quarkusPlatformGroupId=io.quarkus diff --git a/integration-tests/gradle/src/test/resources/avro-simple-project/settings.gradle b/integration-tests/gradle/src/test/resources/avro-simple-project/settings.gradle new file mode 100644 index 0000000000000..27eb5357f0483 --- /dev/null +++ b/integration-tests/gradle/src/test/resources/avro-simple-project/settings.gradle @@ -0,0 +1,18 @@ +pluginManagement { + repositories { + // in case a custom local repo is configured we are going to use that instead of the default mavenLocal() + if (System.properties.containsKey('maven.repo.local')) { + maven { + url System.properties.get('maven.repo.local') + } + } else { + mavenLocal() + } + mavenCentral() + gradlePluginPortal() + } + plugins { + id 'io.quarkus' version "${quarkusPluginVersion}" + } +} +rootProject.name = 'avro-project' \ No newline at end of file diff --git a/integration-tests/gradle/src/test/resources/avro-simple-project/src/main/avro/hello.avpr b/integration-tests/gradle/src/test/resources/avro-simple-project/src/main/avro/hello.avpr new file mode 100644 index 0000000000000..92631583c4f70 --- /dev/null +++ b/integration-tests/gradle/src/test/resources/avro-simple-project/src/main/avro/hello.avpr @@ -0,0 +1,12 @@ +{ + "protocol" : "HelloProtocol", + "namespace" : "org.acme.quarkus.hello", + "types" : [ + { + "type": "enum", + "namespace": "org.acme.quarkus.hello", + "name": "Provider", + "symbols" : ["MAIL", "SMS"] + } + ] +} \ No newline at end of file diff --git a/integration-tests/gradle/src/test/resources/avro-simple-project/src/main/java/org/acme/quarkus/sample/HelloResource.java b/integration-tests/gradle/src/test/resources/avro-simple-project/src/main/java/org/acme/quarkus/sample/HelloResource.java new file mode 100644 index 0000000000000..b885722662d1c --- /dev/null +++ b/integration-tests/gradle/src/test/resources/avro-simple-project/src/main/java/org/acme/quarkus/sample/HelloResource.java @@ -0,0 +1,22 @@ +package org.acme.quarkus.sample; + +import static java.util.stream.Collectors.joining; + +import java.util.Arrays; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import org.acme.quarkus.hello.Provider; + +@Path("/hello") +public class HelloResource { + + @GET + @Produces(MediaType.TEXT_PLAIN) + public String providerValues() { + return Arrays.stream(Provider.values()).map(String::valueOf).collect(joining(",")); + } +} \ No newline at end of file