{"id":25603256,"url":"https://github.com/sayaka-sh/KJna","last_synced_at":"2026-06-22T19:01:15.025Z","repository":{"id":241522122,"uuid":"804979600","full_name":"sayaka-sh/KJna","owner":"sayaka-sh","description":"This project has been moved to GitLab","archived":true,"fork":false,"pushed_at":"2024-07-23T19:06:39.000Z","size":205,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-05-11T21:47:03.398Z","etag":null,"topics":["binding","binding-generator","cinterop","jextract","kotlin-multiplatform","kotlin-native"],"latest_commit_sha":null,"homepage":"https://gitlab.com/toasterofbread/kjna","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sayaka-sh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-05-23T16:39:00.000Z","updated_at":"2024-11-24T13:27:39.000Z","dependencies_parsed_at":"2024-05-28T21:37:42.716Z","dependency_job_id":"6f5b84c9-7d42-46c9-a62d-4463eea5102e","html_url":"https://github.com/sayaka-sh/KJna","commit_stats":null,"previous_names":["toasterofbread/kjna","sayaka-sh/kjna"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/sayaka-sh/KJna","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayaka-sh%2FKJna","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayaka-sh%2FKJna/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayaka-sh%2FKJna/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayaka-sh%2FKJna/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sayaka-sh","download_url":"https://codeload.github.com/sayaka-sh/KJna/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayaka-sh%2FKJna/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34661709,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-22T02:00:06.391Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binding","binding-generator","cinterop","jextract","kotlin-multiplatform","kotlin-native"],"created_at":"2025-02-21T17:25:48.376Z","updated_at":"2026-06-22T19:01:15.020Z","avatar_url":"https://github.com/sayaka-sh.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# KJna\n\nA Gradle plugin for Kotlin Multiplatform projects that generates binding code for common module access to native libraries. Supports Kotlin/Native using the built-in cinterop system and Kotlin/JVM using [Jextract](https://github.com/openjdk/jextract).\n\nKJna currently supports the following Kotlin platforms:\n- JVM\n- Linux x86_64\n- Linux ARM64\n- Windows x86_64\n\nSee the [releases](https://github.com/toasterofbread/kjna/releases) page for a list of available versions.\n\n\u003e [!WARNING]\n\u003e This library is experimental. Some features such as nested pointers are untested and/or not implemented.\n\n## Setup\n\n### Installation\n\n\n1. Add the Maven Central repository to your dependency resolution configuration\n```\nrepositories {\n    mavenCentral()\n}\n```\n\n2. Add the KJna Gradle plugin\n\n```\nplugins {\n    id(\"dev.toastbits.kjna\").version(\"\u003cversion\u003e\")\n}\n```\n\n3. Add the KJna runtime dependency\n```\ndependencies {\n    implementation(\"dev.toastbits.kjna:runtime:\u003cversion\u003e\")\n}\n```\n\n### JDK version\n\nJextract relies on [Java 22's foreign memory API](https://docs.oracle.com/en/java/javase/22/core/foreign-function-and-memory-api.html), so consumers of this library must be compiled using JDK 22 or greater (or JDK 21 with preview features enabled).\n\n**To use JDK 22**\n\n```\nkotlin {\n    jvmToolchain(22)\n}\n```\n\n**To use JDK 21 with preview features**\n\n```\ntasks.withType\u003cJavaCompile\u003e() {\n    options.compilerArgs.add(\"--enable-preview\")\n}\n\nkotlin {\n    jvmToolchain(21)\n}\n```\n\n### Build files\n\nDue to a KMP limitation, Java source files generated by Jextract are stored in `/\u003cproject\u003e/src/jvmMain/java/kjna` (by default). You might want to exclude this directory from source control.\n\nAll other generated files are stored in `/\u003cproject\u003e/build/kjna`.\n\nUnless specified by the user, Jextract is downloaded automatically and stored in `/\u003croot-project\u003e/build/jextract`.\n\n## Configuration\n\nSee the [sample project](/sample/build.gradle.kts) for a working example using mpv.\n\n```\nkotlin {\n    jvm() // 'withJava()' is called automatically by KJna\n\n    val native_targets: List\u003cKotlinNativeTarget\u003e =\n        listOf(\n            linuxX64(),\n            ...\n        )\n\n    kjna {\n        generate {\n            packages(native_targets) {\n                add(\"kjna.libmpv\") {\n\n                    // Disabled packages will have no function implementations\n                    // Use the 'isAvailable()' companion method to check at runtime\n                    enabled = true\n\n                    addHeader(\n                        \"mpv/client.h\", // Header path\n                        \"MpvClient\" // Generated class name (gen.libmpv.LibMpv in this case)\n                    )\n\n                    libraries = listOf(\"mpv\")\n                }\n\n                ...\n            }\n        }\n    }\n}\n```\n\n## Additional credits\n\n- [ANTLR](https://github.com/antlr/antlr4)\n- [Kotlin support for ANTLR](https://github.com/Strumenta/antlr-kotlin) by [Strumenta](https://github.com/Strumenta)\n- [JCPP](https://github.com/shevek/jcpp) by [Shevek](https://github.com/shevek)\n- [Gradle download task](https://github.com/michel-kraemer/gradle-download-task) by [Michel Krämer](https://github.com/michel-kraemer)\n- [Plexus archiver](https://github.com/codehaus-plexus/plexus-archiver) by [Codehaus](https://github.com/codehaus-plexus)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsayaka-sh%2FKJna","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsayaka-sh%2FKJna","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsayaka-sh%2FKJna/lists"}