Installable units are missing in p2 repository, so that tycho-p2-director fails when setting source=repository

StackOverflow https://stackoverflow.com/questions/17855554

  •  04-06-2022
  •  | 
  •  

Question

I am building a product (in an eclipse-repository module) containing several features which configure their plug-ins via installable units created through p2.inf files.

This works as long as I use the default value targetPlatform for the source configuration parameter of the tycho-p2-director-plugin. AFAIK this makes the director access the p2 metadata from <project_dir>/target/targetPlatformRepository/context.xml and the artifacts from the local Maven repository.

As I want to modify some bundles, I changed the source parameter to repository. This makes the director use artifacts and metadata from the generated repository in <project_dir>/target/repository and breaks my build ;-)

It seems that the installable units created via the p2.inf are missing in <project_dir>/target/repository/content.jar whereas <project_dir>/target/targetPlatformRepository/context.xml is complete. E.g. the following unit is only contained in the latter:

<unit id='configure.org.sample.bundle' ...>
  <!-- config -->
</unit>

How do I configure the build to also include that installable unit in project/repository/content.jar?

Here is a snippet of my p2.inf file:

# org.sample.bundle
requires.0.namespace=org.eclipse.equinox.p2.iu
requires.0.name=configure.org.sample.bundle
requires.0.greedy=true

units.0.id=configure.org.sample.bundle
units.0.version=1.0.0
units.0.provides.1.namespace=org.eclipse.equinox.p2.iu
units.0.provides.1.name=configure.org.sample.bundle
units.0.provides.1.version=1.0.0
units.0.instructions.install=org.eclipse.equinox.p2.touchpoint.eclipse.installBundle(bundle:${artifact});
units.0.instructions.configure=org.eclipse.equinox.p2.touchpoint.eclipse.setStartLevel(startLevel:2); org.eclipse.equinox.p2.touchpoint.eclipse.markStarted(started:true);
units.0.hostRequirements.1.namespace=osgi.bundle
units.0.hostRequirements.1.name=org.sample.bundle
units.0.hostRequirements.1.greedy=false
units.0.hostRequirements.2.namespace=org.eclipse.equinox.p2.eclipse.type
units.0.hostRequirements.2.name=bundle
units.0.hostRequirements.2.range=[1.0.0,2.0.0)
units.0.hostRequirements.2.greedy=false
units.0.requires.1.namespace=osgi.bundle
units.0.requires.1.name=org.sample.bundle
units.0.requires.1.greedy=false

And the error from Tycho build:

Cannot complete the install because one or more required items could not be found.
Software being installed: sample 1.0.0.201308060715 (sample.product 1.0.0.201308060715)
Missing requirement: Sample Feature 1.0.0.201308060715 (sample.feature.feature.group
1.0.0.201308060715) requires 'configure.org.sample.bundle 0.0.0' but it could not be found
Was it helpful?

Solution

When you create a product installation, the p2 director needs to resolve all transitve dependencies of the product. However by default, the p2 repository built in an eclipse-repository module (usually at target/repository/) only aggregates the included content.

Since you are saying that the units created via the p2.inf are missing in the target/repository/ p2 repository, they are probably not included in the features but only referenced as dependency. Although you could also change the p2.inf to generate inclusions, this is probably not the easiest solution.

Instead, simply configure the tycho-p2-repository-plugin to aggregate not only inclusions but all dependencies:

<build>
  <plugins>
    <plugin>
      <groupId>org.eclipse.tycho</groupId>
      <artifactId>tycho-p2-repository-plugin</artifactId>
      <version>${tycho-version}</version>
      <configuration>
        <includeAllDependencies>true</includeAllDependencies>
      </configuration>
    </plugin>
  </plugins>
</build>

Then, it shouldn't matter if you have the tycho-p2-director-plugin install directly from the target platform or from the aggregated p2 repository.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top