diff --git a/zproject_java.gsl b/zproject_java.gsl index 969c48b4..bcccd962 100644 --- a/zproject_java.gsl +++ b/zproject_java.gsl @@ -432,13 +432,7 @@ dependencies { // Build section task copyLibs(type: Copy) { - def libraryPaths = System.getProperty('java.library.path').split(File.pathSeparator).toList() - libraryPaths.add('/usr/local/lib') - if (osdetector.os == 'windows') { - libraryPaths.add("${rootDir}/$(project.prefix:c)-jni/build/Release") - } else { - libraryPaths.add("${rootDir}/$(project.prefix:c)-jni/build") - } + def libraryPaths = [] if (project.hasProperty('buildPrefix')) { if (osdetector.os == 'windows') { // DLLs are installed to the bin directory by cmake @@ -447,6 +441,18 @@ task copyLibs(type: Copy) { libraryPaths.add("${project.buildPrefix}/lib") } + def javaLibraryPaths = System.getProperty('java.library.path').split(File.pathSeparator).toList() + libraryPaths.addAll (javaLibraryPaths) + + libraryPaths.add('/usr/local/lib') + if (osdetector.os == 'windows') { + libraryPaths.add("${rootDir}/$(project.prefix:c)-jni/build/Release") + } else { + libraryPaths.add("${rootDir}/$(project.prefix:c)-jni/build") + } + + def oldStrategy = duplicatesStrategy + duplicatesStrategy = DuplicatesStrategy.WARN libraryPaths.each { path -> from path include '$(project.libname)jni.so' @@ -462,6 +468,7 @@ task copyLibs(type: Copy) { . endfor into 'build/natives' } + duplicatesStrategy = oldStrategy } jar.baseName = "$(project.prefix:c)-jni-${osdetector.classifier}"