I have actualised the sample given on IDEA website's guide on JNI in this [repo](https://github.com/lilvadim/GradleJniSample) (you can see fork there) and now it runs with modern JDK and JUnit Tests even on my aarch64 Mac (hope it runs anywhere else). But I do not really understand what is going on in `build.gradle` in `hello` Gradle subproject folder. I can recognise compiler arguments there, but include options are set in separate methods, which gets me confused.

My aim is to have just wrapper C-file that doing `dlopen`(or its Windows' alternative) and runs some function from dynamic library.

E.g.

```
<ProjectRoot>/hello/src/main/c/ wrapper-with-JNI-call-convensions.c 
                                libsomelib.dylib
                                libsomelib.so
                                somelib.dll

Calls looks like this: Java -[JNI]-> wrapper.dll -> somelib.dll
                                     ^    ^    ^
                                     |    |    |
                         building wrapper.c using Gradle to this

```

So I have successfully managed to get JNI working (while not changing `build.gradle` from sample) if I just run build with two C source files (wrapper that uses JNI and C source code of my library). Then I built `dylib` using macOS built-in `clang` compiler and wrote proper (I guess) `dlopen` and `dlsym` code. But when I build project I get NULL returned from `dlopen` call.

I have tried to add some arguments to the `build.gradle` that used to compile binary that uses dynamic library, but it did not help.

My test running exits here:

```
// my wrapper
void* dlHandle = dlopen("libsomelib.dylib", RTLD_LAZY);
    if (dlHandle == NULL) {
        printf("DLL NOT OPENED !!!\n");
        exit(0);
    }

```

I know I have to write proper platform-dependent calls in my wrapper, it's not a big deal for me.

So can you tell me how I can properly get this working using Gradle? Remember that goal is to have just JNI-ready `*.c` wrapper and just dynamic linked libraries `*.so & *.dylib & *.dll` in my case.

**Update:** I've decided not to use Gradle, I use VSCode `tasks.json`, it is like 20 times more intuitive. I will write my approach as self-answer.