Skip to content

Commit 807dd84

Browse files
committed
Problem: Compilation fails on CentOS, due to duplicate lib entry.
ZYRE compilation started for Android, with a similar script to zyre/bingings/jni/ci_build.sh. Compilation ends with: ``` > Task :czmq-jni-native:classes UP-TO-DATE Skipping task ':czmq-jni-native:classes' as it has no actions. :czmq-jni-native:classes (Thread[Execution worker for ':',5,main]) completed. Took 0.0 secs. :czmq-jni-native:copyLibs (Thread[Execution worker for ':',5,main]) started. > Task :czmq-jni-native:copyLibs FAILED Caching disabled for task ':czmq-jni-native:copyLibs' because: Build cache is disabled Task ':czmq-jni-native:copyLibs' is not up-to-date because: No history is available. file or directory '/usr/java/packages/lib', not found :czmq-jni-native:copyLibs (Thread[Execution worker for ':',5,main]) completed. Took 0.062 secs. FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':czmq-jni-native:copyLibs'. > Entry libcurl.so is a duplicate but no duplicate handling strategy has been set. Please refer to https://docs.gradle.org/7.4.2/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy for details. * Try: > Run with --stacktrace option to get the stack trace. > Run with --debug option to get more log output. > Run with --scan to get full insights. * Get more help at https://help.gradle.org ``` Investigation have shown 2 things: - On CentOS, /lib and /lib64 point to /usr/lib and /usr/lib64: ``` prompt> ls -ald /lib /lib64 lrwxrwxrwx. 1 root root 7 12 janv. 2020 /lib -> usr/lib lrwxrwxrwx. 1 root root 9 12 janv. 2020 /lib64 -> usr/lib64 prompt> ``` - Since Gradle 7, one has to set a duplicate strategy, when using copyLibs: gradle/gradle#17236 Solution: Set duplicate strategy to warn, not to stop the build. Additionnally, add libraries found in $BUILD_PREFIX first, then, the system ones, in case one wants to have his own library version in the JAR. This fixes CZMQ issue zeromq/czmq#2231
1 parent 4d393c8 commit 807dd84

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

zproject_java.gsl

+14-7
Original file line numberDiff line numberDiff line change
@@ -432,13 +432,7 @@ dependencies {
432432
// Build section
433433

434434
task copyLibs(type: Copy) {
435-
def libraryPaths = System.getProperty('java.library.path').split(File.pathSeparator).toList()
436-
libraryPaths.add('/usr/local/lib')
437-
if (osdetector.os == 'windows') {
438-
libraryPaths.add("${rootDir}/$(project.prefix:c)-jni/build/Release")
439-
} else {
440-
libraryPaths.add("${rootDir}/$(project.prefix:c)-jni/build")
441-
}
435+
def libraryPaths = []
442436
if (project.hasProperty('buildPrefix')) {
443437
if (osdetector.os == 'windows') {
444438
// DLLs are installed to the bin directory by cmake
@@ -447,6 +441,18 @@ task copyLibs(type: Copy) {
447441
libraryPaths.add("${project.buildPrefix}/lib")
448442
}
449443

444+
def javaLibraryPaths = System.getProperty('java.library.path').split(File.pathSeparator).toList()
445+
libraryPaths.addAll (javaLibraryPaths)
446+
447+
libraryPaths.add('/usr/local/lib')
448+
if (osdetector.os == 'windows') {
449+
libraryPaths.add("${rootDir}/$(project.prefix:c)-jni/build/Release")
450+
} else {
451+
libraryPaths.add("${rootDir}/$(project.prefix:c)-jni/build")
452+
}
453+
454+
def oldStrategy = duplicatesStrategy
455+
duplicatesStrategy = DuplicatesStrategy.WARN
450456
libraryPaths.each { path ->
451457
from path
452458
include '$(project.libname)jni.so'
@@ -462,6 +468,7 @@ task copyLibs(type: Copy) {
462468
. endfor
463469
into 'build/natives'
464470
}
471+
duplicatesStrategy = oldStrategy
465472
}
466473

467474
jar.baseName = "$(project.prefix:c)-jni-${osdetector.classifier}"

0 commit comments

Comments
 (0)