2

Iam trying to generate a categorized p2 repository with Tycho. There are basically three steps to make (compare Eclipse documentation):

  1. Download Bundles
  2. Trigger org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher
  3. Trigger org.eclipse.equinox.p2.publisher.CategoryPublisher

which i configured in a maven pom-file. Steps 1 and 2 are doing well whereas step 3 fails with:

Status ERROR: this code=0 publishing result null children=[Status ERROR: org.eclipse.equinox.p2.updatesite code=0 Error
generating category xml action. org.eclipse.equinox.p2.core.ProvisionException: Error reading update site file:/<path>/category.xml.]

Here is my pom.file

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001 XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <groupId>demo</groupId>
  <artifactId>simple-p2-repository</artifactId>
  <version>0.1.0-SNAPSHOT</version>
  <name>Simple p2 repository build</name>
  <packaging>pom</packaging>

  <properties>
    <tycho-version>0.18.0</tycho-version>
  </properties>

  <build>
    <plugins>
        <!-- Step 1 -->
        <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-bundles-for-publishing</id>
            <phase>process-resources</phase>
            <goals>
              <goal>copy</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>org.apache.cxf</groupId>
                  <artifactId>cxf-bundle</artifactId>
                  <version>2.7.5</version>
                </artifactItem>
              </artifactItems>
              <outputDirectory>${project.basedir}/target/source/plugins</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <!-- Step 2 -->
      <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>publish-features-and-bundles</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <compress>true</compress>
          <append>true</append>
          <publishArtifacts>true</publishArtifacts>
        </configuration>
      </plugin>
      <!-- Step3 -->
      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>tycho-p2-plugin</artifactId>
        <version>${tycho-version}</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>category-p2-metadata</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <target>${basedir}/target/repository</target>
          <categoryDefinition>${basedir}/category.xml</categoryDefinition>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

And my category.xml

<?xml version="1.0" encoding="UTF-8"?>
  <site>
    <category-def name="all" label="Maven osgi-bundles"/>
    <iu>
      <category name="all"/>
      <query>
        <expression type="match">providedCapabilities.exists(p | p.namespace == 'osgi.bundle')</expression>
     </query>
   </iu>
</site>

If i manually execute the steps the same error occurs. What am i missing?

Achim
  • 155
  • 1
  • 2
  • 11

1 Answers1

0

Although it is theoretically possible to call the low-level p2 actions via Tycho, I wouldn't recommend this approach for the problem you are trying to solve.

The artifact is already available in a Maven repository, so you can easily add it to the target platform of a Tycho build via pomDependencies=consider. Then you can for example build a p2 repository with the artifact, using Tycho's packaging type eclipse-repository.

You'll need the following POM configuration...

  ...
  <packaging>eclipse-repository</packaging>

  <dependencies>
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-bundle</artifactId>
      <version>2.7.5</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>target-platform-configuration</artifactId>
        <version>${tycho-version}</version>
        <configuration>
          <pomDependencies>consider</pomDependencies>
        </configuration>
      </plugin>
    </plugins>
  </build>

... and a category.xml which explicitly lists the bundles you want to include:

<?xml version="1.0" encoding="UTF-8"?>
<site>
   <bundle id="org.apache.cxf.bundle" version="0.0.0">
      <category name="all"/>
   </bundle>
   <category-def name="all" label="Maven osgi-bundles"/>
</site>
oberlies
  • 11,503
  • 4
  • 63
  • 110
  • The `` syntax is currently not supported in Tycho, and nobody has [requested](https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Tycho) it yet. Maybe you want to suggest this enhancement? – oberlies Jun 17 '13 at 14:33
  • Hmm, this will fail with "Missing requirement: org.apache.cxf.bundle 2.7.5 requires 'package com.ibm.wsdl.util.xml 0.0.0' but it could not be found". @Achim: Do you have any clue where this package is supposed to come from at runtime? – oberlies Jun 17 '13 at 14:39
  • The package comes from [org.apache.servicemix.bundles.wsdl4j](http://search.maven.org/#artifactdetails%7Corg.apache.servicemix.bundles%7Corg.apache.servicemix.bundles.wsdl4j%7C1.6.3_1%7Cbundle). Thanks for the hint i will give it a try and report if it works for me. – Achim Jun 18 '13 at 06:35
  • You'll also need to add the dependencies of the cxf bundle to the target platform. Tycho already checks during the build that (transitive) dependencies can be resolved - something that is needed at runtime anyway. – oberlies Jun 18 '13 at 07:38
  • I limited the dependencies/bundles in this example to keep it simple. My origin project with a bunch of bundles works fine with your approach. For the record i had to add eclipse juno repository to satisfy OSGi dependencies. Thanks! – Achim Jun 18 '13 at 08:40
  • 1
    @oberlies - I reported the IU syntax as a bug some time ago - https://bugs.eclipse.org/bugs/show_bug.cgi?id=371983 – Simon Jun 18 '13 at 13:06