Using the c plugin, one can specify executables and libraries. I'm using a string tag to specify a library with an OS specific name (later used in a JNI setup).
import org.apache.commons.lang3.SystemUtils as SU
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.apache.commons:commons-lang3:3.3.2'
}
}
def osString = SU.IS_OS_LINUX ? "linux" : (SU.IS_OS_MAC_OSX ? "macosx" : SU.IS_OS_WINDOWS ? "windows" : "")
assert osString
That is to get the OS string. Here the declaration of the library:
libraries {
"diaf-${osString}" {}
}
When running
gradle tasks
on a linux box, one of the tasks will be "diaf-linuxSharedLibrary"
How does one get a handle to the output file of the task (to be used in another task)? In this case libdiaf-linux.so? Without resorting to hard coded paths as in
def path = "${buildDir}/build/binaries/diaf-linuxSharedLibrary/libdiaf-linux.so"
?