Equinox/p2/Ant Tasks

From Eclipsepedia

Jump to: navigation, search

The new format is available in builds after April 26, 2009.

Contents

Mirror Task

The p2.mirror task is used to copy the contents of one repository to another. The location of the destination repository must be modifiable, and if a destination repository of a type is defined then a source for that type must also be present

Note that in the examples in this section the tasks contain a </source> tag, this tag should not contain a space it is present due to a limitation in the wiki software.

Simple Examples

A task to mirror only the contents of a metadata repository at a given location:

<p2.mirror>
  <repository location="file:/myDestination" name="A new repository" kind="M" />
  <source>
    <repository location="http://aSource/" kind="M" />
  < /source>
</p2.mirror>

The task to mirror the artifact contents is very similar changing only the 'kind' attribute of the repositories:

<p2.mirror>
  <repository location="file:/myDestination" name="A new repository" kind="A" />
  <source>
    <repository location="http://aSource/" kind="A" />
  < /source>
</p2.mirror>

A co-located repository can be specified by omitting the kind attribute on the repository, in this example the contents of both the artifact and metadata repositories at the location will be mirrored:

<p2.mirror>
  <repository location="file:/myDestination" name="A new repository" />
  <source>
    <repository location="http://aSource/" />
  < /source>
</p2.mirror>

The repositories in the tasks can be a mixture specified kinds and co-located.

Multiple Repositories

The source or destination metadata and artifact repositories need not be co-located, although the tasks are limited to at most one artifact and one metadata destination repository.

<p2.mirror>
  <repository location="file:/myArtifactDestination" name="A new repository" kind="A" />
  <repository location="file:/myMetaDestination" name="A new repository" kind="M" />
  <source>
    <repository location="http://aSource/" />
  < /source>
</p2.mirror>

Multiple source locations can also be defined:

<p2.mirror>
  <repository location="file:/myArtifactDestination" name="A new repository" kind="A" />
  <repository location="file:/myMetaDestination" name="A new repository" kind="M" />
  <source>
    <repository location="http://aSource2/" />
    <repository location="http://aSourceMeta/" kind="M" />
    <repository location="http://aSourceArtifact/" kind="A" />
  < /source>
</p2.mirror>

Fileset Repositories

The source repositories can also be defined through a FileSet (see Apache Ant documentation for defining a fileset), though if the location(s) in the filesetshould be a specific kind of repository that should also be specified by again using the kind attribute:

<p2.mirror>
  <repository location="file:/myDestination" name="A new repository" />
  <source>
    <repository location="http://aSource/" />
    <fileset kind="m" .... />
  < /source>
  <iu id="tooling.osgi.bundle.default" version="1.0.0" />
  <slicingoptions platformfilter="win32,win32,x86" />
</p2.mirror>

Repository Format

By default if the destination repositories already exist then the new data is appended, this can be prevented by adding the append attribute with the value false:

<p2.mirror>
  <repository location="file:/myArtifactDestination" name="A new repository" kind="A" append="false" />
  <repository location="file:/myMetaDestination" name="A new repository" kind="M" append="false" />
  <source>
    <repository location="http://aSource/" />
  < /source>
</p2.mirror>

To create a new repository using the properties of an existing repository the format attribute is added to the repository element:

<p2.mirror>
  <repository location="file:/myArtifactDestination" name="A new repository" kind="A" format="http://somerepo/" />
  <repository location="file:/myMetaDestination" name="A new repository" kind="M" append="false" />
  <source>
    <repository location="http://aSource/" />
  < /source>
</p2.mirror>

Partial Mirroring

Its also possible to partially mirror a repository, the simplest method is to specify an individual IU which will result in the default slicing options being used. If an artifact destination repository is defined then the artifacts required by the IUs will also be mirrored.

<p2.mirror>
  <repository location="file:/myDestination" name="A new repository" />
  <source>
    <repository location="http://aSource/" />
  < /source>
  <iu id="tooling.osgi.bundle.default" version="1.0.0" />
</p2.mirror>

If only windows IUs and artifacts were required then a slicingOptions element needs to be defined with a platform filter:

<p2.mirror>
  <repository location="file:/myDestination" name="A new repository" />
  <source>
    <repository location="http://aSource/" />
  < /source>
  <iu id="tooling.osgi.bundle.default" version="1.0.0" />
  <slicingoptions platformfilter="win32,win32,x86" />
</p2.mirror>

Comparison

There are several comparators (eg. MD5, JarComparator) available which can be used to compare the contents of a repository, when these are used the artifact must either be present in the destination repository, or a baseline repository must be defined.

