Importing Maven Dependencies into KNIME Nodes

I’m working on integrating my company’s proprietary Java code into a KNIME node. The code is complex and has many dependencies that span multiple maven repositories, but the developers have simplified everything through a simple maven dependency:


Using this dependency, I can easily import everything and build a standalone executable.

The next step is to integrate this functionality into KNIME. I believe (though may be mistaken) that the KNIME SDK does not yet support maven. So these are the steps I’ve taken to get things working and avoid NoClassDefFoundError and ClassNotFoundException. Note that I’ve started with the KNIME Wizard “NumberFormatter”:

Step 1: Convert my KNIME NumberFormatter project to Maven by [Project][Configure][Convert to Maven Project]

Step 2: Edit my pom.xml to include my company’s dependency

Step 3: On the command line, run the following maven command from the directory containing the new pom.xml:

$ mvn dependency:copy-dependencies -DoutputDirectory=lib

This has the effect of copying all of the dependencies into a /lib directory that is local to my KNIME project. As the project is complex, about 50 JAR files get copied across.


Step 4: Open up plugin.xml and manually add all of the dependencies to the [Runtime][Classpath]


Step 5: Check that everything was added to the MANIFEST.MF


While I’m still just building a little proof-of-concept, these steps look like they basically work. My problem is that it all looks very brittle and un-maven-like. If I need to upgrade something then these steps could be very painful to maintain.

Could I be doing this in a better way?

Hi @Edlueze,

The forum post you linked is not quite correct, you can actually build KNIME extensions with maven and Tycho, in fact you are doing exactly that in the Scientific Strategy nodes.

To include maven dependencies, there are two better strategies, I know of, than the one you correctly identified as brittle:

1.) Add the maven dependencies to your target platform file directly, in many cases eclipse is able to generate the p2 plugins from that directly, take a look here for an example birt/ at master · eclipse/birt · GitHub. You will need to adapt your tycho build to use that target platform, as you can see in the same repository: birt/pom.xml at 7d6429dca1dfb9313e8667d939819d826d7e98bd · eclipse/birt · GitHub

2.) Converting the external dependencies to p2 plugins and creating a dedicated update site for them. Take a look into GitHub - reficio/p2-maven-plugin: Maven3 plugin that automates the third-party dependency management for Eclipse RCP. This is what we use to bundle external dependencies for use in AP development. This allows you to generate an update site that contains your maven dependencies.

In both cases, you will also need to add the created plugins to your update site, either via a feature or directly, so that users have access to them when they are installing your plugin.


1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.