Adding a JNI library to the local Maven Repository

后端 未结 3 1780
盖世英雄少女心
盖世英雄少女心 2021-02-04 02:52

I wish to add a JNI library, including its shared object (.so) file to my project using Maven. Unfortunately it is not yet on a public repository so I guess I have to install it

3条回答
  •  心在旅途
    2021-02-04 03:38

    My approach:

    Put .so files to repository with platform specific classifier, like this: sqlite3-3.7.9-linux-x86_64.so. Add .so dependencies for all required platforms:

    
        de.ch-werner
        sqlite-jdbc
        3.7.9
        so
        linux-x86_64
    
    

    Use this maven assembly plugin config to put all native libs into lib/native directory of you dist:

    
        lib/native
        ${artifact.artifactId}${dashClassifier?}.${artifact.extension}
        false
        false
        false
        
            *:*:dll:*
            *:*:so:*
            *:*:jnilib:*
        
        
    

    Use this class to load libs on app startup (planning to change classifier naming to GNU triplets):

    CtzJniUtils.loadJniLibsFromStandardPath(Launcher.class, "sqlite3")
    

提交回复
热议问题