Why can't maven find an osgi bundle dependency?

前端 未结 1 1855
长情又很酷
长情又很酷 2020-12-10 02:29

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


    org.         


        
1条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-10 03:16

    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

    
          org.apache.felix
          maven-bundle-plugin
          2.4.0
          true
    
    

    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:

    
        org.apache.maven.plugins
        maven-dependency-plugin
        
            
                org.apache.felix
                maven-bundle-plugin
                2.4.0
                maven-plugin
    
            
        
        true
    
    

    0 讨论(0)
提交回复
热议问题