Found the solution on this thread: https://discuss.gradle.org/t/is-it-possible-to-set-eclipses-java-library-path-from-build-gradle/6511/6
Adding the following code to my gradle build file and re-running gradle eclipse
solved the issue:
build.gradle:
def getSqlLite4JavaNativeLibraryPath() {
return configurations.runtime.resolve().findResult { entry ->
String absolutPath = entry.getAbsolutePath();
if(absolutPath.contains("sqlite4java-win32-x64")){
// return the directory that contains the native library
return entry.getParent()
}
}
}
eclipse.classpath.file.whenMerged { classpath ->
//remove the all native libraries as direct dependencies
classpath.entries.removeAll {
entry -> entry.kind == 'lib' && (entry.path.endsWith('.dll')
|| entry.path.endsWith('.so')
|| entry.path.endsWith('.dylib'))
}
//but add them as native libraries
def sqlite4java = classpath.entries.findResult { entry ->
if (entry.kind == 'lib' && entry.path.contains('sqlite4java')) {
return entry
}
}
sqlite4java.setNativeLibraryLocation(getSqlLite4JavaNativeLibraryPath())
}
The generated .classpath file now contains the attributes for the native library directory.
.classpath:
<classpathentry sourcepath="C:/Users/user1/.gradle/caches/modules-2/files-2.1/com.almworks.sqlite4java/sqlite4java/1.0.392/2efe18f7bea6fa9536802dd4ea54d948117216c6/sqlite4java-1.0.392-sources.jar" kind="lib" path="C:/Users/user1/.gradle/caches/modules-2/files-2.1/com.almworks.sqlite4java/sqlite4java/1.0.392/d6234e08ff4e1607ff5321da2579571f05ff778d/sqlite4java-1.0.392.jar" exported="true">
<attributes>
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="C:\Users\user1\.gradle\caches\modules-2\files-2.1\com.almworks.sqlite4java\sqlite4java-win32-x64\1.0.392\d20dc00abecc7e0bde38c68eee68f2e70c26df95"/>
</attributes>
</classpathentry>
I also ran into the problem that the gradle unit tests were failing to load the sqlite4java native libraries, so I also needed to add the following to my gradle test target so that the tests run from gradle would be able to load the sqlite4java native libraries.
test {
systemProperty "sqlite4java.library.path", getSqlLite4JavaNativeLibraryPath()
}