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

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

commit 6da43f2a5900c1a4611f830a2f90a76209e3567c
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Feb 25 17:08:56 2026 +0100

    camel-jbang - transform route should be able to disregard boolean 
properties function
---
 .../DefaultPropertiesFunctionResolver.java         | 15 +++++++------
 .../component/properties/PropertiesComponent.java  |  6 -----
 .../java/org/apache/camel/main/KameletMain.java    |  9 ++++----
 ...ndencyDownloaderPropertiesFunctionResolver.java | 26 +++++++++++++++++++++-
 4 files changed, 38 insertions(+), 18 deletions(-)

diff --git 
a/core/camel-base/src/main/java/org/apache/camel/component/properties/DefaultPropertiesFunctionResolver.java
 
b/core/camel-base/src/main/java/org/apache/camel/component/properties/DefaultPropertiesFunctionResolver.java
index a88f42816b02..f5951dafffc5 100644
--- 
a/core/camel-base/src/main/java/org/apache/camel/component/properties/DefaultPropertiesFunctionResolver.java
+++ 
b/core/camel-base/src/main/java/org/apache/camel/component/properties/DefaultPropertiesFunctionResolver.java
@@ -43,13 +43,6 @@ public class DefaultPropertiesFunctionResolver extends 
ServiceSupport
     private final Map<String, PropertiesFunction> functions = new 
LinkedHashMap<>();
 
     public DefaultPropertiesFunctionResolver() {
-        // include out of the box functions
-        addPropertiesFunction(new EnvPropertiesFunction());
-        addPropertiesFunction(new SysPropertiesFunction());
-        addPropertiesFunction(new ServicePropertiesFunction());
-        addPropertiesFunction(new ServiceHostPropertiesFunction());
-        addPropertiesFunction(new ServicePortPropertiesFunction());
-        addPropertiesFunction(new BooleanPropertiesFunction());
     }
 
     @Override
@@ -124,6 +117,14 @@ public class DefaultPropertiesFunctionResolver extends 
ServiceSupport
 
     @Override
     protected void doInit() throws Exception {
+        // include out of the box functions
+        addPropertiesFunction(new EnvPropertiesFunction());
+        addPropertiesFunction(new SysPropertiesFunction());
+        addPropertiesFunction(new ServicePropertiesFunction());
+        addPropertiesFunction(new ServiceHostPropertiesFunction());
+        addPropertiesFunction(new ServicePortPropertiesFunction());
+        addPropertiesFunction(new BooleanPropertiesFunction());
+
         functions.values().forEach(f -> 
CamelContextAware.trySetCamelContext(f, camelContext));
         ServiceHelper.initService(functions.values());
     }
diff --git 
a/core/camel-base/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java
 
