Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing libraries in final package #1028

Closed
haifengl opened this issue Sep 5, 2017 · 7 comments
Closed

missing libraries in final package #1028

haifengl opened this issue Sep 5, 2017 · 7 comments
Labels
bug documentation Documentation should be extended or updated universal Zip, tar.gz, tgz and bash issues

Comments

@haifengl
Copy link

haifengl commented Sep 5, 2017

Expected behaviour

Our project smile reply on sbt and sbt-native-packager for buidling and packaging. The module netlib depends on the third party library netlib-java. When we use

"com.github.fommil.netlib" % "all"                  % "1.1.2" pomOnly()

the build is successful and all depended libraries are packaged into lib directory. Note that "all" is a pom only dependency and will include many libraries that we don't need. So we try to include only the libraries that we need as following:

libraryDependencies ++= Seq(
  "com.github.fommil.netlib" % "netlib-native_system-linux-x86_64" % "1.1",
  "com.github.fommil.netlib" % "netlib-native_system-win-x86_64"   % "1.1",
  "com.github.fommil.netlib" % "netlib-native_system-osx-x86_64"   % "1.1",
  "com.github.fommil.netlib" % "native_system-java"                % "1.1",
  "com.github.fommil.netlib" % "core"                              % "1.1.2",
  "com.github.fommil"        % "jniloader"                         % "1.1"
)

run sbt stage and check the target lib directory, the jar files of netlib-native_system-linux-x86_64, netlib-native_system-win-x86_64, and netlib-native_system-osx-x86_64 are missing.

Actual behaviour

Missing libraries in lib directory.

Information

  • What sbt-native-packager are you using
    1.2.1

  • What sbt version
    0.13.16

  • What is your build system (e.g. Ubuntu, MacOS, Windows, Debian )
    MacOS

  • What package are you building (e.g. docker, rpm, ...)
    Universal Package .tgz

  • What version has your build tool (find out with e.g. rpm --version)
    N/A

  • What is your target system (e.g. Ubuntu 16.04, CentOS 7)
    Universal package (most development on macOS 10.12 Sierra, test on CentOS 7 and Windows 10 too)

@muuki88 muuki88 added bug universal Zip, tar.gz, tgz and bash issues documentation Documentation should be extended or updated labels Sep 6, 2017
@muuki88
Copy link
Contributor

muuki88 commented Sep 6, 2017

Thanks for your bug report. I'm pretty sure it relates to this todo.

The issue is that the native dependencies doesn't have jar classifier, but something else.

However we have a workaround for this issue. Use the MappingsHelper#fromClasspath method. See the scaladocs

So you need to add something like

mappings in Universal ++= fromClasspath(
  (managedClasspath in Runtime).value,
  "lib",
  artifact => artifact.`type` == "native" // what ever the type is
)

@haifengl
Copy link
Author

haifengl commented Sep 6, 2017

Thanks! I will try the work around. But the native packages do have .jar files here. Do I misunderstand the todo?

@haifengl
Copy link
Author

haifengl commented Sep 7, 2017

Can you please provide the complete example? I tried the following

import NativePackagerHelper._

name := "smile-netlib"

// work around with sbt-native-packager handling of native packages.
mappings in Universal ++= fromClasspath(
    (managedClasspath in Runtime).value,
    "lib",
    artifact => artifact.`type` == "native"
  )

libraryDependencies ++= Seq(
  "com.github.fommil.netlib" % "netlib-native_ref-linux-x86_64"    % "1.1",
  "com.github.fommil.netlib" % "netlib-native_ref-win-x86_64"      % "1.1",
  "com.github.fommil.netlib" % "netlib-native_ref-osx-x86_64"      % "1.1",
  "com.github.fommil.netlib" % "netlib-native_system-linux-x86_64" % "1.1",
  "com.github.fommil.netlib" % "netlib-native_system-win-x86_64"   % "1.1",
  "com.github.fommil.netlib" % "netlib-native_system-osx-x86_64"   % "1.1",
  "com.github.fommil.netlib" % "native_ref-java"                   % "1.1",
  "com.github.fommil.netlib" % "native_system-java"                % "1.1",
  "com.github.fommil.netlib" % "core"                              % "1.1.2",
  "com.github.fommil"        % "jniloader"                         % "1.1",
  "net.sourceforge.f2j"      % "arpack_combined_all"               % "0.1"
)

But I got the error:

Reference to undefined setting: 

  netlib/universal:mappings from netlib/universal:mappings (/Users/hli/github/smile/netlib/build.sbt:6)
 
	at sbt.Init$class.Uninitialized(Settings.scala:270)
	at sbt.Def$.Uninitialized(Def.scala:10)
	at sbt.Init$class.delegate(Settings.scala:191)
	at sbt.Def$.delegate(Def.scala:10)
	at sbt.Init$class.compiled(Settings.scala:138)
	at sbt.Def$.compiled(Def.scala:10)
	at sbt.Init$class.make(Settings.scala:144)
	at sbt.Def$.make(Def.scala:10)
	at sbt.Load$$anonfun$8.apply(Load.scala:161)
	at sbt.Load$$anonfun$8.apply(Load.scala:156)
	at sbt.Load$.timed(Load.scala:1025)
	at sbt.Load$.apply(Load.scala:156)
	at sbt.Load$.defaultLoad(Load.scala:39)
	at sbt.BuiltinCommands$.liftedTree1$1(Main.scala:503)

Thanks!

@muuki88
Copy link
Contributor

muuki88 commented Sep 7, 2017

Undefined setting means something is not yet intitialized. Where are you enabling native packer in your example?

@haifengl
Copy link
Author

haifengl commented Sep 7, 2017

This module is not the main module/entry of the application. I move the workaround code to the main module build.sbt but it doesn't solve the problem. The native libraries are still missing.

@haifengl
Copy link
Author

haifengl commented Mar 28, 2020

This can be resolved by adding classifier "natives" to native dependency.

@muuki88
Copy link
Contributor

muuki88 commented Apr 2, 2020

Thanks for sharing @haifengl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug documentation Documentation should be extended or updated universal Zip, tar.gz, tgz and bash issues
Projects
None yet
Development

No branches or pull requests

2 participants