Eclipse plugin native libraries

(Frank San Miguel) #1


I’m building a project that requires the use of JNI (SQL Server Windows Authentication). I am using the application plugin and the eclipse plugin. I have everything working from the command line and from the install scripts, but I can’t figure out how to get the eclipse plugin to generate the correct build path (e.g. for “run as junit test” or “run as application”).

Anyone have suggestions?

Thanks, Frank

Here’s how eclipse wants it to look

Here’s the build script

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'application'
  version = '4.0-SNAPSHOT'
    configurations { nativelib }
dependencies {
   testCompile 'junit:junit:4.11'
   runtime ''
 nativelib (group: '', name: 'sqljdbc_auth', version: '4.0.1', ext: 'dll')
  ext { nativeLibs = "$buildDir/nativeLibs" }
  task copyToLib << {
 def nativeLibs = file("$buildDir/nativeLibs")
 outputs.dir nativeLibs
 configurations.nativelib.resolvedConfiguration.resolvedArtifacts.each { artifact ->
  project.copy {
   from artifact.file
   into nativeLibs
   rename { "${}.${artifact.extension}" }
  applicationDistribution.from(copyToLib) { into "nativeLibs" }
tasks.withType(Test) { systemProperty "java.library.path", nativeLibs }
tasks.withType(JavaExec) { systemProperty "java.library.path", nativeLibs }
  startScripts { defaultJvmOpts = [
 ] }


You might be able to tweak the generated eclipse project file to do what you want. Check out the Eclipse chapter of the User Guide.