This is an automated email from the ASF dual-hosted git repository.

ppalaga pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git


The following commit(s) were added to refs/heads/main by this push:
     new 8f302f5  Deprecated @BuildTimeAvroDataFormat in favor of quarkus-avro 
build time class generation #2513
8f302f5 is described below

commit 8f302f5deeed0801c61f4e16925e48c08bba9e5a
Author: aldettinger <[email protected]>
AuthorDate: Tue Jun 15 16:57:31 2021 +0200

    Deprecated @BuildTimeAvroDataFormat in favor of quarkus-avro build time 
class generation #2513
---
 .../ROOT/pages/reference/extensions/avro.adoc      |  5 ++++
 .../avro/runtime/src/main/doc/configuration.adoc   |  5 ++++
 .../component/avro/BuildTimeAvroDataFormat.java    |  8 +++++
 integration-tests/avro/pom.xml                     | 34 ++++++++++++++++++++++
 integration-tests/avro/src/main/avro/admin.avsc    |  7 +++++
 .../quarkus/component/avro/it/AvroResource.java    | 13 +++++++++
 .../camel/quarkus/component/avro/it/AvroRoute.java |  4 +++
 .../camel/quarkus/component/avro/it/AvroTest.java  |  6 ++++
 8 files changed, 82 insertions(+)

diff --git a/docs/modules/ROOT/pages/reference/extensions/avro.adoc 
b/docs/modules/ROOT/pages/reference/extensions/avro.adoc
index f26df5f..4d4afc1 100644
--- a/docs/modules/ROOT/pages/reference/extensions/avro.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/avro.adoc
@@ -57,3 +57,8 @@ public void configure() {
 }
 ----
 
+Since Camel Quarkus 2.0.0, @BuildTimeAvroDataFormat is deprecated. The build 
time class generation approach from quarkus-avro is preferred. As such, it is 
advised to store *.avsc files in a folder named 'avro' to have @AvroGenerated 
class created at build-time by quarkus-avro.
+
+Please see a running configuration at work in the 
link:https://github.com/apache/camel-quarkus/tree/main/integration-tests/avro[Camel
 Quarkus Avro integration tests].
+There is also a quarkus-avro integration test 
link:https://github.com/quarkusio/quarkus/tree/main/integration-tests/avro-reload/src/test/avro[here].
+
diff --git a/extensions/avro/runtime/src/main/doc/configuration.adoc 
b/extensions/avro/runtime/src/main/doc/configuration.adoc
index f0bb9fc..3aa6c88 100644
--- a/extensions/avro/runtime/src/main/doc/configuration.adoc
+++ b/extensions/avro/runtime/src/main/doc/configuration.adoc
@@ -13,3 +13,8 @@ public void configure() {
   
from("direct:marshalUsingBuildTimeAvroDataFormat").marshal(buildTimeAvroDataFormat);
 }
 ----
+
+Since Camel Quarkus 2.0.0, @BuildTimeAvroDataFormat is deprecated. The build 
time class generation approach from quarkus-avro is preferred. As such, it is 
advised to store *.avsc files in a folder named 'avro' to have @AvroGenerated 
class created at build-time by quarkus-avro.
+
+Please see a running configuration at work in the 
link:https://github.com/apache/camel-quarkus/tree/main/integration-tests/avro[Camel
 Quarkus Avro integration tests].
+There is also a quarkus-avro integration test 
link:https://github.com/quarkusio/quarkus/tree/main/integration-tests/avro-reload/src/test/avro[here].
\ No newline at end of file
diff --git 
a/extensions/avro/runtime/src/main/java/org/apache/camel/quarkus/component/avro/BuildTimeAvroDataFormat.java
 
b/extensions/avro/runtime/src/main/java/org/apache/camel/quarkus/component/avro/BuildTimeAvroDataFormat.java
index 13bb6e4..b77722d 100644
--- 
a/extensions/avro/runtime/src/main/java/org/apache/camel/quarkus/component/avro/BuildTimeAvroDataFormat.java
+++ 
b/extensions/avro/runtime/src/main/java/org/apache/camel/quarkus/component/avro/BuildTimeAvroDataFormat.java
@@ -23,6 +23,14 @@ import java.lang.annotation.Target;
 
 @Target({ ElementType.FIELD })
 @Retention(RetentionPolicy.RUNTIME)
+@Deprecated
+/**
+ * @deprecated Prefer storing *.avsc files in a folder named 'avro' to have 
@AvroGenerated class created at build-time
+ *             by quarkus-avro.
+ * @see        <a href=
+ *             
"https://github.com/quarkusio/quarkus/tree/main/integration-tests/avro-reload/src/test/avro";>quarkus-avro/a>
+ *             test.
+ */
 public @interface BuildTimeAvroDataFormat {
     public String value();
 }
diff --git a/integration-tests/avro/pom.xml b/integration-tests/avro/pom.xml
index fd3f605..a469c2d 100644
--- a/integration-tests/avro/pom.xml
+++ b/integration-tests/avro/pom.xml
@@ -84,6 +84,40 @@
         </dependency>
     </dependencies>
 
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>io.quarkus</groupId>
+                <artifactId>quarkus-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>generate-code</id>
+                        <goals>
+                            <goal>generate-code</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>add-source</goal>
+                        </goals>
+                        <configuration>
+                            <sources>
+                                
<source>${project.build.directory}/generated-sources/avsc</source>
+                            </sources>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
     <profiles>
         <profile>
             <id>native</id>
