spring boot - Gradle: Fail on adding systemProperty -
i'm trying add .dll file "java.library.path" system property via gradle on spring boot project. i'm using gradle 2.1 on sts. small piece of groove code within build.gradle:
tasks.withtype(javacompile) { systemproperty "java.library.path", file("./src/main/resources/meta-inf/opencv-2.4.9/windows_bin/x64") }
and i'm getting following error:
could not find method systemproperty() arguments [java.library.path,
d:\github\tfg_1\guiatv\src\main\resources\meta-inf\opencv-2.4.9\windows_bin\x64] on root project 'guiatv'
that path exists, don't know problem is.
any help? thank you!
update 1:
@amnon shochot try add native library (.dll) project. took idea sites (for example, http://zouxifeng.github.io/2014/07/17/add-system-property-to-spring-boot.html, https://github.com/cjstehno/coffeaelectronica/wiki/going-native-with-gradle).
the first 1 using suggested:
tasks.withtype(javaexec) { systemproperty "java.library.path", file("./libs") }
the second 1 using:
run { systemproperty 'java.library.path', file( 'build/natives/windows' ) }
none of them working me. first 1 (with javaexec) failing gradle test throwing:
java.lang.unsatisfiedlinkerror: no opencv_java249 in java.library.path @ java.lang.classloader.loadlibrary(classloader.java:1865) @ java.lang.runtime.loadlibrary0(runtime.java:870)
if follow trace, it's crashing @ runtime in sentence: system.loadlibrary(core.native_library_name);
and second 1 failing on gradle build following message:
could not find method run() arguments [build_24sfpo0st6dokeq7fn3ad7r34$_run_closure7@2652c3da] on root project 'guiatv'.
luckily know try achieve , can solve problem.
thank interest!
update 2:
finally, ended adding these lines build.gradle script:
// following makes "gradle build", "gradle test" work test { jvmargs = ['-djava.library.path=./src/main/resources/meta-inf/opencv-2.4.9/windows_bin/x64'] } // thw following makes "gradle run" work run { jvmargs = ['-djava.library.path=./src/main/resources/meta-inf/opencv-2.4.9/windows_bin/x64'] }
by way, i'm using "spring-boot" gradle plugin. that's run task comes from. so, can execute "gradle build", "gradle test" , "gradle run" sucessfully. is, native library correctly added. however, since i'm using "eclipse" gradle plugin, add native library executing "gradle eclipse". instead, must create library on eclipse manually, , add project.
thank @amnon collaboration. i'll posting new solution in case found it.
the problem not set context systemproperty
method gradle tries locate in project
object not exist reason error got.
if wanted apply configuration tasks of type javacompile
code should have been looked like:
tasks.withtype(javacompile) { javacompile t -> t.systemproperty "java.library.path", file("./src/main/resources/meta-inf/opencv-2.4.9/windows_bin/x64") }
however, javacompile
task type not contain systemproperty
code wouldn't work either.
you can define compileoptions
javacompile
task using options
property, i.e.:
tasks.withtype(javacompile) { javacompile t -> t.options "java.library.path", file("./src/main/resources/meta-inf/opencv-2.4.9/windows_bin/x64") }
however, i'm not sure whether can define specific system property.
one last note - systemproperty
method exist tasks of type javaexec
in case intended do.
Comments
Post a Comment