Eclipse RCP built by Tycho includes unwanted optional dependencies
Asked Answered
D

2

7

This is a question which has been frequently asked in the Tycho community:

I migrated my Eclipse RCP build from [previous technology, e.g. eclipse-application/ PDE headless build / ...] to the new recommended way of building products with Tycho using the packaging type eclipse-repository. Now my distribution contains more bundles than before.

The problem seems to be that Tycho pulls in the optional dependencies of the bundles included in my product. How can I prevent this?

Draw answered 11/9, 2012 at 14:40 Comment(0)
D
10

Tycho's eclipse-repository packaging type builds product distributions with the same technology (called p2) you also use when, for example, installing a new feature into your Eclipse IDE. This has the advantage that, unlike with other build technologies, you don't need to manually specify all dependencies of the bundles you want in your product, but Tycho/p2 will automatically include them for you. (This is important because otherwise the bundles would not start at runtime.)

On the other hand, this may also be a disadvantage: Tycho/p2 also includes certain optional dependencies that you would rather want to exclude from your product.

There is no option to tell Tycho to not include any optional dependencies (because p2 doesn't have this option). However you can identify the optional bundles you don't want, and explicitly exclude them from the target platform with the following configuration:

<plugin>
   <groupId>org.eclipse.tycho</groupId>
   <artifactId>target-platform-configuration</artifactId>
   <version>${tycho-version}</version>
   <configuration>
      <filters>
         <filter>
            <type>eclipse-plugin</type>
            <id>unwanted.bundle.id</id>
            <removeAll />
         </filter>
      </filters>
   </configuration>
</plugin>

Then the product build can no longer see the excluded bundle, and will omit it from the installation.

Note: If you get a dependency resolution error after adding the above configuration, there is something that non-optionally requires the bundle. Although it is a bit tricky to read, the error message will tell you the chain of dependencies that leads from something you are building to the removed bundle.

Draw answered 11/9, 2012 at 14:40 Comment(0)
V
1

I stumbled upon this answer to exclude com.ibm.icu from my RCP build and wanted to post an update.

Tycho can be configured to ignore optional dependencies since a while, see https://wiki.eclipse.org/Tycho/Release_Notes/0.14

<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tychoVersion}</version>
<configuration>
  <dependency-resolution>
    <optionalDependencies>ignore</optionalDependencies>
  </dependency-resolution>
</configuration>
Vite answered 12/4, 2021 at 12:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.