diff --git a/integration-tests/avro/src/main/avro/admin.avsc 
b/integration-tests/avro/src/main/avro/admin.avsc
new file mode 100644
index 0000000..a5035ba
--- /dev/null
+++ b/integration-tests/avro/src/main/avro/admin.avsc
@@ -0,0 +1,7 @@
+{"namespace": "example.avro",
+ "type": "record",
+ "name": "Admin",
+ "fields": [
+     {"name": "name", "type": "string"}
+ ]
+}
diff --git 
a/integration-tests/avro/src/main/java/org/apache/camel/quarkus/component/avro/it/AvroResource.java
 
b/integration-tests/avro/src/main/java/org/apache/camel/quarkus/component/avro/it/AvroResource.java
index 1a4662d..efd6587 100644
--- 
a/integration-tests/avro/src/main/java/org/apache/camel/quarkus/component/avro/it/AvroResource.java
+++ 
b/integration-tests/avro/src/main/java/org/apache/camel/quarkus/component/avro/it/AvroResource.java
@@ -24,6 +24,7 @@ import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 
+import example.avro.Admin;
 import org.apache.avro.generic.GenericData;
 import org.apache.avro.generic.GenericRecord;
 import org.apache.camel.ProducerTemplate;
@@ -49,6 +50,18 @@ public class AvroResource {
         return output.get("name").toString();
     }
 
+    @Path("/genericMarshalUnmarshalUsingBuildTimeGeneratedClass/{value}")
+    @GET
+    @Produces(MediaType.TEXT_PLAIN)
+    public String 
genericMarshalUnmarshalUsingBuildTimeGeneratedClass(@PathParam("value") String 
value) {
+        GenericRecord input = new GenericData.Record(Admin.SCHEMA$);
+        input.put("name", value);
+        Object marshalled = 
producerTemplate.requestBody("direct:marshalUsingBuildTimeGeneratedClass", 
input);
+        GenericRecord output = 
producerTemplate.requestBody("direct:unmarshalUsingBuildTimeGeneratedClass", 
marshalled,
+                GenericRecord.class);
+        return output.get("name").toString();
+    }
+
     @Path("/genericMarshalUnmarshalUsingConfigureTimeAvroDataFormat/{value}")
     @GET
     @Produces(MediaType.TEXT_PLAIN)
diff --git 
a/integration-tests/avro/src/main/java/org/apache/camel/quarkus/component/avro/it/AvroRoute.java
 
b/integration-tests/avro/src/main/java/org/apache/camel/quarkus/component/avro/it/AvroRoute.java
index 65b32db..95a20d0 100644
--- 
a/integration-tests/avro/src/main/java/org/apache/camel/quarkus/component/avro/it/AvroRoute.java
+++ 
b/integration-tests/avro/src/main/java/org/apache/camel/quarkus/component/avro/it/AvroRoute.java
@@ -18,6 +18,7 @@ package org.apache.camel.quarkus.component.avro.it;
 
 import javax.enterprise.context.ApplicationScoped;
 
+import example.avro.Admin;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.dataformat.avro.AvroDataFormat;
 import org.apache.camel.quarkus.component.avro.BuildTimeAvroDataFormat;
@@ -36,6 +37,9 @@ public class AvroRoute extends RouteBuilder {
         
from("direct:marshalUsingBuildTimeAvroDataFormat").marshal(buildTimeAvroDataFormat);
         
from("direct:unmarshalUsingBuildTimeAvroDataFormat").unmarshal(buildTimeAvroDataFormat);
 
+        
from("direct:marshalUsingBuildTimeGeneratedClass").marshal().avro(Admin.class);
+        
from("direct:unmarshalUsingBuildTimeGeneratedClass").unmarshal().avro(Admin.class);
+
         AvroDataFormat configureTimeAvroDataFormat = new 
AvroDataFormat(getSchema());
         
from("direct:marshalUsingConfigureTimeAvroDataFormat").marshal(configureTimeAvroDataFormat);
         
from("direct:unmarshalUsingConfigureTimeAvroDataFormat").unmarshal(configureTimeAvroDataFormat);
diff --git 
a/integration-tests/avro/src/test/java/org/apache/camel/quarkus/component/avro/it/AvroTest.java
 
b/integration-tests/avro/src/test/java/org/apache/camel/quarkus/component/avro/it/AvroTest.java
index 38ea0c0..900414d 100644
--- 
a/integration-tests/avro/src/test/java/org/apache/camel/quarkus/component/avro/it/AvroTest.java
+++ 
b/integration-tests/avro/src/test/java/org/apache/camel/quarkus/component/avro/it/AvroTest.java
@@ -32,6 +32,12 @@ class AvroTest {
     }
 
     @Test
+    void genericMarshalUnmarshalUsingBuildTimeGeneratedClassShouldSucceed() {
+        
RestAssured.get("/avro/genericMarshalUnmarshalUsingBuildTimeGeneratedClass/bill").then().statusCode(200)
+                .body(is("bill"));
+    }
+
+    @Test
     void 
genericMarshalUnmarshalUsingConfigureTimeAvroDataFormatShouldSucceed() {
         
RestAssured.get("/avro/genericMarshalUnmarshalUsingConfigureTimeAvroDataFormat/elizabeth").then().statusCode(200)
                 .body(is("elizabeth"));

Reply via email to