Why can't maven find an osgi bundle dependency?

前端 未结 1 1856
长情又很酷
长情又很酷 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

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

    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>
    
    0 讨论(0)
提交回复
热议问题