Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [tycho-dev] Get Metadata of a given repo from Tycho

Hi,
Mickael, did you get your maven plugin to work?

I'm currently trying to do something similar. I created a shared bundle with component interface, a regular bundle that provides the component and a maven plugin that tries to get this service.
But whatever I do I always get a 'Service is not registered' exception from EquinoxServiceFactory#getService(). Stock tycho services seem to be working without any problem.
I made sure that my TychoOsgiRuntimeArtifacts component does get called and whenever I provide some bogus artifacts from there, the mojo executions fails with their resolution.
Seems that component doesn't get registered in the first place..

Thanks in advance!


2014-09-13 4:14 GMT+03:00 Igor Fedorenko <igor@xxxxxxxxxxxxxx>:
Here is a working example [1], although it uses much much older version
of Tycho and I don't remember how much we changed in this area.

org.sonatype.m2e.discovery.publisher.p2.facade is the bridge between
Maven and OSGi classloaders. It defines facade interface visible both to
OSGi and Maven worlds.

org.sonatype.m2e.discovery.publisher.p2.impl is real OSGi bundle that
uses OSGi, P2 and Tycho P2 API.

org.sonatype.m2e.discovery.publisher.maven-plugin is the Maven plugin
that invokes OSGi/P2 services through the facade interface.

P2RuntimeMetadata, which implements TychoP2RuntimeMetadata interface, is
how Tycho knows what additional bundles should be added to embedded OSGi
framework instance at runtime. I don't remember how Tycho decides which
bundles should be loaded as bundles and which as "bridges".


[1] https://github.com/takari/m2eclipse-discovery


--
Regards,
Igor

On 2014-09-12, 6:52, Oberlies, Tobias wrote:
Yes, all the p2 things are only usable in OSGi bundles.

In order to get access to such a functionality, you’d define an
interface in a “shared bundle”, provide an implementation in a normal
bundle and register that implementation as OSGi service, and then obtain
the instance from the mojo via
EquinoxServiceFactory.getService(Class<T>). The “shared bundles” bridge
the two classloader worlds: They are loaded by the Maven class loader
and exposed to the real OSGi bundles as extra system packages (see
TychoOsgiRuntimeLocator).

AFAIK, Igor has implemented explicit support for extending Tycho’s OSGi
runtime, e.g. for your own OSGi services. To do this, you’d need to
create your own shared bundle and implementation bundle. The
implementation bundle can be added to the OSGi runtime via a new
TychoOsgiRuntimeArtifacts component. (To add components, you’d need to
add the jar defining the component as extra dependency of the Tycho
build extension AFAIK.) Your shared bundle also needs to be added as
dependency to Tycho’s build extension. AFAIK, there is no extension
mechanism for additional system packages, but this shouldn’t be hard to add.

I’ve never seen this in practice, so if you get this to work, I’d be
interested to see it.

Regards

Tobias

*From:*tycho-dev-bounces@eclipse.org
[mailto:tycho-dev-bounces@eclipse.org] *On Behalf Of *Mickael Istria
*Sent:* Freitag, 12. September 2014 11:56
*To:* tycho-dev@xxxxxxxxxxx
*Subject:* Re: [tycho-dev] Get Metadata of a given repo from Tycho

Thanks for this answer.
It seems to me that IArtifactRepository interface (and family) are only
visible from inside Equinox, and cannot be accessed directly from a
Mojo. Am I right? If so, does it means I'd need to wrap it in a service
(similarly to how BaselineService works) ? Is it possible to
define/register additional Equinox services from a Mojo ?

--
Mickael Istria
Eclipse developer at JBoss, by Red Hat <http://www.jboss.org/tools>
My blog <http://mickaelistria.wordpress.com> - My Tweets
<http://twitter.com/mickaelistria>



_______________________________________________
tycho-dev mailing list
tycho-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/tycho-dev

_______________________________________________
tycho-dev mailing list
tycho-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/tycho-dev



--
Regards,
Anton.

Back to the top