Auto-discover/load RouteBuilder from Maven dependency (Jar)
- Dominant language
- Go
- Stars
- 927
- Forks
- 387
- Avg merge
- 15h 5m
- Merged PRs (30d)
- 36
Description
### Requirement
Hi,
Topic from Zulip: [#camel-k > Auto-discover/load RouteBuilder from Maven dependency (Jar)](https://camel.zulipchat.com/#narrow/channel/257299-camel-k/topic/Auto-discover.2Fload.20RouteBuilder.20from.20Maven.20dependency.20.28Jar.29/with/574670586)
I have some Java Camel routes packaged in a Maven artifact that I would like to run in my integrations.
**Specs:**
* Camel K: 2.9.0
* Repository: Nexus (private maven repo)
**Current Workaround:** To start the routes, I have to use an additional "loader" Java class to manually wire them:
```java
import org.apache.camel.builder.RouteBuilder;
import org.tnt.camel.MyRouteBuilder;
public class Loader extends RouteBuilder {
@Override
public void configure() throws Exception {
getContext().addRoutes(new MyRouteBuilder());
}
}
```
The Java route inside my Maven artifact looks like this:
```java
package org.tnt.camel;
import org.apache.camel.builder.RouteBuilder;
public class MyRouteBuilder extends RouteBuilder {
public void configure() {
from("timer:test")
.setBody().constant("Hi from jar!")
.log("${body}");
}
}
```
I run this integration using the following command:
```bash
kamel run Loader.java test.camel.yaml --name test-mvn -d mvn:org.tnt.camel:tnt-camel:1.0.0
```
**The Question:** All works good, but I was wondering if there is an alternative way to tell Camel K to **auto-discover** or scan for routes in the classpath at runtime?
I am looking for something similar to `camel.main.routes-include-pattern` so I can just point to the JAR and avoid writing the `Loader.java` wrapper class.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the Loader.java example and the `kamel run Loader.java test.camel.yaml --name test-mvn -d mvn:org.tnt.camel:tnt-camel:1.0.0` entry point, then trace how Camel K handles Maven dependencies and route discovery at runtime. Done means a RouteBuilder packaged in the supplied JAR can be discovered and run without the Loader.java wrapper, with the supported configuration or limitation documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 40/100