Skip to content

Commit

Permalink
Handle avro generator in gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
glefloch committed Apr 2, 2021
1 parent d3ecfb2 commit ab2596c
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Path> sourcesDirectories;
Expand Down
18 changes: 18 additions & 0 deletions integration-tests/gradle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
<artifactId>quarkus-arc</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-avro</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-bootstrap-core</artifactId>
Expand Down Expand Up @@ -107,6 +112,19 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-avro-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core-deployment</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -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");
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
quarkusPlatformArtifactId=quarkus-bom
quarkusPlatformGroupId=io.quarkus
Original file line number Diff line number Diff line change
@@ -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'
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"protocol" : "HelloProtocol",
"namespace" : "org.acme.quarkus.hello",
"types" : [
{
"type": "enum",
"namespace": "org.acme.quarkus.hello",
"name": "Provider",
"symbols" : ["MAIL", "SMS"]
}
]
}
Original file line number Diff line number Diff line change
@@ -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(","));
}
}

0 comments on commit ab2596c

Please sign in to comment.