b/core/camel-base/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java
index 9215e4125475..9957c589a9a3 100644
--- 
a/core/camel-base/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java
+++ 
b/core/camel-base/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java
@@ -131,12 +131,6 @@ public class PropertiesComponent extends ServiceSupport
 
     public PropertiesComponent() {
         addPropertiesLookupListener(defaultPropertiesLookupListener);
-        // include out of the box functions
-        addPropertiesFunction(new EnvPropertiesFunction());
-        addPropertiesFunction(new SysPropertiesFunction());
-        addPropertiesFunction(new ServicePropertiesFunction());
-        addPropertiesFunction(new ServiceHostPropertiesFunction());
-        addPropertiesFunction(new ServicePortPropertiesFunction());
     }
 
     /**
diff --git 
a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java 
b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java
index 6d949b81481a..91ace180b2b7 100644
--- 
a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java
+++ 
b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java
@@ -440,11 +440,13 @@ public class KameletMain extends MainCommandLineSupport {
         answer.getCamelContextExtension().setStartupStepRecorder(new 
BacklogStartupStepRecorder());
 
         boolean export = 
"true".equals(getInitialProperties().get(getInstanceType() + ".export"));
+        boolean transform = 
"true".equals(getInitialProperties().get(getInstanceType() + ".transform"));
         if (export) {
-            setupExport(answer, export);
+            // both when exporting and transforming routes then we need to 
setup in special mode
+            setupExport(answer, true);
         } else {
             PropertiesComponent pc = (PropertiesComponent) 
answer.getPropertiesComponent();
-            pc.setPropertiesFunctionResolver(new 
DependencyDownloaderPropertiesFunctionResolver(answer, false));
+            pc.setPropertiesFunctionResolver(new 
DependencyDownloaderPropertiesFunctionResolver(answer, false, transform));
         }
 
         // groovy scripts
@@ -482,7 +484,6 @@ public class KameletMain extends MainCommandLineSupport {
         SagaDownloader.registerDownloadReifiers(this);
 
         // if transforming DSL then disable processors as we just want to work 
on the model (not runtime processors)
-        boolean transform = 
"true".equals(getInitialProperties().get(getInstanceType() + ".transform"));
         if (transform) {
             // we just want to transform, so disable custom bean or processors 
as they may use code that does not work
             
answer.getGlobalOptions().put(ProcessorReifier.DISABLE_BEAN_OR_PROCESS_PROCESSORS,
 "true");
@@ -781,7 +782,7 @@ public class KameletMain extends MainCommandLineSupport {
         
addInitialProperty("camel.component.properties.ignore-missing-location", 
"true");
         PropertiesComponent pc = (PropertiesComponent) 
answer.getPropertiesComponent();
         pc.setPropertiesParser(new ExportPropertiesParser(answer));
-        pc.setPropertiesFunctionResolver(new 
DependencyDownloaderPropertiesFunctionResolver(answer, export));
+        pc.setPropertiesFunctionResolver(new 
DependencyDownloaderPropertiesFunctionResolver(answer, export, false));
 
         // override default type converters with our export converter that is 
more flexible during exporting
         ExportTypeConverter ec = new ExportTypeConverter();
diff --git 
a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/DependencyDownloaderPropertiesFunctionResolver.java
 
b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/DependencyDownloaderPropertiesFunctionResolver.java
index 2766e8ef189d..5a01fae03229 100644
--- 
a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/DependencyDownloaderPropertiesFunctionResolver.java
+++ 
b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/DependencyDownloaderPropertiesFunctionResolver.java
@@ -17,8 +17,10 @@
 package org.apache.camel.main.download;
 
 import org.apache.camel.CamelContext;
+import org.apache.camel.component.properties.BooleanPropertiesFunction;
 import org.apache.camel.component.properties.DefaultPropertiesFunctionResolver;
 import org.apache.camel.spi.PropertiesFunction;
+import org.apache.camel.support.service.ServiceHelper;
 
 /**
  * Auto downloaded needed JARs when resolving properties functions.
@@ -26,11 +28,13 @@ import org.apache.camel.spi.PropertiesFunction;
 public class DependencyDownloaderPropertiesFunctionResolver extends 
DefaultPropertiesFunctionResolver {
 
     private final boolean export;
+    private final boolean transform;
 
-    public DependencyDownloaderPropertiesFunctionResolver(CamelContext 
camelContext, boolean export) {
+    public DependencyDownloaderPropertiesFunctionResolver(CamelContext 
camelContext, boolean export, boolean transform) {
         super();
         setCamelContext(camelContext);
         this.export = export;
+        this.transform = transform;
     }
 
     @Override
@@ -78,6 +82,14 @@ public class DependencyDownloaderPropertiesFunctionResolver 
extends DefaultPrope
                         getCamelContext().getVersion());
             }
         }
+        if ("boolean".equals(name) && transform) {
+            // ensure boolean function can fallback and return a value as we 
just want to transform
+            var bf = new ExportBooleanFunction();
+            bf.setCamelContext(getCamelContext());
+            ServiceHelper.startService(bf);
+            addPropertiesFunction(bf);
+
+        }
         PropertiesFunction answer = super.resolvePropertiesFunction(name);
         if (answer != null && export) {
             answer = new ExportPropertiesFunction(answer);
@@ -85,6 +97,18 @@ public class DependencyDownloaderPropertiesFunctionResolver 
extends DefaultPrope
         return answer;
     }
 
+    private static class ExportBooleanFunction extends 
BooleanPropertiesFunction {
+
+        @Override
+        public String apply(String remainder) {
+            try {
+                return super.apply(remainder);
+            } catch (Exception e) {
+                return "true";
+            }
+        }
+    }
+
     private static class ExportPropertiesFunction implements 
PropertiesFunction {
 
         private final PropertiesFunction delegate;

Reply via email to