Proper way to use native libs in build logic

We have been using Gradle since before it supported building native binaries, so we wrote the build logic ourselves. Now I’m wondering how hard it would be to move to the (by now) built-in Gradle plugin.

We have build logic that uses the output of the compiled native (and java) binaries of it’s own build: We have some low level components, with native code, and java (JNI) wrappers around it. We build those first, and can then use it to build other artifacts.

Now, my question: What’s the proper way of putting the libs, output by the c and cpp plugins on one subproject, on PATH (on Windows) or LD_LIBRARY_PATH (on *nix) of another sub project?

Are you saying that you build a native library + Java JNI wrapper over it and then use it for another part of your build (e.g., to generate source code or as part of tests)?

Or are you saying that you build a native library and need to use it to link with another, different native library?

I’ll need to do both, but my main question was about the first: How to reference the libs for generating code.