如何在 tycho 中引用 mockito?
我目前正在尝试让 tycho 完成我的构建(约 30 个捆绑包).
在我的单元测试中使用 的说明.(我不确定您是否需要指定解析器).
关于 Nexus 中对 p2 存储库的支持,我的理解是 Nexus 的 p2 插件已经开源:
- Nexus - P2 存储库插件一个>
- Nexus - Bundle Maker
- nexus-p2-repository-plugin 的 Github 存储库
I'm currently trying to get my build (~30 bundles) done by tycho.
I faced some confusing problems when using Mockito in my unit tests.
I created an eclipse-test-plugin
as fragment project to the tested bundle.
Since tycho should resolve the required bundles using the manifest, I removed the dependency to mockito from the pom.xml
.
When I then try to add mockito to the required bundles in the manifest mockito isn't listed.
I found this post and created a target platform pointing to eclipse indigo.
I included the platform specifics so I don't need the eclipse delta pack. Then the first strange thing occurs. Eclipse is telling me that there are some unsatisfiably dependencies and when I set the newly created target platform as active within eclipse, no more packages like org.osgi.framework
, etc. can be resolved by eclipse. But when I build an eclipse-product
using tycho and the target platform it is working.
If I set the current eclipse installation as active platform the bundles are resolved. I've selected the following of the indigo release:
- Eclipse RCP Plug-in Developer Resources
- Equinox Target Components
- Jetty Target Components
So my first question is "What is wrong with my target-platform so that tycho is able to use it but eclipse isn't?"
To get closer to my original problem (getting mockito running) I set the current eclipse installation as the active target platform. Eclipse then can resolve the org.osgi.framework
package and others.
I added then the previously removed dependency to mockito again to my pom.xml
like in the above-mentioned post. But I still can't find mockito when I try to add it to the required bundles in the manifest.
So my second question is "What am I doing wrong? How do you reference bundles that are not published at the eclipse update site, e.g. the maven central repository?"
Update: During my research I found two ways of including bundles from non-p2-update-sites in my target-platform:
- Nexus Pro
The professional version of Nexus supports p2-Proxy repositories which can wrap default maven repositories like the Maven Central Repository into a p2 update-site, but the professional version costs round about $800 per year. - Create an eclipse-repository
You can create a new maven project with packagingeclipse-repository
including all your desired bundles. The created artifact is then deployed to a common web server.
In your target-platform you can then reference the Nexus p2-proxy repo or the web hosted p2-repo.
Does anyone know other ways - probably more convenient/less expensive?
Please help me understand the confusing world of tycho a bit more...
Thanks in advance
If mockito isn't in your target platform (and you don't have it in a p2 repository), the easiest thing to do is probably to re-add the dependency back into your pom (without removing the mockito import from your manifest).
I think you'll also need to specify the following in the pom, in the configuration for the target-platform-configuration plugin:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<pomDependencies>consider</pomDependencies>
</configuration>
</plugin>
See the instructions on adding a dependency on a pom-first artifact. (I'm not sure whether you'll need to specify the resolver).
Regarding support for p2 repositories in Nexus, my understanding is that the p2 plugin for Nexus has since been open-sourced:
- Nexus - P2 Repository Plugin
- Nexus - Bundle Maker
- Github repository for nexus-p2-repository-plugin
相关文章