Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 334540 - Find a way to import org.hamcrest as package dependency
Summary: Find a way to import org.hamcrest as package dependency
Status: NEW
Alias: None
Product: EGit
Classification: Technology
Component: UI (show other bugs)
Version: 0.11   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-17 11:46 EST by Matthias Sohn CLA
Modified: 2016-08-17 15:58 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Sohn CLA 2011-01-17 11:46:11 EST
Change [1] tried to replace the bundle dependency on org.hamcrest by a package dependency.
This works in Eclipse but unfortunately doesn't work in the Tycho build since org.hamcrest is a split package. We should find a way to fix this. In order to fix the build until this fix is available we revert this change for now.

[1] http://egit.eclipse.org/r/#change,2253
Comment 1 Matthias Sohn CLA 2011-01-17 11:47:55 EST
Comment by Jan Sievers (Tycho team):



2011/1/17 Sievers, Jan <jan.sievers@sap.com>
hm.

Bundle-SymbolicName should have been org.hamcrest.core, not org.hamcrest.

So I don't know how it worked before (mabe this is a different hamcrest wrapper bundle coming from swtbot?).

package org.hamcrest is a split package

Export-Package: org.hamcrest;version="1.1.0";core=split;mandatory:=cor
 e,org.hamcrest.core;version="1.1.0",org.hamcrest.internal;version="1.
 1.0";x-internal:=true

which seems to cause major headaches, see

https://bugs.eclipse.org/bugs/show_bug.cgi?id=271348
http://groups.google.com/group/hamcrest-dev/browse_thread/thread/3c2357667c5bc005?pli=1

To make things more complicated, the hamcrest packages are also re-exported by the junit 4 bundle.

Did not go into the details but I would just use Require-Bundle to get around this.
Or maybe try

Import-Package: org.hamcrest;core=split

Regards,
Jan

> From: Matthias Sohn [mailto:matthias.sohn@googlemail.com]
> Sent: Montag, 17. Januar 2011 10:53
> To: Sievers, Jan
> Subject: why does require-bundle work but import-package not
>
> We have changed our indirect dependency to bundle org.hamcrest needed by junit 4
> from require-bundle to import package [1], now the build in Eclipse still succeeds but
> the tycho build fails [2]. Any idea what's the reason ?
>
> [1] http://egit.eclipse.org/r/#patch,unified,2253,2,org.eclipse.egit.ui.test/META-INF/MANIFEST.MF
> [2] https://hudson.eclipse.org/hudson/job/egit/913/console
Comment 2 Gunnar Wagenknecht CLA 2013-03-13 09:53:47 EDT
I just hit the same issue today while porting a larger project to Tycho. The issue is IMHO a Tycho issue.

My target definition file contains all the Hamcrest bundles from Orbit including their dependencies. The Target Platform State view in Eclipse show they resolve properly.

However, Tycho seems to only add "org.hamcrest.core" to the Equinox Resolver during resolution process. The Tycho debug output at least shows no signs about the other Hamcrest bundles.


> mvn clean compile -X
...
[DEBUG] Adding target definition file "...my-target-platform.target"
[DEBUG] Added 562 units, the content of the target definition file, to the target platform
[DEBUG] Registered artifact repository org.eclipse.tycho.repository.registry.facade.RepositoryBlackboardKey(uri=file:/resolution-context-artifacts@...)
[DEBUG] Added 11 locally built units to the target platform
[INFO] Resolving dependencies of MavenProject: ...:1.0.0-SNAPSHOT @ ...\pom.xml
[WARNING] The following locally built units have been used to resolve project dependencies:
[WARNING]   org.apache.commons.csv/1.0.0.r678580_qualifier
[INFO] Resolving class path of MavenProject: ...:1.0.0-SNAPSHOT @ ...\pom.xml
[DEBUG] Equinox resolver state:
Resolved OSGi state
..
RESOLVED org.hamcrest.core_1.3.0.v201303031735 : ..\.m2\repository\p2\osgi\bundle\org.hamcrest.core\1.3.0.v201303031735\org.hamcrest.core-1.3.0.v201303031735.jar
...
[ERROR] -> [Help 1]
org.apache.maven.InternalErrorException: Internal error: java.lang.RuntimeException: org.osgi.framework.BundleException: Bundle ... cannot be resolved
Resolution errors:
   Bundle ... - Missing Constraint: Import-Package: org.hamcrest; version="1.1.0"
Comment 3 Gunnar Wagenknecht CLA 2013-03-13 10:06:53 EDT
(In reply to comment #2)
> However, Tycho seems to only add "org.hamcrest.core" to the Equinox Resolver
> during resolution process. The Tycho debug output at least shows no signs
> about the other Hamcrest bundles.

Confirmed the behavior with "org.eclipse.core.runtime" package. Created bug 403196 for Tycho investigation.