Skip to content
CAI
Software that uses CAICheck a score

sbt/sbt-jni

63.7

Adequate · 20 September 2026

899

lines of production code

Scala

primary language

1

measurement over time

CAI band scale
CAI lens gauges

What this system is

This system is an sbt plugin designed to automate the integration of native code with Scala projects. It handles the generation of JNI headers, the compilation of native libraries using build tools like CMake, Meson, Autotools, and Cargo, and the loading of resulting native binaries at runtime. The plugin provides macro annotations to simplify binding Scala methods to native implementations and supports cross-compilation across multiple Scala and SBT versions.

How it got here

2015–2016 — macro annotation migration and build modernization

13 changes.

The project underwent a significant architectural shift by removing legacy JNI loading utilities and SBT plugins in favor of a new approach using macro annotations for automatic native library integration. This transition was accompanied by a comprehensive modernization of the build infrastructure, upgrading to SBT 2 and Scala 3, and consolidating the project structure. Extensive scripted tests were added to validate the new macro-based loading mechanisms across simple and multi-class scenarios.

2021 — Modularization and build tool expansion

12 changes.

The plugin was refactored into modular AutoPlugins to improve structure and support Scala 3, while introducing built-in support for Meson, Autotools, and Cargo build systems. New features included gjavah header generation, bytecode scanning utilities, and enhanced handling for multiple native library outputs. Comprehensive scripted tests were added to validate these new integrations and syntax changes.

2023–2026 — SBT 2.x compatibility and test expansion

7 changes.

The project implemented compatibility shims to support SBT 2.x, addressing API differences in file handling and caching across Scala 2 and 3. Concurrently, the test suite was expanded to cover complex scenarios, including overloaded native methods with reference parameters, Meson build system integration, and Cargo paths containing spaces.

Features

Add BytecodeUtil for detecting native classes

Introduces a new BytecodeUtil utility that scans Java class files to identify classes containing methods annotated with @native, enabling the plugin to accurately locate native implementations during the build process.

plugin/src/main/scala/com/github/sbt/jni/util · high confidence

Add gjavah JNI header generation engine

The plugin now includes a complete gjavah implementation (copied from gjavah v0.3.1) to generate JNI C header files from Java classes. This adds the JavahTask orchestrator, a JNIGenerator that uses ASM to inspect class metadata and resolve native methods, and search path support for class paths, module paths, and the runtime classpath. It also includes localization resources for English and Simplified Chinese help and error messages.

plugin/src/main/java · high confidence

Added Meson build tool support for JNI projects

Users can now generate JNI projects using the Meson build system in addition to the existing CMake support. This change introduces new template files (meson.build, meson.options) within the plugin resources that configure the project for C/C++/Java compilation, locate JNI headers, and handle library naming conventions required by sbt-jni.

plugin/src/main/resources · high confidence

Introduction of core model classes for JNI header generation

The plugin now includes new domain model classes to support the generation of JNI headers. ClassName provides structured handling of module and class names, including full and internal name parsing. ClassPath implements search logic for locating classes within classpath roots. Constant models Java constants with type validation and mangled name generation. NativeMethod represents native method signatures, handling access flags, type descriptors, and generating unique mangled names for method resolution.

repository · high confidence

Support for multiple native library outputs and new build tools

The plugin now supports building projects that produce multiple native library files (e.g., .so, .dylib, .dll) via the \nativeMultipleOutputs\ setting, preventing warnings or truncation when more than one output is generated. Additionally, the plugin introduces built-in support for the Autotools and Meson build systems alongside existing CMake and Cargo support, allowing users to integrate these tools directly without custom configuration.

plugin/src/main/scala/com/github/sbt/jni/build · high confidence

Removals

Native JNI example code removed from demo project

The native library build files (CMakeLists.txt), the JNI header, the SBT plugin configuration, and the Scala wrapper object for the native library have been deleted from the examples/demo directory. This change removes the local native code integration from the demo, aligning with the commit intent to use a separate project for native libraries.

examples · high confidence

Removal of legacy JNI library and SBT plugin

