# Product Builds with p2

Defining the new property:

`p2.gathering = true`

will cause a few changes for product builds. In particular, the build will produce properly installed fully p2 enabled products.

The following is a list of related properties (old and new):

`p2.gathering` | Set to `true` to turn on p2 publisher based builds.
`p2.build.repo` | A URI to the local build time p2 repository, default is `file:${buildDirectory}/buildRepo`. Results will be mirrored from here to the final archive location.
`generate.p2.metadata` | This is property for the old metadata generator integration. It has no effect when `p2.gathering=true`.
`p2.metadata.repo p2.artifact.repo` | These properties are be URIs. By default for product builds, the final archives are the installed products and metadata and artifacts are left in the `${p2.build.repo}`. If `p2.metadata.repo` and `p2.artifact.repo` are defined, then the artifacts and metadata for the product will be mirrored from the build repository.
`p2.metadata.repo.name p2.artifact.repo.name` | Optional, these properties will be used to name the final repository when `p2.metadata.repo` and `p2.artifact.repo` are used.
`p2.compress` | Set to `true` to compress the final repository xml into a jar.
`p2.flavor` | The flavor of the product, used as a qualifier on the configuration metadata for the product. See below.
`p2.product.qualifier` | The qualifier to use when replacing "1.0.0.qualifier" in a product's version. If not set, the qualifier will be based on `forceContextQualifier` or the timestamp.
`p2.publish.artifacts` | No effect when `p2.gathering=true` (Old property)
`p2.root.name p2.root.version` | No effect when `p2.gathering=true` (Old property)
`p2.context.repos` | Define context repositories. See reusing metadata.
`repoBaseLocation` | A folder containing repositories to transform using `<p2.repo2runnable>`. See also reusing metadata.
`transformedRepoLocation` | The folder containing the output of `<p2.repo2runnable>`. See also reusing metadata.
`p2.category.site` | A URL to a site.xml file used to define categories.
`p2.category.definition` | A URL to a category.xml file used to define categories.
`p2.category.prefix` | Define a prefix to ensure unique ids for category IUs generated from site/category files that don't use unique names.
`skipMirroring` | Skip the final mirroring from `${p2.build.repo}` to `${p2.metadata.repo}`.
`skipDirector` | Skip the call to the director. No installed products will be produced. If `p2.metadata.repo` and `p2.artifact.repo` are defined, those repositories will contain the product metadata and artifacts, otherwise `${p2.build.repo}` will contain the results.
`p2.director.log` | Location of a log file to log the results of the director call.
`p2.director.profile` | The name to use for the p2 profile created by the director. Generally it is a good idea to name this something related to your product. Default is "profile".
`p2.director.extraArgs` | Extra arguments to pass to the directory. Default is "`-profileProperties org.eclipse.update.install.features=true`".

Mirroring Properties

When building products or features, PDE/Build mirrors dependencies from context repositories to be included in the build. These properties control what dependencies are included in this operation. See the p2.mirror ant task for details.

`p2.mirror.raw` | Default value: false. Set to true to reuse artifact descriptors from the source repositories.
`p2.mirror.slicing.filter` | Default is no filter. Set additional filter properties IUs must satisfy in order to be included.
`p2.mirror.slicing.followOnlyFilteredRequirements` | Default is false. Set to true to invert the filters and only include IUs that don't match.
`p2.mirror.slicing.followStrict` | Default is false. Set to true to only include dependencies whose versions are exactly specified.
`p2.mirror.slicing.includeFeatures` | Default is true. Whether or not to include features.
`p2.mirror.slicing.includeNonGreedy` | Default is false. Whether or not to include non-greedy dependencies.
`p2.mirror.slicing.includeOptional` | Default is true, whether or not to include optional dependencies.
`p2.mirror.slicing.latestVersionOnly` | Default is false, whether or not to only include the latest version of a dependency when the requirement is a range and multiple versions are available.
`p2.mirror.slicing.platformFilter` | Default is no filter, An "os,ws,arch" triplet to set as the platform against which IU LDAP filters will be matched. IUs not matching the filter will not be mirrored.

### Product Flavor

As part of a product build, PDE/Build automatically generates default configuration metadata to set start levels and config.ini property. This metadata is commonly referred to as Configuration Units (CUs). In particular, start levels are set using CU fragments on the IU for the bundle being started. The flavor is used as a qualifier when generating the CU's name based on the IU.

For example, with "`p2.flavor = tooling`", `'toolingwin32.win32.x86org.eclipse.core.runtime'` will be the name of the CU that configures the org.eclipse.core.runtime bundle on windows. It may be a good idea to use a flavor based on your product id to avoid conflicts with other metadata, particularly if your product has particular needs with respect to start levels.

See also the configuring products page.

### The director call

PDE/Build includes a `runDirector` target that is called to perform installs during a product build. Currently, this is a fork of the director application in a new process. In more advanced releng scenarios, it is possible to reuse this task to perform additional installs. The task requires that the location of the equinox launcher for the builder is defined. An example call would look something like this:

    	<property name="equinoxLauncherJar" value="/builder/eclipse/plugins/org.eclipse.equinox.launcher_1.0.200.v20090520.jar"/>
    	<ant antfile="${eclipse.pdebuild.scripts}/genericTargets.xml" target="runDirector" inheritAll="true">
    		<property name="ws" value="gtk"/>
    		<property name="os" value="linux"/>
    		<property name="arch" value="x86"/>
    		<property name="p2.director.installPath" value="${installFolder}"/>
    		<property name="p2.repo" value="${p2.build.repo}"/>
    		<property name="p2.director.iu" value="my.rcp.product"/>
    		<property name="p2.director.version" value="1.0.0"/>
    	</ant>