Class BamlExtension

java.lang.Object
com.boundaryml.baml.gradle.BamlExtension

public abstract class BamlExtension extends Object
Configuration for the BAML Gradle plugin, exposed as the baml { ... } block:
 baml {
     srcDir.set(layout.projectDirectory)      // where baml.toml + baml_src/ live
     bamlExecutable.set("baml")               // the CLI to run (PATH or abs path)
     outputType.set("java")                   // informational only
     nativePlatforms.set(listOf("all"))       // which native jars to depend on
     manageDependencies.set(true)             // auto-add the baml-bridge runtime
 }
 

Every option has a convention (default) applied by BamlPlugin, so the block is optional for the common case — the whole point of the plugin is that plugins { id("com.boundaryml.baml") version "X" } is the entire setup (it injects the matching com.boundaryml:baml-bridge runtime and the native jar for the build machine automatically).

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract org.gradle.api.provider.Property<String>
    The baml executable to invoke.
    abstract org.gradle.api.provider.Property<Boolean>
    Whether the plugin auto-manages the BAML runtime dependencies.
    abstract org.gradle.api.provider.ListProperty<String>
    Which per-platform native jars to depend on (the classifier tokens linux-x86_64, linux-aarch64, macos-x86_64, macos-aarch64, windows-x86_64, windows-aarch64).
    abstract org.gradle.api.provider.Property<String>
    Informational only: the generator output type.
    abstract org.gradle.api.file.DirectoryProperty
    Project directory containing baml.toml and baml_src/.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BamlExtension

      public BamlExtension()
  • Method Details

    • getSrcDir

      public abstract org.gradle.api.file.DirectoryProperty getSrcDir()
      Project directory containing baml.toml and baml_src/. Passed to the CLI as --from. Default: the project directory.
    • getBamlExecutable

      public abstract org.gradle.api.provider.Property<String> getBamlExecutable()
      The baml executable to invoke. May be a bare name resolved on the PATH (the default, "baml") or an absolute path to a specific binary. The CLI owns toolchain/version resolution.
    • getOutputType

      public abstract org.gradle.api.provider.Property<String> getOutputType()
      Informational only: the generator output type. The real generator configuration (output type, naming convention, output dir) lives in baml.toml under [generator.<name>]. Default: "java".
    • getNativePlatforms

      public abstract org.gradle.api.provider.ListProperty<String> getNativePlatforms()
      Which per-platform native jars to depend on (the classifier tokens linux-x86_64, linux-aarch64, macos-x86_64, macos-aarch64, windows-x86_64, windows-aarch64).

      Default (empty): the plugin auto-detects the build machine's platform from os.name/os.arch and depends only on that one native jar — the zero-config path.

      Explicit list: setting a non-empty list replaces detection with exactly the platforms you name — e.g. to build on Linux but run on macOS, or to ship a runnable artifact for several targets.

      The special value "all": a list containing "all" expands to every platform in the known set. This is always safe: baml_bridge's NativeLibraryLoader selects the jar to load by the JVM's own os.name/os.arch at runtime (first-hit-wins on the /native/<os>-<arch>/ classpath resource), so the extra native jars for other platforms are inert — they simply sit unused on the runtime classpath. The trade-off is download size (one engine cdylib per platform), not correctness.

      Note: the experimental musl classifiers (linux-*-musl) are never auto-detected and are not part of "all"; a musl (Alpine) consumer must request that classifier explicitly.

    • getManageDependencies

      public abstract org.gradle.api.provider.Property<Boolean> getManageDependencies()
      Whether the plugin auto-manages the BAML runtime dependencies. Default: true.

      When true, the plugin injects implementation("com.boundaryml:baml-bridge:<pluginVersion>") plus a runtimeOnly native jar per resolved platform (see getNativePlatforms()) — unless the project already declares an explicit com.boundaryml:baml-bridge dependency, in which case the plugin defers to it and injects nothing.

      Set to false to opt out entirely — the escape hatch for exotic setups (a custom runtime coordinate, a vendored jar, a platform the standard classifiers don't cover). You then own the baml-bridge (and native jar) dependencies yourself.