You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Vladislav Krejcirik <vk...@gmail.com> on 2024/04/15 13:19:50 UTC
Managing Quarkus dependencies when working with Native build
Hey,
I’m building Kamel K integration where I’m using Native build due to sparing some Kubernetes resources. I’m using VS Code and RH extension pack for Camel. It seems like I need to tag all my classes with @RegisterForReflection. When I do that, I’m having unresolved dependency - io.quarkus.runtime.annotations.RegisterForReflection. Since the project is not managed by either Maven or Gradle, what is the good practice for including Quarkus .jar files for design time?
Thank you,
Vlad
Re: Managing Quarkus dependencies when working with Native build
Posted by Vladislav Krejcirik <vk...@gmail.com>.
Could you be more specific, please? I can add line below, but that’s for runtime. I need to figure out design time - to prevent VS Code complaining about missing dependencies.
// camel-k: dependency=mvn:org.apache.camel.quarkus:camel-quarkus-core
Thanks,
Vlad
> On 15. 4. 2024, at 16:43, Claudio Miranda <cl...@claudius.com.br> wrote:
>
> Em seg., 15 de abr. de 2024 às 15:14, Vladislav Krejcirik
> <vk...@gmail.com> escreveu:
>>
>> Thanks for quick response! I do need reflection for my class. Please see my dummy Integration below. When I removed annotation, it was not able to find my ‘getRandomNumber’ method. When I added annotation, it worked just fine, but my VS Code was complaining about missing Quarkus dependency.
>
> You can add the maven artifact: io.quarkus:quarkus-core to the
> dependency list, so the vscode can learn about the dependency.
>
> --
> Claudio Miranda
>
> claudio@claudius.com.br
> http://www.claudius.com.br
Re: Managing Quarkus dependencies when working with Native build
Posted by Claudio Miranda <cl...@claudius.com.br>.
Em seg., 15 de abr. de 2024 às 15:14, Vladislav Krejcirik
<vk...@gmail.com> escreveu:
>
> Thanks for quick response! I do need reflection for my class. Please see my dummy Integration below. When I removed annotation, it was not able to find my ‘getRandomNumber’ method. When I added annotation, it worked just fine, but my VS Code was complaining about missing Quarkus dependency.
You can add the maven artifact: io.quarkus:quarkus-core to the
dependency list, so the vscode can learn about the dependency.
--
Claudio Miranda
claudio@claudius.com.br
http://www.claudius.com.br
Re: Managing Quarkus dependencies when working with Native build
Posted by Vladislav Krejcirik <vk...@gmail.com>.
Thanks for quick response! I do need reflection for my class. Please see my dummy Integration below. When I removed annotation, it was not able to find my ‘getRandomNumber’ method. When I added annotation, it worked just fine, but my VS Code was complaining about missing Quarkus dependency.
Thanks,
Vlad
// camel-k: language=java
// camel-k: trait=quarkus.enabled=true
// camel-k: trait=quarkus.build-mode=native
// camel-k: trait=builder.verbose=true
// camel-k: trait=builder.node-selector.'camelk-builds'='true'
import org.apache.camel.builder.RouteBuilder;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
public class Demo05 extends RouteBuilder {
@Override
public void configure() throws Exception {
// Write your routes here, for example:
from("timer:java?period={{time:1000}}")
.id("demo05")
.bean(this, "getRandomNumber")
.log("Random number: ${body}")
.choice()
.when(simple("${body} > 50"))
.to("direct:greater")
.otherwise()
.to("direct:lower");
from("direct:greater")
.log("Greater than 50: ${body}");
from("direct:lower")
.log("Lower than 50: ${body}");
}
public int getRandomNumber() {
return (int) (Math.random() * 100) + 1;
}
}
> On 15. 4. 2024, at 15:47, Claudio Miranda <cl...@claudius.com.br> wrote:
>
> Em seg., 15 de abr. de 2024 às 14:21, Vladislav Krejcirik
> <vk...@gmail.com> escreveu:
>>
>> I’m building Kamel K integration where I’m using Native build due to sparing some Kubernetes resources. I’m using VS Code and RH extension pack for Camel. It seems like I need to tag all my classes with @RegisterForReflection. When I do that, I’m having unresolved dependency - io.quarkus.runtime.annotations.RegisterForReflection. Since the project is not managed by either Maven or Gradle, what is the good practice for including Quarkus .jar files for design time?
>
> Your code only needs RegisterForReflection annotation if your custom
> classes do reflection, see
> https://camel.apache.org/camel-quarkus/3.8.x/user-guide/native-mode.html#reflection
>
> Otherwise there is no need for the annotation.
>
> For in depth doc about the extension development in camel, see
> https://camel.apache.org/camel-quarkus/3.8.x/contributor-guide/create-new-extension.html
>
> --
> Claudio Miranda
>
> claudio@claudius.com.br
> http://www.claudius.com.br
Re: Managing Quarkus dependencies when working with Native build
Posted by Claudio Miranda <cl...@claudius.com.br>.
Em seg., 15 de abr. de 2024 às 14:21, Vladislav Krejcirik
<vk...@gmail.com> escreveu:
>
> I’m building Kamel K integration where I’m using Native build due to sparing some Kubernetes resources. I’m using VS Code and RH extension pack for Camel. It seems like I need to tag all my classes with @RegisterForReflection. When I do that, I’m having unresolved dependency - io.quarkus.runtime.annotations.RegisterForReflection. Since the project is not managed by either Maven or Gradle, what is the good practice for including Quarkus .jar files for design time?
Your code only needs RegisterForReflection annotation if your custom
classes do reflection, see
https://camel.apache.org/camel-quarkus/3.8.x/user-guide/native-mode.html#reflection
Otherwise there is no need for the annotation.
For in depth doc about the extension development in camel, see
https://camel.apache.org/camel-quarkus/3.8.x/contributor-guide/create-new-extension.html
--
Claudio Miranda
claudio@claudius.com.br
http://www.claudius.com.br