Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 348624 - Manifest export packages sections ignored if Bundle-ClassPath directive present
Summary: Manifest export packages sections ignored if Bundle-ClassPath directive present
Status: CLOSED INVALID
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Tycho (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Jan Sievers CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-07 14:57 EDT by Frederic Perez CLA
Modified: 2021-04-28 16:55 EDT (History)
2 users (show)

See Also:


Attachments
Test case (35.33 KB, application/octet-stream)
2011-06-07 18:33 EDT, Frederic Perez CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Frederic Perez CLA 2011-06-07 14:57:34 EDT
Build Identifier: 0.13 git 09d71aa2f895d94bb002b7e6c6bdf299a740c224

If project A requires in its manifest bundle B that has entries like:
bundle B manifest:
Export-Package: com.example.b
Bundle-ClassPath: ext/dependency.jar

The compilation of A fails when trying to import the com.example.b package. 
If the line Bundle-ClassPath is removed from bundle B manifest, the compilation succeeds.


Reproducible: Always

Steps to Reproduce:
Try to import a package from a bundle with a Bundle-ClassPath directive
Comment 1 Igor Fedorenko CLA 2011-06-07 15:07:24 EDT
Please provide complete standalone example project and steps to reproduce the problem.
Comment 2 Frederic Perez CLA 2011-06-07 18:33:49 EDT
Created attachment 197549 [details]
Test case

Finally did some tests and found the root of the problem.
Looks like an entry like this:
Bundle-ClassPath: ext/lib.jar
works in eclipse but not in tycho. Tycho needs
Bundle-ClassPath: ., ext/lib.jar
(Note the .,)
I'm not sure the former is correct or not.

I have assembled some tests. To run them you have to:
- publish p2TestRepo to http://127.0.0.1/p2TestRepo 
- run mvn compile
p2TestRepo is a p2 repository with:
HasBundleClassPathWithDot.jar - exports com.example.Example and has BundleClassPath: .,lib.jar
NoBundleClassPath - exports com.example.Example and has no BundleClassPath directive
HasBundleClassPath - exports com.example.Example and has BundleClassPath : lib.jar
the lib.jar is some random library unused in the test.

The main 3 projects are all the same but each one requiring the bundle its name states. Each project just imports com.example.Example and does a new Example();

usesHasClassBundleClassPathWithDot -> builds correctly
usesHasBundleClassPath -> builds correctly
usesNoClassBundleClassPath -> Fails to build in tycho. Builds with no errors in Eclipse.

Eclipse and Tycho behave differently and this might lead to confusion.
Comment 3 Jan Sievers CLA 2011-06-14 11:36:49 EDT
(In reply to comment #2)

you configured the wrong groupId "org.sonatype.tycho" for target-platform-configuration in your sample project.

If I fix this, I can build successfully modules 

    <module>usesHasClassBundleClassPathWithDot</module>
    <module>usesNoClassBundleClassPath</module>  


Module

    <module>usesHasClassBundleClassPath</module> 

fails with compilation error. This is normal because it has

Require-Bundle: HasBundleClassPath;bundle-version="1.0.0"

and actually HasBundleClassPath exports the package required for compilation

Export-Package: com.example

, but it only has 

Bundle-ClassPath: ext/jsr305-0.0.0.jar

which does not contain this package.

To summarize, I don't see this is a bug. Feel free to reopen with a sample project that proves it's a bug.

The thing that may have confused you here is that in OSGi, if there is no Bundle-ClassPath MANIFEST entry, this means there is an implicit default value Bundle-ClassPath: .

However as soon as you specify an explicit Bundle-ClassPath entry, the "." entry must be mentioned explicitly if desired. See OSGi core spec section 3.8.1 .