Add cli-connector support for Camel JBang runtime=quarkus
diff --git a/docs/modules/ROOT/pages/reference/extensions/cli-connector.adoc b/docs/modules/ROOT/pages/reference/extensions/cli-connector.adoc
index 536be15..61c3634 100644
--- a/docs/modules/ROOT/pages/reference/extensions/cli-connector.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/cli-connector.adoc
@@ -39,3 +39,22 @@
 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-cli-connector-additional-camel-quarkus-configuration"]
+== Additional Camel Quarkus configuration
+
+[width="100%",cols="80,5,15",options="header"]
+|===
+| Configuration property | Type | Default
+
+
+|icon:lock[title=Fixed at build time] [[quarkus.camel.cli.enabled]]`link:#quarkus.camel.cli.enabled[quarkus.camel.cli.enabled]`
+
+Sets whether to enable Camel CLI Connector support.
+| `boolean`
+| `true`
+|===
+
+[.configuration-legend]
+{doc-link-icon-lock}[title=Fixed at build time] Configuration property fixed at build time. All other configuration properties are overridable at runtime.
+
diff --git a/extensions-jvm/cli-connector/deployment/pom.xml b/extensions-jvm/cli-connector/deployment/pom.xml
index 37c9ba9..dfb39cb 100644
--- a/extensions-jvm/cli-connector/deployment/pom.xml
+++ b/extensions-jvm/cli-connector/deployment/pom.xml
@@ -46,6 +46,12 @@
             <groupId>org.apache.camel.quarkus</groupId>
             <artifactId>camel-quarkus-cli-connector</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>io.quarkus</groupId>
+            <artifactId>quarkus-junit5-internal</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>
diff --git a/extensions-jvm/cli-connector/deployment/src/main/java/org/apache/camel/quarkus/component/cli/connector/deployment/CliConnectorProcessor.java b/extensions-jvm/cli-connector/deployment/src/main/java/org/apache/camel/quarkus/component/cli/connector/deployment/CliConnectorProcessor.java
index 0edcf22..dcad85e 100644
--- a/extensions-jvm/cli-connector/deployment/src/main/java/org/apache/camel/quarkus/component/cli/connector/deployment/CliConnectorProcessor.java
+++ b/extensions-jvm/cli-connector/deployment/src/main/java/org/apache/camel/quarkus/component/cli/connector/deployment/CliConnectorProcessor.java
@@ -16,14 +16,23 @@
  */
 package org.apache.camel.quarkus.component.cli.connector.deployment;
 
+import java.util.function.BooleanSupplier;
+
+import io.quarkus.builder.Version;
 import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.annotations.BuildSteps;
 import io.quarkus.deployment.annotations.ExecutionTime;
 import io.quarkus.deployment.annotations.Record;
 import io.quarkus.deployment.builditem.FeatureBuildItem;
 import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild;
+import org.apache.camel.quarkus.component.cli.connector.CamelCliConnectorConfig;
+import org.apache.camel.quarkus.component.cli.connector.CamelCliConnectorRecorder;
 import org.apache.camel.quarkus.core.JvmOnlyRecorder;
+import org.apache.camel.quarkus.core.deployment.spi.CamelBeanBuildItem;
+import org.apache.camel.spi.CliConnectorFactory;
 import org.jboss.logging.Logger;
 
+@BuildSteps(onlyIf = CliConnectorProcessor.CliConnectorEnabled.class)
 class CliConnectorProcessor {
 
     private static final Logger LOG = Logger.getLogger(CliConnectorProcessor.class);
@@ -34,6 +43,14 @@
         return new FeatureBuildItem(FEATURE);
     }
 
+    @BuildStep
+    @Record(value = ExecutionTime.STATIC_INIT)
+    CamelBeanBuildItem camelBeanBuildItem(CamelCliConnectorRecorder recorder) {
+        return new CamelBeanBuildItem("quarkusCliConnectorFactory",
+                CliConnectorFactory.class.getName(),
+                recorder.createCliConnectorFactory(Version.getVersion()));
+    }
+
     /**
      * Remove this once this extension starts supporting the native mode.
      */
