为什么Maven找不到osgi bundle依赖项? [英] Why can't maven find an osgi bundle dependency?

查看:403
本文介绍了为什么Maven找不到osgi bundle依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的maven项目中将OSGi捆绑软件声明为依赖项. (恰好是felix容器.)

I have declared a OSGi bundle as a dependency in my maven project. ( It just happens to be the felix container. )

<dependency>
    <groupId>org.apache.felix</groupId>
    <artifactId>org.apache.felix.framework</artifactId>
    <version>4.0.2</version>
    <type>bundle</type>
    <scope>compile</scope>
</dependency>

当我尝试构建时,它说找不到.

When I try to build, it says it can't find it.

[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

Missing:
----------
1) org.apache.felix:org.apache.felix.framework:bundle:4.0.2

  Try downloading the file manually from the project website.

但是,快速浏览一下中心就可以确定该工件确实存在.我注意到,如果将其更改为罐子"类型,它将确实为我下载该罐子( bundle ).是什么让我开始思考,为什么首先要将其称为捆绑销售商品?好吧,我这样做是因为当我使用m2e查找工件时,它称它为捆绑包".实际上,m2e生成了我上面引用的那些坐标.

But, a quick look in central verifies that this artifact is indeed there. I noticed that if I change it to a "jar" type, it will indeed download the jar ( bundle ) for me. Which got me to thinking, why did I call it a bundle in the first place? Well, I did that because when I was using m2e to lookup the artifact, it called it a "bundle"; in fact, m2e generated those coordinates that I cite above.

捆绑软件不是有效的Maven工件类型吗?如果没有,为什么m2e会这样称呼它?

Is bundle not a valid maven artifact type? If not, why does m2e call it that?

推荐答案

这不是公认的答案中提到的m2e故障.问题在于,行家不知道捆绑"的类型是什么.因此,您需要添加一个定义它的插件,即maven-bundle-plugin.请注意,您还需要将 extensions 属性设置为true.因此,POM应该具有类似

This is not a glitch in m2e as mentioned in the accepted answer. The problem is that maven doesn't know what the type "bundle" is. So you need to add a plugin that defines it, namely the maven-bundle-plugin. Notice that you also need to set the extensions property to true. So the POM should have something like

<plugin>
      <groupId>org.apache.felix</groupId>
      <artifactId>maven-bundle-plugin</artifactId>
      <version>2.4.0</version>
      <extensions>true</extensions>
</plugin>

被接受的答案的问题是,如果类型捆绑包的依赖关系是直接依赖关系,则它可以工作;由于是您的pom声明它,因此只需删除该类型即可.但是,如果您的依赖项本身具有 bundle 类型的依赖项,那么您会被搞砸,因为您的传递性依赖项之一是bundle类型,您不能只是删除其中的类型,因为您不是该所有者的所有者该工件,并且无权访问pom,而您当前的执行方式又无法理解pom.它将尝试寻找repo/your-dependency.bundle

The problem with the accepted answer is that it works if the dependency of type bundle is a direct dependency; since it is your pom that declares it, you can just remove the type. However, if your dependency itself has a dependency of type bundle then you are screwed because then one of your transitive dependencies is of type bundle and you cannot just remove the type in it since you are not the owner of that artifact and don't have access to the pom, which again your current execution doesn't understand. it will try to look for repo/your-dependency.bundle

在使用依赖插件复制依赖项时遇到了这个问题.在这种情况下,插件依赖关系必须包含在插件本身中.您只需要依赖插件来了解捆绑插件:

I ran into this problem when using the dependency plugin to copy-dependencies. In that case, the plugin dependency has to go in the plugin itself. You just need the dependency plugin to know about the bundle plugin:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <dependencies>
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>2.4.0</version>
            <type>maven-plugin</type>

        </dependency>
    </dependencies>
    <extensions>true</extensions>
</plugin>

这篇关于为什么Maven找不到osgi bundle依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