Task jni

Build a JNI-based native library. The native library is created by compiling a designated set of C[-compatible] source files and linking them together.

This task is currently specific to macOS. It generates a universal library, if required.

Properties

Property Description Type
jniVisibility Specifies a default value for the visibility parameter. String
jniIncludePath Specifies a default value for the includePath parameter. Path

References

Reference Description Type
jni.default.targets Refers to a set of targets that create JNI libraries. These targets are invoked by the JavaLibrary task after the native header files are generated and before the generated native libraries are packaged into the library JAR. TargetContainer

Parameters accepted as attributes

Attribute Description Type Required?
sourceRef The ID of a resource collection that identifies source files to be compiled. Reference No.
includePath Specify a search path for header files. Path No. If not defined, the value of the jniIncludePath property is used.
libraryPath Specify a search path for required dynamic libraries. Path No. If not defined, a default path is used.
outputFile The location where the native library is written. String Yes.
installDir An additional location where the native library should be installed. String No.
visibility The linker visibility option. The only available option is hidden, which indicates that symbols not marked for export are unavailable to other libraries. String No. If not specified, defaults to the value of the jniVisibility property. If that property is not defined, visibility of symbols is not restricted.
installName Specifies the install name for the library. This is a path that will be attached to clients when they link against this library. The path may be used by the dynamic linker at runtime to locate the library. String No. If not specified, defaults to the path where the library is written.
version Specifies the library version number to install in the library. See the documentation of ld for details. String No.
compatibilityVersion Specifies the library compatibility version number to install in the library. See the documentation of ld for details. String No.
debugOption The debug option passed to the native compiler. String No.
compiler The location of the native compiler. String No. If not specified, some standard locations will be searched.
dSymUtil The location of the dsymutil program. This program is used to create a debugging symbol bundle for the library. String No. If not specified, some standard locations will be searched.

Parameters accepted as nested elements

Option library ...

Specify a required native library. The value should be a library name or a Maven repo artifact key.

Example:

<library>VAqua</library>
<library value="org.jetbrains:annotations"/>

Option framework ...

Specify a required Framework. The value should be the framework name.

Example:

<framework>Cocoa</framework>
<framework value="Cocoa"/>

Option compilerOption ...

Specify an option to be passed to the native compiler.

Option warningOption ...

Specify an option to be passed to the native compiler.

Option linkerOption ...

Specify an option to be passed to the native linker.

ResourceCollection ...

Specify source files for the native library.

Target ...

Specify a target architecture that the native library should support.