且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么Maven找不到osgi bundle依赖项?

更新时间:2022-06-26 06:53:58

这不是公认的答案中提到的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>