I've created a boiler-plate project following vogella's extensive Tycho tutorial.
我在vogella广泛的第谷教程之后创建了一个样板工程。
Facts:
事实:
- There's no feature, and there's no plugin. The only plugin is the RCP app, which is also the entry-point.
- 没有特性,也没有插件。唯一的插件是RCP应用程序,也是入口点。
Problem:
问题:
-
I have no idea in which
pom.xml
do I include the 3rd party dependencies.我不知道在哪里。xml是否包含第三方依赖项。
-
I cannot include them in the RCP project, because the packaging of that pom is
eclipse-plugin
, and notjar
. From what I've noticed, if I change the packaging tojar
, then the "Maven Dependencies" library is added automatically. If I change back toeclipse-plugin
, they get removed.我不能将它们包含在RCP项目中,因为pom的封装是eclipse-plugin,而不是jar。我注意到,如果我将包更改为jar,那么将自动添加“Maven依赖项”库。如果我改回eclipse-plugin,它们就被删除了。
Questions:
问题:
- Where do I add the dependencies? There's no pom with
jar
packaging in my project. - 我在哪里添加依赖项?在我的项目中没有带jar包装的pom。
- Should I create a separate project with the necessary JARs? How do I include that dependency to my entire project?
- 我应该用必要的jar创建一个单独的项目吗?我如何将这个依赖关系包含到整个项目中?
- Is it really that much of a good practice to create a separate plugin and a feature for this RCP app?
- 为RCP应用程序创建一个独立的插件和特性真的是一个很好的实践吗?
Related solutions:
相关的解决方案:
- "Update projects" doesn't work, and neither do the n other solutions in the other SO questions.
- “更新项目”不起作用,其他n个解决方案也不起作用。
- There's also this question and that question, but I don't fully get the answers
- 还有这个问题和那个问题,但我没有完全得到答案
1 个解决方案
#1
15
I think that you have a fundamental misunderstanding.
我认为你有一个根本性的误解。
Maven: Maven determines all of the project dependencies via the pom.xml and resolves transitive dependencies automatically (assuming that all of the pom files and artifacts exist in repositories that you've configured and correctly declare their dependencies).
Maven: Maven通过pom确定所有的项目依赖项。xml并自动解析传递依赖项(假设所有pom文件和工件都存在于您配置并正确声明它们的依赖项的存储库中)。
Tycho: The problem is that Eclipse already has its own project model based on product files, feature.xml files, and plug-in MANIFEST.MF files. Tycho leverages the Maven machinery for Eclipse, but the idea is that the pom.xml files just configure the Maven plug-ins and declare the packaging type. That provides an entry point for Maven, but then Tycho takes over. While Maven would normally build the dependency chain from information in the pom.xml files, Tycho is building the dependency change from information in the product, feature, and MANIFEST.MF files. You don't put any dependencies in the pom.xml files. Tycho also uses Eclipse p2 repositories (instead of normal Maven repositories) for finding dependent plug-ins that are not found in the local modules or target platform.
问题是Eclipse已经有了基于产品文件和特性的项目模型。xml文件和插件清单。MF文件。Tycho利用了Eclipse的Maven机制,但其思想是pom。xml文件只是配置Maven插件并声明打包类型。这为Maven提供了一个入口点,但是Tycho接管了它。而Maven通常会从pom中的信息构建依赖链。通过xml文件,Tycho正在构建产品、特性和清单中的信息的依赖关系变更。MF文件。你没有在pom中放入任何依赖项。xml文件。Tycho还使用Eclipse p2储存库(而不是普通的Maven储存库)查找本地模块或目标平台中没有的依赖插件。
That's actually a benefit for many Eclipse developers since they've already set up everything properly in their Eclipse plug-ins, features, and products. They do not want to have to repeat all of the dependencies in the pom.xml.
这实际上对许多Eclipse开发人员是一个好处,因为他们已经在Eclipse插件、特性和产品中正确地设置了所有内容。他们不希望重复使用pom.xml中的所有依赖项。
Using Libraries in Eclipse plug-ins: In Eclipse, if you want to use a library that is not already packaged as an Eclipse plug-in, you have a few options. Your plug-in can include a set of JARs in a libs folder and then include that libs folder in the plug-in and runtime classpath (see the build.properties file). Another option is to create your own "library plug-in" that repackages a JAR library as an Eclipse plug-in. See also https://wiki.eclipse.org/FAQ_What_is_the_classpath_of_a_plug-in%3F. That's the answer that you're getting above.
在Eclipse插件中使用库:在Eclipse中,如果您想使用尚未打包为Eclipse插件的库,您可以使用一些选项。您的插件可以在libs文件夹中包含一组jar,然后在插件和运行时类路径中包含那个libs文件夹(参见构建)。属性文件)。另一个选项是创建您自己的“库插件”,该插件将JAR库重新打包为Eclipse插件。参见https://wiki.eclipse.org/FAQ_What_is_the_classpath_of_a_plug-in%3F。这就是你得到的答案。
The problem is that if you're trying to include a complex library with multiple JARs that is normally distributed and included in a standard Java project via Maven. We hit this problem with the Jersey JAX-RS implementation in my project. There's no p2 repository that includes all of the pieces of the libraries as plug-ins with correct dependency information.
问题是,如果您试图包含一个包含多个jar的复杂库,这些jar通常分布,并通过Maven包含在标准Java项目中。我们在项目中的Jersey JAX-RS实现中遇到了这个问题。没有p2存储库将库的所有部分作为具有正确依赖信息的插件来包含。
Easy Solution: If you need a common library, check the Orbit project first to see whether the libraries have already been packaged as Eclipse plug-ins, http://www.eclipse.org/orbit/. In that case, you can download them and include them in your target platform, or you can pull them in dynamically at (Tycho) build time from their p2 repository. Your plug-ins would just include those plug-ins as dependencies (in the their MANIFEST.MF files).
简单的解决方案:如果需要公共库,请首先检查Orbit项目,看看这些库是否已经打包为Eclipse插件,http://www.eclipse.org/orbit/。在这种情况下,您可以下载它们并将它们包含到目标平台中,或者您可以在(Tycho)构建时从它们的p2存储库中动态地提取它们。您的插件将仅仅包含这些插件作为依赖项(在它们的清单中)。MF文件)。
Workaround / Solution: In our case, Jersey JAX-RS was not available as an Eclipse plug-in, and it had a bunch of transitive dependencies. The workaround was to create an Eclipse "library plug-in" like I mentioned above with two pom files. We initially created a skeleton plug-in with an empty libs folder. One pom file is just a standard Maven pom file with <packaging>jar</packaging>
that declares the top-level dependencies required to pull in the Jersey JAX-RS implementation and all of its dependencies. The dependencies are declared with <scope>compile</scope>
. We use the maven-dependency-plugin to copy all of those dependencies into the project's libs folder.
解决方案/解决方案:在我们的示例中,Jersey JAX-RS作为Eclipse插件不可用,并且它有很多传递性依赖项。解决方案是使用两个pom文件创建Eclipse“库插件”,如我上面提到的那样。我们最初创建了一个包含空libs文件夹的框架插件。一个pom文件只是一个标准的Maven pom文件,其
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>compile</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>libs</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
We actually ended up running Maven with that pom by hand from time to time to update the libs, and then we just checked the plug-in with all of its dependent JARs into source control.
Checking the build later, I see that we actually populate the libs folder on-the-fly with Maven with a separate build task just before we start the Maven/Tycho part of the build. Of course, plug-in's MANIFEST-MF file's Bundle-ClassPath and Export-Package entries are coming straight from source control. We have to check those from time to time to ensure that they match the libraries and packages that we're getting from Maven. (That doesn't tend to change much unless we bump major library versions or add a new dependency at the Maven level.) The plug-in's build.properties has the libs/ folder as part of bin.includes.
实际上,我们最终使用pom手工运行Maven来更新libs,然后我们将插件的所有相关jar签入到源代码控制中。稍后检查构建,我发现我们实际上是在Maven/Tycho部分构建之前,在Maven与Maven之间进行一个单独的构建任务。当然,插件的MANIFEST-MF文件的绑定- classpath和导出- package条目直接来自源代码控制。我们必须不时地检查它们,以确保它们与Maven获得的库和包匹配。(除非我们修改主要的库版本,或者在Maven级别添加新的依赖项,否则不会有太大的变化。)插件的构建。属性将libs/文件夹作为bin.include的一部分。
In the development environment, after we first check out the code, we just run mvn (with an External Tools launch config that's also checked in with the project) on the project's "copy dependencies" pom file. That populates the libs folder with all of the JAX-RS libraries and dependencies. We only have to run it again when we update something about the dependencies or when we're jumping between branches that have different versions of the JAX-RS dependencies. We set .gitignore to ensure that we don't commit the libs to Git.
在开发环境中,在我们第一次检查代码之后,我们只运行mvn(带有一个外部工具启动配置,它也在项目中进行了检入)在项目的“copy dependencies”pom文件中。将所有JAX-RS库和依赖项填充到libs文件夹中。当我们更新有关依赖项的内容或在具有不同版本的JAX-RS依赖项的分支之间跳转时,我们只需再次运行它。我们设置了.gitignore以确保不会将libs提交给Git。
The other pom for this project is set up like a normal Tycho pom file with <packaging>eclipse-plugin</packaging>
. During our automated build, we run one step early in the build process (just after check out) that calls mvn with the jar pom to populate the libs. Then we proceed with the main Maven/Tycho build using the eclipse-plugin pom. The eclipse-plugin pom has no dependency information (as I said above). It's just providing Tycho a way to recognize the Eclipse plug-in and build it based on its MANIFEST.MF and build.properties files. But the built plug-in includes and exposes all of those libs that were populated by the mvn call to the jar pom step.
这个项目的另一个pom就像一个正常的Tycho pom文件,带有 <封装> eclipse-plugin。在我们的自动构建过程中,我们在构建过程的早期(即检出之后)运行了一个步骤,该过程使用jar pom调用mvn来填充libs。然后我们继续使用eclipse插件pom构建Maven/Tycho。eclipse插件pom没有依赖信息(如前所述)。它只是为Tycho提供了一种识别Eclipse插件并基于其清单构建它的方法。MF和构建。属性文件。但是构建的插件包含并公开了mvn对jar pom步骤的调用所填充的所有lib。
So, it's a bit of a mess, but that's the best solution we found a couple of years ago when we hit this problem. I'm not sure whether Tycho is doing any work to permit some sort of hybrid Maven/Tycho build that could do this automatically as part of the build. I guess I should ask the developers. :)
这有点乱,但这是我们几年前遇到这个问题时找到的最好的解决办法。我不确定Tycho是否在做任何工作来允许某种混合的Maven/Tycho构建,它可以作为构建的一部分自动完成这些工作。我想我应该问问开发人员。:)
Your questions:
你的问题:
- Where do I add the dependencies? There's no pom with jar packaging in my project. Answer: The workaround above lets you do it with one project. You just have two pom files, like pom_deps.xml and pom.xml. You just have to invoke the pom_deps.xml separately to populate the libs folder (in the dev environment and with your automated builds).
- 我在哪里添加依赖项?在我的项目中没有带jar包装的pom。答:上面的解决方案允许您使用一个项目。你只有两个pom文件,像pom_deps。xml和pom.xml。只需调用pom_deps。分别使用xml填充libs文件夹(在开发环境中,并使用自动构建)。
-
Should I create a separate project with the necessary JARs? How do I include that dependency to my entire project? Answer: the workaround that I described above lets you do it with a single project. Another way to do it is to create a separate JAR project, but I don't think that your Eclipse RCP app can really include a
<packaging>jar</packaging>
module in a useful way. The only way I've found to do it is to use a similar workaround. You build the JAR module first, install it into the maven repository, and then have one of your plug-in projects bundle the JAR in its libs folder. (If you really want to do it that way, ask. We have a case where we have to do that, too, and I can provide the steps we do in development and the build to make it work. I think the single project workaround that I provided above makes more sense for your case.) -
我应该用必要的jar创建一个单独的项目吗?如何将这种依赖关系包含到整个项目中?答:我上面描述的解决方案允许您使用单个项目。另一种方法是创建一个单独的JAR项目,但是我不认为您的Eclipse RCP应用程序能够以一种有用的方式包含
JAR module。我找到的唯一方法就是使用类似的方法。首先构建JAR模块,将其安装到maven存储库中,然后让您的一个插件项目将JAR打包到它的libs文件夹中。(如果你真的想这么做,那就去问。我们也有这样的情况,我可以提供我们在开发和构建中所做的步骤,以使其工作。我认为我上面提供的单一项目解决方案对您的情况更有意义。 - Is it really that much of a good practice to create a separate plugin and a feature for this RCP app? Answer: that's really a separate question. If you have a feature with multiple plug-ins, you have the same problem. Tycho can handle the product/feature/plug-ins, but it cannot jump across into Maven-based dependency resolution. You'll end up having to use the same workarounds
- 为RCP应用程序创建一个独立的插件和特性真的是一个很好的实践吗?回答:这是一个独立的问题。如果您有一个具有多个插件的特性,那么您将遇到相同的问题。Tycho可以处理产品/特性/插件,但它不能跨越到基于maven的依赖项解决方案。你将不得不使用相同的方法
Summary: The fundamental issue is that Eclipse plug-ins can't "see" a bare JAR library. The plug-in needs to have the library included in its local libs folder (with a matching Bundle-ClassPath entry in MANIFEST.MF), or it needs to depend on some other plug-in that exports the appropriate packages. Tycho just resolves dependencies via Eclipse plug-ins, and it cannot leverage normal Maven dependency resolution directly to pull in a bunch of JARs. If all of your dependencies are already plug-ins, you're fine. If not, you may have to use the workaround above to package a set of libraries for your plug-ins to use.
概要:基本的问题是Eclipse插件不能“看到”裸JAR库。插件需要将库包含在它的本地libs文件夹中(在MANIFEST.MF中有一个匹配的Bundle-ClassPath条目),或者它需要依赖于其他导出适当包的插件。Tycho只是通过Eclipse插件来解析依赖项,它不能直接利用普通的Maven依赖项解析来提取一堆jar。如果您的所有依赖项都已经是插件,那就没问题了。如果不是,您可能需要使用上面的解决方案来为插件打包一组库。
#1
15
I think that you have a fundamental misunderstanding.
我认为你有一个根本性的误解。
Maven: Maven determines all of the project dependencies via the pom.xml and resolves transitive dependencies automatically (assuming that all of the pom files and artifacts exist in repositories that you've configured and correctly declare their dependencies).
Maven: Maven通过pom确定所有的项目依赖项。xml并自动解析传递依赖项(假设所有pom文件和工件都存在于您配置并正确声明它们的依赖项的存储库中)。
Tycho: The problem is that Eclipse already has its own project model based on product files, feature.xml files, and plug-in MANIFEST.MF files. Tycho leverages the Maven machinery for Eclipse, but the idea is that the pom.xml files just configure the Maven plug-ins and declare the packaging type. That provides an entry point for Maven, but then Tycho takes over. While Maven would normally build the dependency chain from information in the pom.xml files, Tycho is building the dependency change from information in the product, feature, and MANIFEST.MF files. You don't put any dependencies in the pom.xml files. Tycho also uses Eclipse p2 repositories (instead of normal Maven repositories) for finding dependent plug-ins that are not found in the local modules or target platform.
问题是Eclipse已经有了基于产品文件和特性的项目模型。xml文件和插件清单。MF文件。Tycho利用了Eclipse的Maven机制,但其思想是pom。xml文件只是配置Maven插件并声明打包类型。这为Maven提供了一个入口点,但是Tycho接管了它。而Maven通常会从pom中的信息构建依赖链。通过xml文件,Tycho正在构建产品、特性和清单中的信息的依赖关系变更。MF文件。你没有在pom中放入任何依赖项。xml文件。Tycho还使用Eclipse p2储存库(而不是普通的Maven储存库)查找本地模块或目标平台中没有的依赖插件。
That's actually a benefit for many Eclipse developers since they've already set up everything properly in their Eclipse plug-ins, features, and products. They do not want to have to repeat all of the dependencies in the pom.xml.
这实际上对许多Eclipse开发人员是一个好处,因为他们已经在Eclipse插件、特性和产品中正确地设置了所有内容。他们不希望重复使用pom.xml中的所有依赖项。
Using Libraries in Eclipse plug-ins: In Eclipse, if you want to use a library that is not already packaged as an Eclipse plug-in, you have a few options. Your plug-in can include a set of JARs in a libs folder and then include that libs folder in the plug-in and runtime classpath (see the build.properties file). Another option is to create your own "library plug-in" that repackages a JAR library as an Eclipse plug-in. See also https://wiki.eclipse.org/FAQ_What_is_the_classpath_of_a_plug-in%3F. That's the answer that you're getting above.
在Eclipse插件中使用库:在Eclipse中,如果您想使用尚未打包为Eclipse插件的库,您可以使用一些选项。您的插件可以在libs文件夹中包含一组jar,然后在插件和运行时类路径中包含那个libs文件夹(参见构建)。属性文件)。另一个选项是创建您自己的“库插件”,该插件将JAR库重新打包为Eclipse插件。参见https://wiki.eclipse.org/FAQ_What_is_the_classpath_of_a_plug-in%3F。这就是你得到的答案。
The problem is that if you're trying to include a complex library with multiple JARs that is normally distributed and included in a standard Java project via Maven. We hit this problem with the Jersey JAX-RS implementation in my project. There's no p2 repository that includes all of the pieces of the libraries as plug-ins with correct dependency information.
问题是,如果您试图包含一个包含多个jar的复杂库,这些jar通常分布,并通过Maven包含在标准Java项目中。我们在项目中的Jersey JAX-RS实现中遇到了这个问题。没有p2存储库将库的所有部分作为具有正确依赖信息的插件来包含。
Easy Solution: If you need a common library, check the Orbit project first to see whether the libraries have already been packaged as Eclipse plug-ins, http://www.eclipse.org/orbit/. In that case, you can download them and include them in your target platform, or you can pull them in dynamically at (Tycho) build time from their p2 repository. Your plug-ins would just include those plug-ins as dependencies (in the their MANIFEST.MF files).
简单的解决方案:如果需要公共库,请首先检查Orbit项目,看看这些库是否已经打包为Eclipse插件,http://www.eclipse.org/orbit/。在这种情况下,您可以下载它们并将它们包含到目标平台中,或者您可以在(Tycho)构建时从它们的p2存储库中动态地提取它们。您的插件将仅仅包含这些插件作为依赖项(在它们的清单中)。MF文件)。
Workaround / Solution: In our case, Jersey JAX-RS was not available as an Eclipse plug-in, and it had a bunch of transitive dependencies. The workaround was to create an Eclipse "library plug-in" like I mentioned above with two pom files. We initially created a skeleton plug-in with an empty libs folder. One pom file is just a standard Maven pom file with <packaging>jar</packaging>
that declares the top-level dependencies required to pull in the Jersey JAX-RS implementation and all of its dependencies. The dependencies are declared with <scope>compile</scope>
. We use the maven-dependency-plugin to copy all of those dependencies into the project's libs folder.
解决方案/解决方案:在我们的示例中,Jersey JAX-RS作为Eclipse插件不可用,并且它有很多传递性依赖项。解决方案是使用两个pom文件创建Eclipse“库插件”,如我上面提到的那样。我们最初创建了一个包含空libs文件夹的框架插件。一个pom文件只是一个标准的Maven pom文件,其
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>compile</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>libs</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
We actually ended up running Maven with that pom by hand from time to time to update the libs, and then we just checked the plug-in with all of its dependent JARs into source control.
Checking the build later, I see that we actually populate the libs folder on-the-fly with Maven with a separate build task just before we start the Maven/Tycho part of the build. Of course, plug-in's MANIFEST-MF file's Bundle-ClassPath and Export-Package entries are coming straight from source control. We have to check those from time to time to ensure that they match the libraries and packages that we're getting from Maven. (That doesn't tend to change much unless we bump major library versions or add a new dependency at the Maven level.) The plug-in's build.properties has the libs/ folder as part of bin.includes.
实际上,我们最终使用pom手工运行Maven来更新libs,然后我们将插件的所有相关jar签入到源代码控制中。稍后检查构建,我发现我们实际上是在Maven/Tycho部分构建之前,在Maven与Maven之间进行一个单独的构建任务。当然,插件的MANIFEST-MF文件的绑定- classpath和导出- package条目直接来自源代码控制。我们必须不时地检查它们,以确保它们与Maven获得的库和包匹配。(除非我们修改主要的库版本,或者在Maven级别添加新的依赖项,否则不会有太大的变化。)插件的构建。属性将libs/文件夹作为bin.include的一部分。
In the development environment, after we first check out the code, we just run mvn (with an External Tools launch config that's also checked in with the project) on the project's "copy dependencies" pom file. That populates the libs folder with all of the JAX-RS libraries and dependencies. We only have to run it again when we update something about the dependencies or when we're jumping between branches that have different versions of the JAX-RS dependencies. We set .gitignore to ensure that we don't commit the libs to Git.
在开发环境中,在我们第一次检查代码之后,我们只运行mvn(带有一个外部工具启动配置,它也在项目中进行了检入)在项目的“copy dependencies”pom文件中。将所有JAX-RS库和依赖项填充到libs文件夹中。当我们更新有关依赖项的内容或在具有不同版本的JAX-RS依赖项的分支之间跳转时,我们只需再次运行它。我们设置了.gitignore以确保不会将libs提交给Git。
The other pom for this project is set up like a normal Tycho pom file with <packaging>eclipse-plugin</packaging>
. During our automated build, we run one step early in the build process (just after check out) that calls mvn with the jar pom to populate the libs. Then we proceed with the main Maven/Tycho build using the eclipse-plugin pom. The eclipse-plugin pom has no dependency information (as I said above). It's just providing Tycho a way to recognize the Eclipse plug-in and build it based on its MANIFEST.MF and build.properties files. But the built plug-in includes and exposes all of those libs that were populated by the mvn call to the jar pom step.
这个项目的另一个pom就像一个正常的Tycho pom文件,带有 <封装> eclipse-plugin。在我们的自动构建过程中,我们在构建过程的早期(即检出之后)运行了一个步骤,该过程使用jar pom调用mvn来填充libs。然后我们继续使用eclipse插件pom构建Maven/Tycho。eclipse插件pom没有依赖信息(如前所述)。它只是为Tycho提供了一种识别Eclipse插件并基于其清单构建它的方法。MF和构建。属性文件。但是构建的插件包含并公开了mvn对jar pom步骤的调用所填充的所有lib。
So, it's a bit of a mess, but that's the best solution we found a couple of years ago when we hit this problem. I'm not sure whether Tycho is doing any work to permit some sort of hybrid Maven/Tycho build that could do this automatically as part of the build. I guess I should ask the developers. :)
这有点乱,但这是我们几年前遇到这个问题时找到的最好的解决办法。我不确定Tycho是否在做任何工作来允许某种混合的Maven/Tycho构建,它可以作为构建的一部分自动完成这些工作。我想我应该问问开发人员。:)
Your questions:
你的问题:
- Where do I add the dependencies? There's no pom with jar packaging in my project. Answer: The workaround above lets you do it with one project. You just have two pom files, like pom_deps.xml and pom.xml. You just have to invoke the pom_deps.xml separately to populate the libs folder (in the dev environment and with your automated builds).
- 我在哪里添加依赖项?在我的项目中没有带jar包装的pom。答:上面的解决方案允许您使用一个项目。你只有两个pom文件,像pom_deps。xml和pom.xml。只需调用pom_deps。分别使用xml填充libs文件夹(在开发环境中,并使用自动构建)。
-
Should I create a separate project with the necessary JARs? How do I include that dependency to my entire project? Answer: the workaround that I described above lets you do it with a single project. Another way to do it is to create a separate JAR project, but I don't think that your Eclipse RCP app can really include a
<packaging>jar</packaging>
module in a useful way. The only way I've found to do it is to use a similar workaround. You build the JAR module first, install it into the maven repository, and then have one of your plug-in projects bundle the JAR in its libs folder. (If you really want to do it that way, ask. We have a case where we have to do that, too, and I can provide the steps we do in development and the build to make it work. I think the single project workaround that I provided above makes more sense for your case.) -
我应该用必要的jar创建一个单独的项目吗?如何将这种依赖关系包含到整个项目中?答:我上面描述的解决方案允许您使用单个项目。另一种方法是创建一个单独的JAR项目,但是我不认为您的Eclipse RCP应用程序能够以一种有用的方式包含
JAR module。我找到的唯一方法就是使用类似的方法。首先构建JAR模块,将其安装到maven存储库中,然后让您的一个插件项目将JAR打包到它的libs文件夹中。(如果你真的想这么做,那就去问。我们也有这样的情况,我可以提供我们在开发和构建中所做的步骤,以使其工作。我认为我上面提供的单一项目解决方案对您的情况更有意义。 - Is it really that much of a good practice to create a separate plugin and a feature for this RCP app? Answer: that's really a separate question. If you have a feature with multiple plug-ins, you have the same problem. Tycho can handle the product/feature/plug-ins, but it cannot jump across into Maven-based dependency resolution. You'll end up having to use the same workarounds
- 为RCP应用程序创建一个独立的插件和特性真的是一个很好的实践吗?回答:这是一个独立的问题。如果您有一个具有多个插件的特性,那么您将遇到相同的问题。Tycho可以处理产品/特性/插件,但它不能跨越到基于maven的依赖项解决方案。你将不得不使用相同的方法
Summary: The fundamental issue is that Eclipse plug-ins can't "see" a bare JAR library. The plug-in needs to have the library included in its local libs folder (with a matching Bundle-ClassPath entry in MANIFEST.MF), or it needs to depend on some other plug-in that exports the appropriate packages. Tycho just resolves dependencies via Eclipse plug-ins, and it cannot leverage normal Maven dependency resolution directly to pull in a bunch of JARs. If all of your dependencies are already plug-ins, you're fine. If not, you may have to use the workaround above to package a set of libraries for your plug-ins to use.
概要:基本的问题是Eclipse插件不能“看到”裸JAR库。插件需要将库包含在它的本地libs文件夹中(在MANIFEST.MF中有一个匹配的Bundle-ClassPath条目),或者它需要依赖于其他导出适当包的插件。Tycho只是通过Eclipse插件来解析依赖项,它不能直接利用普通的Maven依赖项解析来提取一堆jar。如果您的所有依赖项都已经是插件,那就没问题了。如果不是,您可能需要使用上面的解决方案来为插件打包一组库。