OSGI: bundles, class inheritance and maven scope

2019-08-15 02:29发布

I have three maven projects as three osgi bundles (that is one project is one bundle). And I have three classes - one class in each bundle.

Project/Bundle 1:
class A{}
pom:    

Project/Bundle 2:
class B extends A{}
pom:
 <dependency>
     <groupId>com.company</groupId>
     <artifactId>project1</artifactId>
     <version>1.0.0</version>
     <scope>provided</scope>
</dependency>

Project/Bundle 3
class C extends B{}
pom:
 <dependency>
     <groupId>com.company</groupId>
     <artifactId>project2</artifactId>
     <version>1.0.0</version>
     <scope>provided</scope>
</dependency>

Why when I compile project3 I get exception that class A can't be accessed? The problem is solved only adding project1 as dependency to project 3. But, why?

标签: java maven osgi
1条回答
smile是对你的礼貌
2楼-- · 2019-08-15 03:12

It is because of the provided scope. It breaks the transitive lookup.

查看更多
登录 后发表回答