How can I set up a simple gradle project that uses sqlite4java?

后端 未结 4 1081
粉色の甜心
粉色の甜心 2020-12-20 12:08

I\'m starting a simple java test project using sqlite4java and building using java.

I can get the core sqlite4java library downloaded easily, but I\'m not sure what

4条回答
  •  情深已故
    2020-12-20 12:43

    I suppose, you need to use additional gradle plugin to handle native libraries or make your own specific tasks, to upload and put native libs in right place, in order to they could be found and linked.

    At the moment I know only about one such a plugin, hope it can solve your problem https://github.com/cjstehno/gradle-natives

    Edit: The problem with plugin in your case is the fact, that your dependecny "com.almworks.sqlite4java:libsqlite4java-osx:1.0.392" is native lib by itself, not a jar with included native lib as I supposed. So, in that case, you can simply add this dependency in dependencies par of build script, as it'a already done, and then create a custom copy task, to put it in any place you need. Tried to do it with gradle 2.6 on Win7, look like:

    task copyNtiveDeps(type: Copy) {
      from (configurations.compile+configurations.testCompile) {
        include "libsqlite4java-osx-1.0.392.dylib"
      }
      into "c:\\tmp"
    }
    

    In your case, you just need to set "into" property to some path from java.library.path. And the second, you can make this task runs automaticaly with gradle task properties dependsOn and mustRunAfter.

提交回复
热议问题