Pick up native JNI files in Maven test (lwjgl)

后端 未结 3 1398
时光说笑
时光说笑 2021-01-01 02:08

I\'m creating a program with LWJGL and Maven, and I\'m writing unit tests for the graphical code. My problem is getting Maven to put the native binaries on the classpath so

3条回答
  •  离开以前
    2021-01-01 02:38

    According to http://maven.40175.n5.nabble.com/Trouble-with-Java-Native-Libraries-td114063.html,

    the surefire plugin starts the VM and then modifies the system properties before passing control to the junit test classes. This is too late for the VM, which needs to have the java.library.path set up at the time the VM is initialized.

    So we need to give the path to Surefire at startup. The following worked:

            
                org.apache.maven.plugins
                maven-surefire-plugin
                
                    once
                    -Djava.library.path=${project.build.directory}/libs/natives/win32:${project.build.directory}/libs/natives/linux:${project.build.directory}/libs/natives/macosx:${project.build.directory}/libs/natives/solaris
                
            
    

提交回复
热议问题