Skip to content

Commit

Permalink
Merge pull request #16201 from glefloch/fix/gradle-avro
Browse files Browse the repository at this point in the history
Handle avro generator in gradle
  • Loading branch information
michalszynkiewicz authored Apr 7, 2021
2 parents eb7348e + 6595e94 commit 2ab99f6
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .github/workflows/ci-actions-incremental.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ jobs:
then
echo -e '\033[0;31mError:\033[0m Dependencies to extension artifacts are outdated!' 1>&2
echo -e '\033[0;31mError:\033[0m Run ./update-extension-dependencies.sh and add the modified pom.xml files to your commit.' 1>&2
echo -e '\033[0;31mError:\033[0m Diff is:' 1>&2
git --no-pager diff '*pom.xml' 1>&2
exit 1
fi
- name: Tar Maven Repo
Expand Down Expand Up @@ -456,6 +458,8 @@ jobs:
then
echo -e '\033[0;31mError:\033[0m Dependencies in integration-tests/gradle/pom.xml are outdated!' 1>&2
echo -e '\033[0;31mError:\033[0m Run update-dependencies.sh in integration-tests/gradle and add the modified pom.xml file to your commit.' 1>&2
echo -e '\033[0;31mError:\033[0m Diff is:' 1>&2
git --no-pager diff '*pom.xml' 1>&2
exit 1
fi
working-directory: integration-tests/gradle
Expand Down
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 2ab99f6

Please sign in to comment.