The \jni-library\ and \jni-plugin\ modules have been completely removed from the codebase. This deletes the \NativeLoader\ and \Platform\ utilities that previously handled automatic extraction and loading of native libraries from JARs, as well as the SBT plugin (\JniPlugin\) that provided build tasks for compiling native code via CMake, generating JNI headers, and bundling native artifacts. Users relying on these components for native library integration must migrate to the new approach indicated by the commit messages (using macro annotations and a separate project for native libraries).

jni-library, jni-plugin · high confidence

Behavioural changes

Compatibility layer for SBT 2.x support

The plugin now includes compatibility shims to support SBT 2.x. This introduces Scala 2 and Scala 3 specific implementation files that handle API differences, such as adapting file conversion logic for \HashedVirtualFileRef\ in SBT 2 and providing a no-op \uncached\ method to maintain compatibility with SBT 1.x's lack of build caching. It also adds a \distinctBy\ collection operation for Scala 2 to ensure consistent behavior across versions.

plugin/src/main/scala-2, plugin/src/main/scala-3 · high confidence

Native library loading now uses packaged fallback for Scala 2.11

The core library now supports Scala 2.11 by introducing a new macro-based \@nativeLoader\ annotation in \scala-2\ and a corresponding \NativeLoader\ syntax object. For users, this means native libraries can be loaded via a packaged fallback mechanism that extracts the library to a temporary directory if the standard \System.loadLibrary\ fails, ensuring compatibility with the Scala 2.11 build target.

core · high confidence

Native library loading via macro annotation in test suite

The simple core test module now uses the @nativeLoader macro annotation from com.github.sbt.jni to automatically load the native library, replacing previous manual loading mechanisms. This change is demonstrated in the Library.scala file which defines the native method and the Main.scala and Test.scala files which verify the native call works correctly in both runtime and test contexts.

plugin/src/sbt-test/sbt-jni/simple/core · high confidence

Restructured native build plugin into modular AutoPlugins

The native build functionality has been refactored from a single monolithic plugin into four distinct, modular AutoPlugins: JniJavah (for JNI header generation), JniLoad (for dependency and macro configuration), JniNative (for native compilation and build tool integration), and JniPackage (for packaging native libraries). This change introduces new settings such as \unmanagedPlatformDependentNativeDirectories\ for finer-grained control over unmanaged native library locations, and \nativeMultipleOutputs\ to support multiple native build outputs. It also standardizes the output directory for generated JNI headers to \target/native/include\ to ensure compatibility across sbt versions, and updates the \sbtJniCoreScope\ to allow switching between Provided and Compile scopes for Scala 3.x compatibility.

plugin/src/main/scala/com/github/sbt/jni/plugins · high confidence

Update scripted test project to Scala 2.13.18 and 2.12.21

The scripted test project for sbt-jni has been updated to use Scala versions 2.13.18 and 2.12.21, with 2.13.18 set as the default. The test configuration now includes compiler options for features and deprecation warnings, and the plugin is loaded via a scripted helper auto-plugin that applies these settings.

plugin/src/sbt-test/sbt-jni/simple/project · high confidence

Updated native build configuration and JNI implementations for multiclasses tests

The native test cases for the \multiclasses\ scenario now use CMake (minimum version 3.12) to build shared libraries instead of previous build methods. The \native1\ library (version 0) implements JNI bindings for the \multiclasses.Adder\ class, including methods for addition and accessing nested class fields, while the \native2\ library (version 1.2.3) implements the \multiclasses.Multiplier\ class. These changes ensure the native code is compiled with the correct include paths and library naming conventions required by sbt-jni.

plugin/src/sbt-test/sbt-jni/multiclasses/native1 · high confidence

Fixes

Fix overloaded native method names with reference type parameters

The native library implementation for the \overloads\ test case now correctly defines the JNI entry points for the overloaded \say\ method. Specifically, the C code implements the distinct signatures required for \say\ when called with a String, a String and int, a String and long, and a String array, ensuring that the native side matches the expected Java method overloads.

plugin/src/sbt-test/sbt-jni/overloads/native · high confidence

Test coverage

Add native library implementation for JNI testing; Add sbt-jni test case for Meson build tool support; Add scripted test for overloaded methods with ref type parameters; Add scripted test infrastructure for sbt-jni Cargo integration; Add simple-cargo test demonstrating Rust native library integration; Add test case for Cargo paths with spaces; Added integration tests for Cargo (Rust) support; Added integration tests for simple and multiclasses scenarios; Added scripted test for loading multiple native libraries; Added scripted tests for oneproject and simple-syntax scenarios; Added simple-syntax test project demonstrating native method loading; Added test case for overloaded native methods with ref type parameters; Added tests for overloaded native method name mangling; Support for native library loading via macro annotation in test case.