@@ -43,4 +60,12 @@
         JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
         recorder.warnJvmInNative(FEATURE); // warn at runtime
     }
+
+    static class CliConnectorEnabled implements BooleanSupplier {
+        CamelCliConnectorConfig config;
+
+        public boolean getAsBoolean() {
+            return config.enabled;
+        }
+    }
 }
diff --git a/extensions-jvm/cli-connector/deployment/src/test/java/org/apache/camel/quarkus/component/cli/connector/deployment/CliConnectorDisabledTest.java b/extensions-jvm/cli-connector/deployment/src/test/java/org/apache/camel/quarkus/component/cli/connector/deployment/CliConnectorDisabledTest.java
new file mode 100644
index 0000000..408882b
--- /dev/null
+++ b/extensions-jvm/cli-connector/deployment/src/test/java/org/apache/camel/quarkus/component/cli/connector/deployment/CliConnectorDisabledTest.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.cli.connector.deployment;
+
+import io.quarkus.test.QuarkusUnitTest;
+import jakarta.inject.Inject;
+import org.apache.camel.CamelContext;
+import org.apache.camel.spi.CliConnectorFactory;
+import org.apache.camel.support.CamelContextHelper;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+public class CliConnectorDisabledTest {
+    @RegisterExtension
+    static final QuarkusUnitTest CONFIG = new QuarkusUnitTest()
+            .overrideConfigKey("quarkus.camel.cli.enabled", "false")
+            .withEmptyApplication();
+
+    @Inject
+    CamelContext context;
+
+    @Test
+    void cliConnectorDisabled() {
+        CliConnectorFactory factory = CamelContextHelper.findSingleByType(context, CliConnectorFactory.class);
+        assertNull(factory);
+    }
+}
diff --git a/extensions-jvm/cli-connector/deployment/src/test/java/org/apache/camel/quarkus/component/cli/connector/deployment/CliConnectorEnabledTest.java b/extensions-jvm/cli-connector/deployment/src/test/java/org/apache/camel/quarkus/component/cli/connector/deployment/CliConnectorEnabledTest.java
new file mode 100644
index 0000000..3760435
--- /dev/null
+++ b/extensions-jvm/cli-connector/deployment/src/test/java/org/apache/camel/quarkus/component/cli/connector/deployment/CliConnectorEnabledTest.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.cli.connector.deployment;
+
+import io.quarkus.test.QuarkusUnitTest;
+import jakarta.inject.Inject;
+import org.apache.camel.CamelContext;
+import org.apache.camel.quarkus.component.cli.connector.QuarkusCliConnectorFactory;
+import org.apache.camel.spi.CliConnectorFactory;
+import org.apache.camel.support.CamelContextHelper;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class CliConnectorEnabledTest {
+    @RegisterExtension
+    static final QuarkusUnitTest CONFIG = new QuarkusUnitTest().withEmptyApplication();
+
+    @Inject
+    CamelContext context;
+
+    @Test
+    void cliConnectorEnabled() {
+        CliConnectorFactory factory = CamelContextHelper.findSingleByType(context, CliConnectorFactory.class);
+        assertNotNull(factory);
+        assertInstanceOf(QuarkusCliConnectorFactory.class, factory);
+    }
+}
diff --git a/extensions-jvm/cli-connector/runtime/src/main/java/org/apache/camel/quarkus/component/cli/connector/CamelCliConnectorConfig.java b/extensions-jvm/cli-connector/runtime/src/main/java/org/apache/camel/quarkus/component/cli/connector/CamelCliConnectorConfig.java
new file mode 100644
index 0000000..78ca502
--- /dev/null
+++ b/extensions-jvm/cli-connector/runtime/src/main/java/org/apache/camel/quarkus/component/cli/connector/CamelCliConnectorConfig.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.cli.connector;
+
+import io.quarkus.runtime.annotations.ConfigItem;
+import io.quarkus.runtime.annotations.ConfigPhase;
+import io.quarkus.runtime.annotations.ConfigRoot;
+
+@ConfigRoot(name = "camel.cli", phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED)
+public class CamelCliConnectorConfig {
+    /**
+     * Sets whether to enable Camel CLI Connector support.
+     */
+    @ConfigItem(defaultValue = "true")
+    public boolean enabled;
+}
diff --git a/extensions-jvm/cli-connector/runtime/src/main/java/org/apache/camel/quarkus/component/cli/connector/CamelCliConnectorRecorder.java b/extensions-jvm/cli-connector/runtime/src/main/java/org/apache/camel/quarkus/component/cli/connector/CamelCliConnectorRecorder.java
new file mode 100644
index 0000000..3e3225e
--- /dev/null
+++ b/extensions-jvm/cli-connector/runtime/src/main/java/org/apache/camel/quarkus/component/cli/connector/CamelCliConnectorRecorder.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.cli.connector;
+
+import io.quarkus.runtime.RuntimeValue;
+import io.quarkus.runtime.annotations.Recorder;
+import org.apache.camel.spi.CliConnectorFactory;
+
+@Recorder
+public class CamelCliConnectorRecorder {
+    public RuntimeValue<CliConnectorFactory> createCliConnectorFactory(String version) {
+        QuarkusCliConnectorFactory factory = new QuarkusCliConnectorFactory();
+        factory.setEnabled(true);
+        factory.setRuntime("Quarkus");
+        factory.setRuntimeVersion(version);
+        return new RuntimeValue<>(factory);
+    }
+}
diff --git a/extensions-jvm/cli-connector/runtime/src/main/java/org/apache/camel/quarkus/component/cli/connector/QuarkusCliConnectorFactory.java b/extensions-jvm/cli-connector/runtime/src/main/java/org/apache/camel/quarkus/component/cli/connector/QuarkusCliConnectorFactory.java
new file mode 100644
index 0000000..90aa448
--- /dev/null
+++ b/extensions-jvm/cli-connector/runtime/src/main/java/org/apache/camel/quarkus/component/cli/connector/QuarkusCliConnectorFactory.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.cli.connector;
+
+import org.apache.camel.cli.connector.DefaultCliConnectorFactory;
+import org.apache.camel.spi.CliConnector;
+
+public class QuarkusCliConnectorFactory extends DefaultCliConnectorFactory {
+    @Override
+    public CliConnector createConnector() {
+        return new QuarkusLocalCliConnector(this);
+    }
+}
diff --git a/extensions-jvm/cli-connector/runtime/src/main/java/org/apache/camel/quarkus/component/cli/connector/QuarkusLocalCliConnector.java b/extensions-jvm/cli-connector/runtime/src/main/java/org/apache/camel/quarkus/component/cli/connector/QuarkusLocalCliConnector.java
new file mode 100644
index 0000000..e671407
--- /dev/null
+++ b/extensions-jvm/cli-connector/runtime/src/main/java/org/apache/camel/quarkus/component/cli/connector/QuarkusLocalCliConnector.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.cli.connector;
+
+import io.quarkus.runtime.LaunchMode;
+import org.apache.camel.cli.connector.LocalCliConnector;
+import org.apache.camel.spi.CliConnectorFactory;
+
+public class QuarkusLocalCliConnector extends LocalCliConnector {
+    public QuarkusLocalCliConnector(CliConnectorFactory cliConnectorFactory) {
+        super(cliConnectorFactory);
+    }
+
+    @Override
+    public void sigterm() {
+        if (LaunchMode.current().equals(LaunchMode.DEVELOPMENT)) {
+            // If Camel JBang launched us in dev mode, then stopping the CamelContext is not enough as dev mode will remain running.
+            // Therefore, init app shutdown which will still shut Camel down gracefully
+            System.exit(0);
+        } else {
+            super.sigterm();
+        }
+    }
+}