简体   繁体   中英

How to add 3rd party libraries into Eclipse RCP?

I'm using Eclipse RCP to write a GUI which would use Spring framework related projects, such as:

  • Spring WebSocket client
  • Spring Web Client

So my question is how to add this dependencies elegantly ? (Spring does not support osgi for a long time, there are many other ways which are very complicated and tedious)

I've found a good Solution to solve this problem. It will use following skills: Maven , Eclipse Plugin

The steps are:

  • first, write the pom.xml which contains the dependencies you want, for example: spring-websocket

     <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-websocket</artifactId> </dependency> 
  • then, you need to download all websocket jars, you need to use maven command to help you to do that :), the jars are all in /target folder by default

    mvn dependency:copy-dependencies

    Note: maven will handle the dependency tree.

  • next, in Eclipse create a "Plug-in from Existing JAR Archives" project and import these jars

    Note: Un-check the "Upzip the JAR archives into the project". (Or all jars will be decompressed into folder and files then stored in the project)

  • finally, add this plugin project in your main RCP project as a dependency . And you can write/run your websocket client now!

Hope this is an elegant way to solve this problem.

There are different ways to convert maven artifacts to OSGi bundles:

  1. Eclipse Bundle Recipes
  2. p2-maven-plugin in combination with a Tycho and a Nexus repository you have a elegant tooling to add thirdparty dependencies to your Eclipse-RCP project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM