// Do not edit directly!
// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
[id="extensions-groovy"]
= Groovy
:page-aliases: extensions/groovy.adoc
:linkattrs:
:cq-artifact-id: camel-quarkus-groovy
:cq-native-supported: true
:cq-status: Stable
:cq-status-deprecation: Stable
:cq-description: Evaluate a Groovy script
:cq-deprecated: false
:cq-jvm-since: 1.0.0
:cq-native-since: 3.2.0

ifeval::[{doc-show-badges} == true]
[.badges]
[.badge-key]##JVM since##[.badge-supported]##1.0.0## [.badge-key]##Native since##[.badge-supported]##3.2.0##
endif::[]

Evaluate a Groovy script

[id="extensions-groovy-whats-inside"]
== What's inside

* xref:{cq-camel-components}:languages:groovy-language.adoc[Groovy language]
* xref:{cq-camel-components}:dataformats:groovyJson-dataformat.adoc[Groovy JSon data format]
* xref:{cq-camel-components}:dataformats:groovyXml-dataformat.adoc[Groovy XML data format]

Please refer to the above links for usage and configuration details.

[id="extensions-groovy-maven-coordinates"]
== Maven coordinates

https://{link-quarkus-code-generator}/?extension-search=camel-quarkus-groovy[Create a new project with this extension on {link-quarkus-code-generator}, window="_blank"]

Or add the coordinates to your existing project:

[source,xml]
----
<dependency>
    <groupId>org.apache.camel.quarkus</groupId>
    <artifactId>camel-quarkus-groovy</artifactId>
</dependency>
----
ifeval::[{doc-show-user-guide-link} == true]
Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
endif::[]

[id="extensions-groovy-camel-quarkus-limitations"]
== Camel Quarkus limitations

[id="extensions-groovy-limitations-native-mode-limitations"]
=== Native mode limitations

[IMPORTANT]
====
Due to an issue in GraalVM / Mandrel 23.1.x, you *must* build your native application with the https://quarkus.io/guides/all-config#quarkus-core_quarkus-native-report-errors-at-runtime[`--report-unsupported-elements-at-runtime`] option. You can do this by adding the following configuration to `application.properties`.
====

Compilation of Groovy expressions is made with static compilation enabled. Which means that the types used in your expressions must
be known at compile time. Please refer to the https://docs.groovy-lang.org/latest/html/documentation/core-semantics.html#static-type-checking[Groovy documentation for more details].

This primarily impacts the customization of the Groovy Shell and the handling of exchange information.
In native mode, customizing the Groovy Shell and accessing the following exchange variables will not function as expected.

* `attachment`
* `exchangeProperty`
* `exchangeProperties`
* `header`
* `log`
* `variable`
* `variables`

If you use property placeholders within your expressions like.

[source,java]
----
from("direct:start")
    .transform().groovy("println '{{greeting.message}}'");
----

`greeting.message` will be evaluated once at build time and its value will be permanently stored in the native image.
It is not possible to override the value of the property at runtime. Attempting to do so will result in an exception being thrown.

[id="extensions-groovy-limitations-invokedynamic-support-in-native-mode"]
==== InvokeDynamic support in native mode

This extension disables Groovy https://docs.groovy-lang.org/next/html/documentation/invokedynamic-support.html[InvokeDynamic] support during script compilation.

Please note that if scripts or their dependencies make any explicit reference to `InvokeDynamic`, they will not work since the underlying logic required to support the feature is not available in GraalVM / Mandrel >= 25

`InvokeDynamic` support in JVM mode is not affected and remains enabled.

