Claus Ibsen created CAMEL-24853:
-----------------------------------

             Summary: camel-jbang - camel export moves a Groovy script the 
route references as a resource: into camel-groovy, where the reference no 
longer resolves
                 Key: CAMEL-24853
                 URL: https://issues.apache.org/jira/browse/CAMEL-24853
             Project: Camel
          Issue Type: Bug
          Components: camel-jbang
            Reporter: Claus Ibsen


A Groovy script used as the body of an expression, referenced from the route as 
a resource:

{code:yaml}
- setBody:
    expression:
      groovy:
        expression: "resource:classpath:shipment-mapping.groovy"
{code}

with {{shipment-mapping.groovy}} next to the route, works with {{camel run}} 
(CAMEL-24852 makes the classpath: form work there too). {{camel export}} copies 
every {{.groovy}} file into {{src/main/resources/camel-groovy}}, the directory 
{{camel.main.groovyScriptPattern}} compiles scripts from at startup, so in the 
exported project the reference must read 
{{resource:classpath:camel-groovy/shipment-mapping.groovy}}, and the same file 
is also compiled as a script (a mapping script with a bare expression body may 
not even compile as one). Neither {{resource:file:}} nor 
{{resource:classpath:}} by bare name survives the export.

The camel-jbang-examples data-mapping example (transform/data-mapping, 
{{resource:file:shipment-mapping.groovy}}) is the case.

Options:
* {{camel export}} keeps a {{.groovy}} file that a route references through 
{{resource:}} at the resources root (not in camel-groovy), so the bare-name 
classpath: reference keeps working and the file is not compiled as a script
* or the export rewrites the reference in the route file to the camel-groovy 
path (fragile: the route files are copied as is today)

The first is the smaller change: the export already scans the route files for 
other things (routesIncludePattern, properties).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to