Hello out there,
I have tried for the last two days to write custom plugin for gradle that internally uses the JNA Library.
The main implementation of the plugin was written for ANT so I use the AntBuilder to create the Ant Task and call it as written in the documentation.
Unfortunatly when the ant task tries to load the JNA Library I get the Error
* What went wrong:
Execution failed for task ':checkSchemaFull'.
> java.lang.Error:
There is an incompatible JNA native library installed on this system.
To resolve this issue you may do one of the following:
- remove or uninstall the offending library
- set the system property jna.nosys=true
- set jna.boot.library.path to include the path to the version of the
jnidispatch library included with the JNA jar file you are using
After some hours of debugging in the jna library I’ve found that gradle is setting the system property jna.boot.library.path
to $GRADLE_USER_HOME/native/ where the native dll (on windows) in the version 3.2.2. lives. That leads to the error in my ant task when it tries to load the 3.4.0 version of JNA, because the versions do not match.
I’ve tried setting the jna.boot.library.path from the command line and from within the gradle.properties of my project, with no success.
The only working solution is to call System.setProperty("jna.boot.library.path","")
manually before calling the ant task in my plugin and restore it after the execution.
So my questions are now:
- Is this the only solution or am I missing somewhat?
- Why does gradle sets the system property for jna.
- Is it possible to fork the ant task to a dedicated java process, so it’s save to change the system property with minimal side effect?