Gradle Task Reference
All tasks live in the default Gradle task group and run in strict dependency order. They are registered only when enabled is true.
kreate-c-interop-initialize
Class: InitializeRustProject
Runs cargo new --lib <projectName> inside projectDirectory. If the target directory already exists, the task is a no-op — it will not overwrite your existing Rust source files.
Input | Description |
|---|---|
| The resolved |
| The resolved project name |
Output | Description |
|---|---|
|
|
kreate-c-interop-dependencies
Class: AddRustDependencies
Adds runtime and build dependencies to Cargo.toml via cargo add. Defaults to adding libc as a runtime dependency and cbindgen as a build dependency. Already-present dependencies are skipped automatically by checking the current Cargo.toml content before invoking cargo add.
Input | Description |
|---|---|
| The Rust project directory |
| Map of |
| Map of |
kreate-c-interop-configure
Class: ConfigureCargo
Appends the following block to Cargo.toml if not already present:
This ensures Cargo produces a static library (.a/.lib) suitable for linking into Kotlin/Native. If the block is already present, the task is a no-op.
Input | Description |
|---|---|
| The Rust project directory containing |
Output | Description |
|---|---|
|
|
kreate-c-interop-script
Class: GenerateRustBuildScript
Creates build.rs in the Rust project root. The script uses cbindgen to generate a C header at include/<projectName>.h. If build.rs already exists and is non-empty, the task is skipped.
Input | Description |
|---|---|
| The Rust project directory |
| Used as the header file name inside the generated script |
Output | Description |
|---|---|
|
|
kreate-c-interop-compile
Class: CompileRust
Executes cargo build --target <target> --release for each resolved Rust target in sequence. If compilation fails for any target, a GradleException is thrown immediately with the failing target name.
Input | Description |
|---|---|
| The Rust project directory |
| Optional; resolved from config or auto-detected from host OS/arch |
Output | Description |
|---|---|
|
|
kreate-c-interop-definitions
Class: GenerateDefinitionFiles
Creates the directory specified by defDirName and writes the .def file consumed by CInteropProcess. The file references the compiled static library and the generated C header. This task always rewrites the .def file — it is not incrementally skipped.
Input | Description |
|---|---|
| The Rust project directory |
| The |
| Used in header and library names |
| File name for the |
| Directory name for the |
| Optional; used to construct the |
Output | Description |
|---|---|
|
|