Adding Artifacts from URLs (or single artifacts from a P2 updatesite)

I have a couple of Artifacts I need to use, that are hidden in a very large p2 repository. I don’t want to use the P2Repo we have, because it would take ages till it downloaded and index everything.

Thus I ask myself, if we have any kind of repository, that I can somehow hand a couple of URLs, that point directly to the necessary files, so it only downloads and indexes what’s needed.

Okay, to Answer my own question:

The P2Repository supports reading a .target file. Curating a target definition with the given target file editor can be quite messy, because it usually works with P2 Features that in most cases come with a lot of garbage that no one needs or wants.

One can however do it manually and point to separate bundles instead of feature. An example could look like this:

<target name="targetPlatform">
	<locations>
		<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
			<repository location="http://download.eclipse.org/releases/2020-06"/>
			<unit id="org.eclipse.draw2d" version="3.10.100.201606061308"/>
		</location>
	</locations>
</target>

Finding the right update site and version usually requires a lot of google use, but will produce results in most cases. Please not that an exact version is required, as in comparison to eclipse, bnd does not support 0.0.0 versions.

See also the idea in this issue: Repository bundle filter implementation · Issue #3522 · bndtools/bnd (github.com)