Dependencies

Updated Scala versions and added scripted test helper for sbt-jni

The scripted test project for sbt-jni now supports Scala 3.8.4, 2.13.18, and 2.12.21, with the latest version set as the default. A new ScriptedHelper auto-plugin was added to enforce -feature and -deprecation compiler flags during tests, and the plugins.sbt file was updated to load the sbt-jni plugin dynamically via a system property.

plugin/src/sbt-test/sbt-jni/simple-syntax/project · high confidence

Upgrade to Scala 3.8.4, SBT 2, and ASM 9.10.1

The build system has been upgraded to support Scala 3.8.4 (alongside 2.13.18, 2.12.21, and 2.11.12) and SBT 2, with the plugin now cross-building using Scala 3 for SBT 2 compatibility. The ASM dependency is updated to version 9.10.1, and the project structure has been consolidated into a new \build.sbt\ that defines \core\ and \plugin\ modules, replacing the previous \Build.scala\ and demo examples.

(dependencies) · high confidence

Upgrade to sbt 1.13 and update build plugins

The build system has been upgraded from sbt 0.13.9 to sbt 1.13.0. This change includes updating the sbt-ci-release plugin to version 1.12.1, sbt-scalafmt to 2.6.2, and sbt-updates to 0.7.0. The legacy Build.scala file has been removed, indicating a migration to the newer sbt project structure.

project · high confidence

Housekeeping

Project initialization and documentation setup

The repository has been initialized with the core project structure, including the addition of a comprehensive README.md detailing the sbt-jni plugin's features (JniJavah, JniLoad, JniNative, JniPackage) and setup instructions, a CHANGELOG.md following the Keep a Changelog format, and a LICENSE file. Configuration files such as .scalafmt.conf (version 3.11.5, Scala 3 dialect) and .gitignore have been added to standardize code formatting and exclude build artifacts, while .git-blame-ignore-revs tracks formatting commits.

(repo-wide) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Baseline

  • First survey — no prior run to compare against. CAI 64.

Lenses

  • Code Health 100
  • Architecture 100
  • Maturity 57
  • Readiness 72
  • Security 56

Changes since last survey

  • 300 commits — 293 feature/other, 7 fixes

By area

  • (root) — 123 commits
  • plugin/src — 95 commits
  • .github/workflows — 38 commits
  • project/plugins.sbt — 32 commits
  • project/build.properties — 5 commits
  • (repo) — 2 commits
  • .github/release-drafter.yml — 2 commits
  • core/src — 2 commits
  • .github/dependabot.yml — 1 commit

Notable commits

  • fix: Fix Rust target-dir with spaces (#173)
  • fix: Fix names of overloaded methods with ref type parameters (#139)
  • fix: Fix sbt test on java 11 (#112)
  • fix: Fix warning (not only) in users' code (#59)
  • fix: [revert] sbt-ci-release to 1.9.3
  • fix: fix dll output not found (#233)
  • fix: fix for #38: sbt 1.4.x (#39)
  • change: Add CMake support of versions < 3.1 (#51)
  • change: Add Cargo into README.md (#56)
  • change: Add Java 17 to CI (#83)
  • change: Add name mangling rule for '$'
  • change: Add release-drafter
  • change: Add scalafmt, upd SBT version, add CHANGELOG, adjust CI (#47)
  • change: Add support for Cargo (Rust) (#42)
  • change: Add support for Meson build tool (#147)
  • change: Add support of multiple native outputs (#186)
  • change: Add unmanagedPlatformDependentNativeDirectories (#60)
  • change: Adjust sbtJniCoreProvided description
  • change: Adjust the CI release conditions
  • change: Auto approve scala-steward PRs
  • …and 280 more

Architecture

  • 0 containers · 2 bounded contexts · 0 dependency edges (baseline)

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

sbt/sbt-jni was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 20 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 6ee5de58d6730b4d35f4bb282e88771e1d9918d0 — the exact code this score is about.
  • Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-b51f968c9b10.