<p2.mirror>
  <repository location="file:/myDestination" name="A new repository" />
  <source>
    <repository location="http://aSource/" />
  < /source>
  <comparator comparator="org.eclipse.equinox.artifact.md5.comparator" comparatorLog="/home/user/myFile.xml">
    <repository location="http://baseline/" />
  </comparator>
</p2.mirror>

Validate Task

This task is used to validate an artifact repository using a comparator (the examples are using an md5 comparator.) A single use example:

<p2.composite.artifact.repository.validate comparatorID="org.eclipse.equinox.artifact.md5.comparator" location="file:///myfile"/>

An example task to validate multiple repositories using the same comparator:

<p2.composite.artifact.repository.validate comparatorID="org.eclipse.equinox.artifact.md5.comparator">
	<repository location="file:///myRepo"/>
	<repository location="file:///myRepo"/>
</p2.composite.artifact.repository.validate>

Creating a Composite Repository

The create composite repository tasks can be used to create an artifact or a metadata composite repository. An existing repository can be used as an example and the new repository will match the properties of the example.

<p2.create.composite.repository>
	<repository kind="metadata" compressed="true" location="file:///myNewRepo1" format="file:///anExampleRepo" name="My New Metadata Repo" />
	<repository kind="artifact" compressed="true" location="file:///myNewRepo2" format="file:///anExampleRepo" name="My New Artifact Repo" />
	<add>
		<repository location="http://eclipse.org/childRepo1"/>
		<repository location="http://eclipse.org/childRepo2"/>
	</add>
</p2.create.composite.repository>

Modifying Children of a Composite Repository

It's also possible to add, or to remove children from a repository with an ant task.

<p2.modify.composite.repository.children>
   <repository kind="metadata" location="file:///Users/Pascal/tmp/mirrorTest9"/>
   <repository kind="artifact" location="file:///Users/Pascal/tmp/mirrorTest9"/>
   <add>
      <repository kind="metadata" location="file:///childRepo"/>
   </add>
   <remove>
      <repository kind="artifact" location="file:///childRepo2"/>
    </remove>
</p2.modify.composite.repository.children>

If the append attribute of the destination is set to false then existing children are removed before other operations are performed:

<p2.modify.composite.repository.children>
    <destination kind="metadata" location="file:///Users/Pascal/tmp/mirrorTest9" append="False"/>
    <add>
	<repository kind="metadata" location="file:///childRepo"/>
    </add>
</p2.modify.composite.repository.children>

Common Task Elements

Repositories

The input format used by repositories in p2 Ant tasks:

<repository location="file:///Users/Pascal/Downloads/builds/transfer/files/updates/3.5-I-builds/I20090203-1200" append="true" compressed="true" 
	format="file:///Users/Pascal/Downloads/builds/transfer/files/updates/3.5-I-builds/I20090203-1200" kind="metadata" name="" remove="false" />

In general the location is always required, other attributes may not be used by individual tasks.

Attribute Type Default Description
location URI null The location of the repository
append boolean true Determines if the task should append to an existing repository or empty it first
compressed boolean true Determines if the repository should be compressed
format URI null Location of a repository to copy format from
kind "metadata" or "artifact" Both Specifies the type of the repository. Default is to add both a metadata and artifact repository
name String null The name of the repository
remove boolean false Defines if the repository be removed

Installable Units

<iu id="tooling.osgi.bundle.default" version="1.0.0" />
Attribute Type Default Description
id String none The InstallableUnit identifier
version Version none The version of the InstallableUnit

Old Tasks

Create Composite Repository

The create composite repository tasks can be used to create an artifact or a metadata composite repository. An existing repository can be used as an example and the new repository will match the properties of the example.

<p2.composite.artifact.repository.create compressed="true" name="My new Repo" location="file:///myNewRepo"  />
<p2.composite.metadata.repository.create compressed="false" name="My new Repo" location="file:///myNewRepo" />

Modifying Children of a Composite Repository

To add a single child to a composite repository:

<p2.composite.artifact.repository.add location="file:///myRepo" child="file:///myChildRepo" />
<p2.composite.metadata.repository.add location="file:///myRepo" child="file:///myChildRepo" />

To remove a single child from a composite repository:

<p2.composite.artifact.repository.remove location="file:///myRepo" child="file:///myChildRepo" />
<p2.composite.metadata.repository.remove location="file:///myRepo" child="file:///myChildRepo" />

Or all children could be removed from a repository:

<p2.composite.artifact.repository.remove location="file:///myRepo" allChildren="True"/>
<p2.composite.metadata.repository.remove location="file:///myRepo" allChildren="True"/>