Class BamlExtension
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 -
Method Summary
Modifier and TypeMethodDescriptionabstract org.gradle.api.provider.Property<String> Thebamlexecutable 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 tokenslinux-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.DirectoryPropertyProject directory containingbaml.tomlandbaml_src/.
-
Constructor Details
-
BamlExtension
public BamlExtension()
-
-
Method Details
-
getSrcDir
public abstract org.gradle.api.file.DirectoryProperty getSrcDir()Project directory containingbaml.tomlandbaml_src/. Passed to the CLI as--from. Default: the project directory. -
getBamlExecutable
Thebamlexecutable to invoke. May be a bare name resolved on thePATH(the default,"baml") or an absolute path to a specific binary. The CLI owns toolchain/version resolution. -
getOutputType
Informational only: the generator output type. The real generator configuration (output type, naming convention, output dir) lives inbaml.tomlunder[generator.<name>]. Default:"java". -
getNativePlatforms
Which per-platform native jars to depend on (the classifier tokenslinux-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.archand 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'sNativeLibraryLoaderselects the jar to load by the JVM's ownos.name/os.archat 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
Whether the plugin auto-manages the BAML runtime dependencies. Default:true.When
true, the plugin injectsimplementation("com.boundaryml:baml-bridge:<pluginVersion>")plus aruntimeOnlynative jar per resolved platform (seegetNativePlatforms()) — unless the project already declares an explicitcom.boundaryml:baml-bridgedependency, in which case the plugin defers to it and injects nothing.Set to
falseto 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 thebaml-bridge(and native jar) dependencies yourself.
-