Eclipse plugin native libraries


(Frank San Miguel) #1

Hi,

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'
mainClassName='com.db.WriteToDb'
    configurations { nativelib }
dependencies {
   testCompile 'junit:junit:4.11'
   runtime 'com.microsoft.sqljdbc:sqljdbc4:4.0.1'
 nativelib (group: 'com.microsoft.sqljdbc.auth.x64', 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.name}.${artifact.extension}" }
  }
 }
}
  applicationDistribution.from(copyToLib) { into "nativeLibs" }
  test.dependsOn(copyToLib)
run.dependsOn(copyToLib)
tasks.withType(Test) { systemProperty "java.library.path", nativeLibs }
tasks.withType(JavaExec) { systemProperty "java.library.path", nativeLibs }
  startScripts { defaultJvmOpts = [
  "-Djava.library.path=../nativeLibs"
 ] }

#2

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.