在常规 Maven 构建中使用 Eclipse p2 存储库中的依赖项?
我想在“常规”Maven 3 构建(例如 JAR 或 WAR 打包)中使用来自远程 Eclipse p2 存储库的依赖项 - 所有这些都无需将 p2 存储库转换为本地 Maven 存储库(这就是 osgi-to-maven2 和m4e 似乎可以)。
理想情况下,我只使用 http://maven.eclipse.org/nexus/,但这还没有( ?)包含许多捆绑包。
使用Maven的systemPath不算!
I'd like to use dependencies from a remote Eclipse p2 repository in a "regular" Maven 3 build (e.g. JAR or WAR packaging) - all without converting the p2 repo to a local Maven repo (which is what osgi-to-maven2 and m4e seem to do).
Ideally, I'd just use http://maven.eclipse.org/nexus/, but that doesn't (yet?) contain many bundles.
Using Maven's systemPath doesn't count!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来我正在回答我自己的另一个问题..
首先,您可以使用 Tycho 添加对 P2 存储库中的捆绑包的依赖项:
让我们尝试一下:
我们的依赖关系已成功从 P2 存储库中解决。不幸的是,我们还没有完成。依赖项已添加到系统范围内,这意味着如果我们创建依赖于我们的构建的 Web 应用程序,则不会包含工件。为了解决这个问题,我们首先将依赖项中包含的所有类解压到某个目录,然后将该目录重新打包为 jar 并将其用作构建的最终工件。
对于第一部分(解包),我们将 maven-dependency-plugin 添加到我们的构建中,并将其配置为在打包阶段运行其 unpack-dependency 目标。对于第二部分(重新打包),我们将 maven-assemble-plugin 添加到我们的构建中,并将其配置为在打包阶段运行其单一目标。我们还需要创建和配置自定义程序集描述符。
我们的构建现在由 3 个文件组成: pom.xml 中的构建文件:
META-INF/MANIFEST.MF 中的清单:
src/main/ assembly/repackaged.xml 中的程序集描述符:
现在 mvn package 将创建一个 jar 文件包含 P2 依赖项中的所有代码,重新打包为适当的 Maven 工件,准备在另一个项目中用作依赖项。
Looks like I'm answering another of my own questions..
First of all, you can use Tycho to add a dependency on a bundle from a P2 repository:
Let's give that a try:
Our dependency has sucessfully been resolved from the P2 repository. Unfortunately, we're not done yet. The dependency has been added with system scope, which means that the artifacts won't be included if we create a webapp that depends on our build. To work around that, we'll first unpack all classes contained in the dependency to some directory, and then re-package that directory as a jar and use it as the final artifact of our build.
For the first part (unpacking), we add the maven-dependency-plugin to our build and configure it to run its unpack-dependencies goal during the package phase. For the second part (re-packaging), we add the maven-assembly-plugin to our build and configure it to run its single goal during the package phase. We also need to create and configure a custom assembly descriptor.
Our build now consists of 3 files: The build file in pom.xml:
The manifest in META-INF/MANIFEST.MF:
The assembly descriptor in src/main/assembly/repackaged.xml:
Now mvn package will create a jar file that contains all the code from our P2 dependency, re-packaged as a proper Maven artifact, ready to be used as a dependency in another project.
另一种方法是使用 b3 聚合器以符合 Maven 的布局镜像 p2 存储库,如下所述:
使用 maven : b3 使用 p2 中的 emf 包
然后就可以使用提供的原始 jar 了。
Another way is to use b3 aggregator to mirror the p2 repo in a maven compliant layout as described here:
Consuming emf bundles from p2 with maven : b3
then one can use the original jars as provided.