l.moretto
l.moretto

Reputation: 213

Tycho: P2 Repo mirror with platform filter

i'm developing an Eclipse RCP application composed by several plugins and features.

Among other things, features also provide platform-dependent native libraries by means of root files.

I succesfully managed to package my application and create a P2 repository using Tycho.

Now i'm trying to create a copy of the repository that should only contain artifacts for the win32 x86 platform. Following the instructions at this link https://wiki.eclipse.org/Tycho/Additional_Tools#mirror_goal, I tried to use Tycho's mirror goal. Here's the pom file I wrote:

<?xml version="1.0" encoding="UTF-8"?>
<project>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>mirror</artifactId>
    <groupId>group</groupId>
    <version>1.0.0-SNAPSHOT</version>
    <name>Win32 Mirror</name>

    <packaging>pom</packaging>
    <properties>
        <tycho-version>0.22.0</tycho-version>
        <tycho-extras-version>0.22.0</tycho-extras-version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.eclipse.tycho.extras</groupId>
                <artifactId>tycho-p2-extras-plugin</artifactId>
                <version>${tycho-version}</version>
                <executions>
                    <execution>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>mirror</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <source>
                        <!-- Full Repository -->
                        <repository>
                            <url>${project.baseUri}/full_repository/</url>
                            <layout>p2</layout>
                        </repository>
                    </source>

                    <filter>
                        <osgi.os>win32</osgi.os>
                        <osgi.ws>win32</osgi.ws>
                        <osgi.arch>x86</osgi.arch>
                    </filter>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project> 

However, when I try to create the mirror, I get the following error:

Failed to execute goal org.eclipse.tycho.extras:tycho-p2-extras-plugin:0.22.0:mirror (default)
on project mirror: Error during mirroring:
Mirroring failed: Problems resolving provisioning plan.
[my.feature_root.gtk.linux.x86_64 1.0.0.201501291243 cannot be installed in
this environment because its filter is not applicable.]

As you can see, Tycho fails to create the mirror when it encounters a binary feature root file for an architecture other than win32 x86 in the original repository.

Do you have any advice on how to create a P2 repository mirror that only targets the desired architecture?

Upvotes: 3

Views: 827

Answers (1)

s.d
s.d

Reputation: 4185

If you are building the repository during the build of your application (e.g., via the tycho-p2-director-plugin, you could use Maven profiles to have different repositories built. One profile could use your standard setup (e.g., all platforms), another could use just a win32.x86-specific target platform, such as specified in the below snippet from the parent POM's <build><plugins> section.

<plugin>
  <groupId>org.eclipse.tycho</groupId>
  <artifactId>target-platform-configuration</artifactId>
  <version>${tycho-version}</version>
  <configuration>
    <resolver>p2</resolver>
      <environments>
        <environment>
          <os>win32</os>
          <ws>win32</ws>
          <arch>x86</arch>
        </environment>
      </environments>
    </configuration>
  </plugin>

Upvotes: 2

Related Questions