apache-cameleclipse-rcpequinoxtarget-platform

Adding Apache Camel to an Eclipse RCP application


I tried to add Apache Camel support in an Eclipse RCP application. With the new Eclipse, I can also add maven repositories in the target platform file, so that is what I did. My target platform contains:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-core</artifactId>
    <version>4.6.0</version>
    <type>jar</type>
</dependency>

I also checked the includeDependency field to include the required dependencies. All is well so far, I get all 20 or so plugins for the camel projects auto-generated. I add them in my manifest files, compile is working, everything is fine. Except when I try to start camel, I get a runtime exception saying No language for 'simple' found(something similar, I don't have the exact stackstrace now).

The problem is this one:

I can only think of 2 possible solutions for this:

  1. Include Apache Camel as a jar dependency. The problem is I don't see any downloadable jar for the core Apache Camel in Maven. I will have to clone the repositories and build my own jar.
  2. Build a Maven project that takes all Camel core dependencies and outputs a single rcp plugin containing the dependencies. For this one I don't need to clone the Camel repositories, but I'm not 100% sure I can achieve this.

For both approaches I think is quite cumbersome to add another Camel component afterwards, because it will probably involve modifying the custom project I created to include the new component(assuming core-engine needs to access it to load it into the context). Also I don't see how I can separate the Camel core from the optional components.

Any ideas to make Camel work with Eclipse RCP?

You can find my target platform here: https://github.com/grozadanut/ro.linic.ui/blob/main/target-platform/target-platform.target

And the RCP product is here: https://github.com/grozadanut/ro.linic.ui/blob/main/ro.linic.ui.product/linic.product


Solution

  • I ended up adding all Camel core jars to my ro.linic.ui.camel.core plugin. And to be able to use camel in other plugins I add this ro.linic.ui.camel.core plugin as a dependency and I exported the required packages to be able to use camel code in my other plugins.

    I did use Maven to automate downloading the jars, so I don't have to download each one individually. The pom I used:

    <project>
    <modelVersion>4.0.0</modelVersion>
    
    <parent>
        <relativePath>../pom.xml</relativePath>
        <groupId>ro.linic.tycho</groupId>
        <artifactId>releng</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </parent>
    
    <groupId>ro.linic.ui</groupId>
    <artifactId>ro.linic.ui.camel.core</artifactId>
    <version>0.0.1</version>
    <packaging>eclipse-plugin</packaging>
    
    <dependencyManagement>
        <dependencies>
            <!-- Camel BOM -->
            <dependency>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-bom</artifactId>
                <version>4.6.0</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
        </dependencies>
    </dependencyManagement>
    
    <dependencies>
    
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-core</artifactId>
        </dependency>
    
    </dependencies>
    
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/${project.build.finalName}.lib
                            </outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    

    Then I took all camel jars from the generated output folder and added them to the manifest, in the Runtime -> Classpath section.