OPS4J Pax URL, find what maven repository has an artifact?

43 views
Skip to first unread message

Steinar Bang

unread,
Sep 4, 2017, 11:44:31 AM9/4/17
to op...@googlegroups.com
I'm thinking about writing an OSGi plugin for karaf that can be
configured to watch a remote repository for snapshot updates.

The idea is to do something like this
1. For each configured bundle, if the bundle has a snapshot version, intially do
a. Get the maven coordinates
b. Scan the configured repositories and chose the first repository
that has the artifact
c. Download the Repo-URL/groupId/artifactId/version/maven-metadata.xml
and parse it to find the most recent snapshot, taking note of the
maven repository, newest snapshot version, newest snapshot
timestamp, as well as the update time of the maven-metadata.xml
file
2. Schedule a job that for each configured bundle, that:
a. Does a conditional GET for the Repo-URL/groupId/artifactId/version/maven-metadata.xml
file
b. If the conditional GET receives content, parse the content and
extract the snapshot version and timestamp and compare them with
the save versions to see if they actually have changed
c. If a new snapshot has arrived, tell the bundle to update

Right now I'm reading the Pax-URL documentation[1] trying to figure out
if it's possible to do step 1b.

Does anyone familiar with Pax-Url think this might be feasible? Or is
the actual repo used so hidden away that it is hard to do?

Thanks!


- Steinar

References:
[1] <https://ops4j1.jira.com/wiki/spaces/paxurl/pages/3833866/Mvn+Protocol>

Grzegorz Grzybek

unread,
Sep 4, 2017, 11:59:55 AM9/4/17
to op...@googlegroups.com
Hello

What you described is implemented in JBoss Fuse 6.x / Fabric8 v1. But it's not that big problem to try to implement it.

1b) "scan the configured repositories" - you have org.ops4j.pax.url.mvn.repositories property in org.ops4j.pa.url.mvn PID
1c) entire point is just "aether resolution operation for SNAPSHOT version" - see the details here: http://ggrzybek.blogspot.com/2016/10/using-maven-with-osgi-part-3.html

In Karaf you can:

osgi:install mvn:groupId/artifactId/version

if "version" is X.Y.Z-SNAPSHOT, then simple "osgi:update <bundle-id or symbolic name>" will go through entire Aether/Maven resolution according to configured update policy (for example, if local version of metadata is not older than 1 day, "org.ops4j.pax.url.mvn.globalUpdatePolicy = daily" will prevent redownloading of metadata.

See http://ggrzybek.blogspot.com/2016/07/using-maven-with-osgi-part-2.html for more information about pax-url-aether configuration
See http://ggrzybek.blogspot.com/2016/10/using-maven-with-osgi-part-3.html for more information about SNAPSHOT resolution

I hope this information will help you decide on your design.

regards
Grzegorz Grzybek


--
--
------------------
OPS4J - http://www.ops4j.org - op...@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ops4j+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jean-Baptiste Onofré

unread,
Sep 4, 2017, 12:52:39 PM9/4/17
to op...@googlegroups.com

Hi,

it's already what I replied on the Karaf mailing list.
AFAIR, Steinar wants to avoid bundle:update: he wants an auto-update (and bundle:watch can only update from the local repository).

Regards
JB

To unsubscribe from this group and stop receiving emails from it, send an email to ops4j+un...@googlegroups.com.

Steinar Bang

unread,
Sep 4, 2017, 1:28:39 PM9/4/17
to op...@googlegroups.com
>>>>> Jean-Baptiste Onofré <jeanbapti...@gmail.com>:

> it's already what I replied on the Karaf mailing list.
> AFAIR, Steinar wants to avoid bundle:update: he wants an auto-update
> (and bundle:watch can only update from the local repository).

Yes, that is correct.

It's the final building block I need to get continous deployment
working.

(and if karaf cave gets it I'll use that instead of rolling my own)

Steinar Bang

unread,
Sep 4, 2017, 1:51:09 PM9/4/17
to op...@googlegroups.com
>>>>> Grzegorz Grzybek <gr.gr...@gmail.com>:

> What you described is implemented in JBoss Fuse 6.x / Fabric8 v1. But it's
> not that big problem to try to implement it.

> 1b) "scan the configured repositories" - you have
> org.ops4j.pax.url.mvn.repositories property in org.ops4j.pa.url.mvn PID
> 1c) entire point is just "aether resolution operation for SNAPSHOT version"
> - see the details here:
> http://ggrzybek.blogspot.com/2016/10/using-maven-with-osgi-part-3.html

Interesting article! (google didn't find it during my searches for
aether and maven stuff)

> In Karaf you can:

> osgi:install mvn:groupId/artifactId/version

> if "version" is X.Y.Z-SNAPSHOT, then simple "osgi:update <bundle-id or
> symbolic name>" will go through entire Aether/Maven resolution according to
> configured update policy (for example, if local version of metadata is not
> older than 1 day, "org.ops4j.pax.url.mvn.globalUpdatePolicy = daily" will
> prevent redownloading of metadata.

I'm currently using globalUpdatePolicy always, and that's enough to make
bundle:update bundlesymbolicname
reload the bundle with a new snapshot made by travis-ci:
https://github.com/steinarb/ukelonn#oppsett-av-webappen-på-en-server-med-debian-gnulinux
(step 6, text in Norwegian but the config stuff should be readable)

So I'm close to having continous deployment from travis-ci, but I'm
missing some way of tickling the "bundle:update" command on the affected
bundles.

> See http://ggrzybek.blogspot.com/2016/07/using-maven-with-osgi-part-2.html
> for more information about pax-url-aether configuration
> See http://ggrzybek.blogspot.com/2016/10/using-maven-with-osgi-part-3.html
> for more information about SNAPSHOT resolution

Looks like I will rely on karaf cave for this functionality, but this is
interesting stuff, so I will read it anyway.

Thanks for the URLs, and the explanations!


- Steinar

Reply all
Reply to author
Forward
0 new messages