Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [tycho-user] Important change merged into 2.3.0-SNAPSHOT, please try!

I just tested the Tycho 2.3.0-SNAPSHOT with our build and encountered problems with platform-specific fragments that use a Bundle-NativeCode header with osname-parameter a in their MANIFEST.MF.
Resolving the class path fails for the platform-specific fragment for the OS that is not the one running.
 
To ship native-libraries we have a plugin and two fragments that contain the native-libraries, one for windows (containing .dll files) and one for linux (containing .so files).
Our build materializes two products (one for windows and one for linux).
 
The (stipped) META-INF/MANIFEST.MF of the windows-fragment looks like this:
"""
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: de.foo.bar.win32.win32.x86_64
Bundle-Version: 1.0.0.qualifier
Fragment-Host: de.foo.bar
Bundle-RequiredExecutionEnvironment: JavaSE-11
Eclipse-PlatformFilter: (& (osgi.os=win32) (osgi.ws=win32) (osgi.arch=x86_64))
Bundle-NativeCode:
  /lib/libFile.dll;
  osname=win32; processor=x86_64
"""
 
The (stipped) META-INF/MANIFEST.MF for linux looks like this:
"""
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: de.foo.bar.linux.gtk.x86_64
Bundle-Version: 1.0.0.qualifier
Fragment-Host: de.foo.bar
Bundle-RequiredExecutionEnvironment: JavaSE-11
Eclipse-PlatformFilter: (& (osgi.os=linux) (osgi.ws=gtk) (osgi.arch=x86_64))
Bundle-NativeCode:
  /lib/libFile.so;
  osname=linux; processor=x86_64
"""
 
 
When I run the Maven-Build on windows the build now fails with the following error messages (it works fine with Tycho-2.2.0):
 
[INFO] Resolving class path of MavenProject: de.foo:de.foo.bar.linux.gtk.x86_64:1.0.0-SNAPSHOT @ C:\dev\git\bar\plugins\3rdParty\de.foo.bar.linux.gtk.x86_64\.polyglot.META-INF
[ERROR] Internal error: java.lang.RuntimeException: org.osgi.framework.BundleException: Bundle de.foo.bar.linux.gtk.x86_64 cannot be resolved:de.foo.bar.linux.gtk.x86_64 [17]
[ERROR]   Unresolved requirement: Require-Capability: osgi.native; native.paths:List<String>="/lib/libFile.so"; filter:="(&(osgi.native.osname~=linux)(osgi.native.processor~=x86_64))"
[ERROR] -> [Help 1]
org.apache.maven.InternalErrorException: Internal error: java.lang.RuntimeException: org.osgi.framework.BundleException: Bundle de.foo.bar.linux.gtk.x86_64 cannot be resolved:de.foo.bar.linux.gtk.x86_64 [17]
  Unresolved requirement: Require-Capability: osgi.native; native.paths:List<String>="/lib/libFile.so"; filter:="(&(osgi.native.osname~=linux)(osgi.native.processor~=x86_64))"
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:120)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
Caused by: java.lang.RuntimeException: org.osgi.framework.BundleException: Bundle de.foo.bar.linux.gtk.x86_64 cannot be resolved:de.foo.bar.linux.gtk.x86_64 [17]
  Unresolved requirement: Require-Capability: osgi.native; native.paths:List<String>="/lib/libFile.so"; filter:="(&(osgi.native.osname~=linux)(osgi.native.processor~=x86_64))"
    at org.eclipse.tycho.core.osgitools.OsgiBundleProject.getResolverState(OsgiBundleProject.java:282)
    at org.eclipse.tycho.core.osgitools.OsgiBundleProject.resolveClassPath(OsgiBundleProject.java:175)
    at org.eclipse.tycho.core.resolver.DefaultTychoResolver.resolveProject(DefaultTychoResolver.java:142)
    at org.eclipse.tycho.core.maven.TychoMavenLifecycleParticipant.lambda$resolveProjects$0(TychoMavenLifecycleParticipant.java:127)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
    at java.base/java.util.stream.WhileOps$1$1.accept(WhileOps.java:99)
    at java.base/java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1632)
    at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
    at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
    at org.eclipse.tycho.core.maven.TychoMavenLifecycleParticipant.resolveProjects(TychoMavenLifecycleParticipant.java:158)
    at org.eclipse.tycho.core.maven.TychoMavenLifecycleParticipant.afterProjectsRead(TychoMavenLifecycleParticipant.java:102)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:264)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
    ... 11 more
Caused by: org.osgi.framework.BundleException: Bundle de.foo.bar.linux.gtk.x86_64 cannot be resolved:de.foo.bar.linux.gtk.x86_64 [17]
  Unresolved requirement: Require-Capability: osgi.native; native.paths:List<String>="/lib/libFile.so"; filter:="(&(osgi.native.osname~=linux)(osgi.native.processor~=x86_64))"
    at org.eclipse.tycho.core.osgitools.EquinoxResolver.assertResolved(EquinoxResolver.java:384)
    at org.eclipse.tycho.core.osgitools.EquinoxResolver.newResolvedState(EquinoxResolver.java:127)
    at org.eclipse.tycho.core.osgitools.OsgiBundleProject.getResolverState(OsgiBundleProject.java:279)
    ... 30 more
 
 
I could make our build work by removing the environment attributes in the Bundle-NativeCode header.
This should not be a problem for us, because only the platform-specific fragment for the corresponding platform should be present in each build product due to the Eclipse-PlatformFilter, so this attribute was kind of redundant anyways.
But maybe this isn't feasibil for others.
 
 
From the specification I take that the installation should fail only if no clause matches the current environment:
https://docs.osgi.org/specification/osgi.core/8.0.0/framework.module.html#framework.module-loading.native.code.libraries
 
So this problem shouldn't occur if multiple clauses for different platforms are specified, as long as one matches the running environment.
 
 
A solution to make it work without removing the environment-attributes could be to append the optional-clause virtually when resolving the bundles at build-time.
The specification says about the optional "*" in conjunction with using the Wiring-API:
"If the optional '*' is specified at the end of the Bundle-NativeCode manifest header, then the native code for the bundle is considered to be optional. When the Framework converts a Bundle-NativeCode header into an osgi.native requirement which is designated as optional then the requirement resolution directive must be set to optional"
 
Maybe Tycho could do this to build each fragment on each platform?
 

Back to the top