Add a Maven dependency to a Eclipse Plugin project

2020-07-22 16:47发布

问题:

just a simple question: I need to add a Maven dependency to a Eclipse Plugin project. The project has not a POM file, so I converted it to a Maven one. Now I have plugin.xml file and pom.xml file. POM contains the dependency I need to satisfy, but it's ignored; I mean, I can't resolve an import in source code referring to that import.

Can you help me? ty

I read about Tycho plugin, but online configurations don't work.

回答1:

If I'm reading this correctly, you've just started by adding a Maven dependency to your project, but don't have the dependency available for Eclipse to validate your code against.

You will need to start a Maven build after you add a brand new dependency so that Maven can add that to your local cached repository. Once the Maven build is done, Eclipse should recognize your imports properly.



回答2:

You may want to check whether the dependency you are looking for is available in the Eclipse Orbit.

The Orbit project is basically a repository of libraries to make them available for Eclipse Plug-in Development. What is especially nice in the Orbit libraries is that they also provide the sources. Thus, it is possible to view the implementation and get proper JavaDoc and so on.

Example

One can find the com.google.gson library using the update site

https://download.eclipse.org/tools/orbit/downloads/drops/R20190602212107/repository

Thereby, the part R20190602212107 refers to the Orbit build name that you find on the downloads page of the project.