Search code examples
maventycho

Tycho: 'Export-Package' gets deleted from MANIFEST.MF


We are migrating our build system from Ant to Maven, and I'm currently working on building Eclipse plug-ins. After doing some research, I decided to use Tycho Maven plug-in to do the builds. It was not straightforward, but I solved most of issues except of this one.

I got errors when tried to build dependent plug-ins. Consider I have some plug-in A, and a plug-in B which depends on A (uses classes from A). Both those plug-ins are manifest-first (and have <packaging>eclipse-plugin</packaging>).

When I tried to build 'B', I got the following build error:

[ERROR] Access restriction: The type Constants is not accessible due to restriction on class pathentry C:/maven/repository/...

I checked everything number of times, but only later I realised that I should take a look at the MANIFEST.MF of A.jar in my repository,- and that was the case. Export-Package for some reason was removed from MANIFEST-MF of plugin A. I manually added the missing exports to MANIFEST.MF in local Maven repository (just in order to make sure it's the real problem!), and the build of plug-in B succeeded!

So the question is: how to configure Tycho not to remove Export-Package in plug-ins that are built (or configuring which packages should be exported)?


Solution

  • Turned out that Tycho relied on order of MANIFEST.MF properties. In my case, Export-Package was placed after Import-Package, and in this case Tycho discarded the whole Export-Package property when building a plug-in and re-generating MANIFEST.MF. As soon as Export-Package was placed before Import-Package, everything worked fine and target MANIFEST.MF was generated as expected. Tycho version tried: 0.14.0, 0.14.1

    EDIT

    The bug was reported on Eclipse Bugzilla: 'Export-Package' gets removed from target MANIFEST.MF when located after 'Import-Package' in provided MANIFEST.MF

    EDIT2

    See details on bug submitted. The true reason was a missing line break,- which formally is a manifest error. Tycho ignored last line during parse, and thus Export-Package, which was the last line, was not included in a target manifest.