Loading native dll within a Gradle PlugIn

Hello,
my team works on a Gradle PlugIn with a custom task that uses the Google ORTools library. Therefore we try to load the native jniortools.dll when executing the task.
The dll file is located in a folder that is part of the java library path.

There is no exception when calling: System.loadLibrary(“jniortools”);
Just to be sure, when I remove the related location from java library path I get the expected exception:
java.lang.UnsatisfiedLinkError: no jniortools in java.library.path

However, when the dll is loaded and I try to use ORTools Classes then there is always this exception:
java.lang.UnsatisfiedLinkError: rel.com.google.ortools.util.mainJNI.new_Domain__SWIG_1(J)J

When I execute the same code in a normal Java main function, there is no problem and everything works fine.
Do I have to consider anything when loading dlls within a Gradle PlugIn?

Update:
It turned out that the reason for the UnsitisfiedLinkError is in our build setup. We create a fat jar containing third party libraries, but they are relocated to another package. That is the reason why the native methods from the dll are not correctly linked to the Java Methods. After we disabled relocation for ORTools it worked.

Dear Andreas,

could you explain in more detail how you managed to integrate ortools in gradle?

So far, I managed to install ortools-java and ortools-darwin in my mavenLocal with the corresponding pom files (https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html) and add it to the dependencies in my build.gradle like this:

repositories {
    mavenLocal()
}

dependencies {
   api 'com.google.ortools:ortools-java:8.0.8283' // installed on maven local
}

Since ortools-java and ortools-darwin have the correct pom files, e.g. protobuf is included by gradle automatically.

What am I missing to also include this jniortools?

Thanks,
Chris