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

nferraro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git


The following commit(s) were added to refs/heads/master by this push:
     new bd553bc  Fix #394: unable to run Groovy routes on Quarkus
     new cc7bbf6  Merge pull request #415 from nicolaferraro/fix-groovy
bd553bc is described below

commit bd553bc12c1cadfba8b005a883f51cfbded09164
Author: nicolaferraro <[email protected]>
AuthorDate: Thu Aug 6 18:41:55 2020 +0200

    Fix #394: unable to run Groovy routes on Quarkus
---
 .../k/loader/groovy/GroovySourceLoader.groovy      | 43 +++++++++-------------
 .../apache/camel/component/knative/knative.json    |  2 +-
 2 files changed, 18 insertions(+), 27 deletions(-)

diff --git 
a/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/GroovySourceLoader.groovy
 
b/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/GroovySourceLoader.groovy
index f0e2fc8..78cc20d 100644
--- 
a/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/GroovySourceLoader.groovy
+++ 
b/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/GroovySourceLoader.groovy
@@ -16,12 +16,11 @@
  */
 package org.apache.camel.k.loader.groovy
 
-
-import org.apache.camel.builder.endpoint.EndpointRouteBuilder
 import org.apache.camel.k.Runtime
 import org.apache.camel.k.Source
 import org.apache.camel.k.SourceLoader
 import org.apache.camel.k.loader.groovy.dsl.IntegrationConfiguration
+import org.apache.camel.k.support.RouteBuilders
 import org.codehaus.groovy.control.CompilerConfiguration
 import org.codehaus.groovy.control.customizers.ImportCustomizer
 
@@ -33,30 +32,22 @@ class GroovySourceLoader implements SourceLoader {
 
     @Override
     Result load(Runtime runtime, Source source) throws Exception {
-        def builder = new EndpointRouteBuilder() {
-            @Override
-            void configure() throws Exception {
-                def ic = new ImportCustomizer()
-                ic.addStarImports('org.apache.camel')
-                ic.addStarImports('org.apache.camel.spi')
-
-                def cc = new CompilerConfiguration()
-                cc.addCompilationCustomizers(ic)
-                cc.setScriptBaseClass(DelegatingScript.class.getName())
-
-                def sh = new GroovyShell(new Binding(), cc)
-                def is = source.resolveAsInputStream(getContext())
-
-                is.withCloseable {
-                    def reader = new InputStreamReader(is)
-                    def script = (DelegatingScript) sh.parse(reader)
-
-                    // set the delegate target
-                    script.setDelegate(new IntegrationConfiguration(this))
-                    script.run()
-                }
-            }
-        }
+        def builder = RouteBuilders.endpoint(source, { reader, builder ->
+            def ic = new ImportCustomizer()
+            ic.addStarImports('org.apache.camel')
+            ic.addStarImports('org.apache.camel.spi')
+
+            def cc = new CompilerConfiguration()
+            cc.addCompilationCustomizers(ic)
+            cc.setScriptBaseClass(DelegatingScript.class.getName())
+
+            def sh = new GroovyShell(new Binding(), cc)
+            def script = (DelegatingScript) sh.parse(reader)
+
+            // set the delegate target
+            script.setDelegate(new IntegrationConfiguration(builder))
+            script.run()
+        })
 
         return Result.on(builder)
     }
diff --git 
a/camel-knative/camel-knative/src/generated/resources/org/apache/camel/component/knative/knative.json
 
b/camel-knative/camel-knative/src/generated/resources/org/apache/camel/component/knative/knative.json
index 4954d47..c1c562a 100644
--- 
a/camel-knative/camel-knative/src/generated/resources/org/apache/camel/component/knative/knative.json
+++ 
b/camel-knative/camel-knative/src/generated/resources/org/apache/camel/component/knative/knative.json
@@ -11,7 +11,7 @@
     "supportLevel": "Preview",
     "groupId": "org.apache.camel.k",
     "artifactId": "camel-knative",
-    "version": "1.5.0-SNAPSHOT",
+    "version": "1.5.1-SNAPSHOT",
     "scheme": "knative",
     "extendsScheme": "",
     "syntax": "knative:type\/name",

Reply via email to