Class GenerateBamlTask

java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
com.boundaryml.baml.gradle.GenerateBamlTask
All Implemented Interfaces:
Comparable<org.gradle.api.Task>, org.gradle.api.internal.DynamicObjectAware, org.gradle.api.internal.TaskInternal, org.gradle.api.Named, org.gradle.api.plugins.ExtensionAware, org.gradle.api.Task, org.gradle.util.Configurable<org.gradle.api.Task>

@CacheableTask public abstract class GenerateBamlTask extends org.gradle.api.DefaultTask
Runs baml generate to produce the typed BAML Java SDK.

Cacheable and incremental: the declared inputs are baml.toml, every file under baml_src/, and the resolved CLI version string; the output is build/generated/sources/baml/java/main. Gradle skips the task as UP-TO-DATE when none of those changed.

The output directory is cleaned before each generation (BAML's own generate does not remove stale files — a renamed/deleted BAML class would otherwise leave a stale .java that still compiles).

  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.gradle.api.Task

    org.gradle.api.Task.Namer
  • Field Summary

    Fields inherited from interface org.gradle.api.Task

    TASK_ACTION, TASK_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    abstract org.gradle.api.provider.Property<String>
    The baml executable (bare name resolved on PATH, or abs path).
    abstract org.gradle.api.file.ConfigurableFileCollection
    Every file under baml_src/ — the BAML sources.
    abstract org.gradle.api.file.RegularFileProperty
    baml.toml — a declared input so config changes retrigger generation.
    abstract org.gradle.api.provider.Property<String>
    The resolved CLI version (from baml --version).
    abstract org.gradle.process.ExecOperations
     
    abstract org.gradle.api.file.FileSystemOperations
     
    abstract org.gradle.api.file.DirectoryProperty
    build/generated/sources/baml/java/main — the generated tree root.
    abstract org.gradle.api.file.DirectoryProperty
    The project directory passed to the CLI as --from.

    Methods inherited from class org.gradle.api.DefaultTask

    compareTo, configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, finalizedBy, getActions, getAnt, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExtensions, getFinalizedBy, getGroup, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOutputs, getPath, getProject, getShouldRunAfter, getState, getTaskDependencies, getTemporaryDir, getTimeout, hasProperty, mustRunAfter, onlyIf, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesService

    Methods inherited from class org.gradle.api.internal.AbstractTask

    acceptServiceReferences, appendParallelSafeAction, doNotTrackState, getAsDynamicObject, getConvention, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getOnlyIf, getReasonNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, setImpliesSubProjects

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.gradle.api.Task

    doNotTrackState, getConvention, notCompatibleWithConfigurationCache
  • Constructor Details

    • GenerateBamlTask

      public GenerateBamlTask()
  • Method Details

    • getBamlExecutable

      @Internal public abstract org.gradle.api.provider.Property<String> getBamlExecutable()
      The baml executable (bare name resolved on PATH, or abs path).
    • getSrcDir

      @Internal public abstract org.gradle.api.file.DirectoryProperty getSrcDir()
      The project directory passed to the CLI as --from.
    • getBamlToml

      @InputFile @PathSensitive(RELATIVE) public abstract org.gradle.api.file.RegularFileProperty getBamlToml()
      baml.toml — a declared input so config changes retrigger generation.
    • getBamlSources

      @InputFiles @PathSensitive(RELATIVE) public abstract org.gradle.api.file.ConfigurableFileCollection getBamlSources()
      Every file under baml_src/ — the BAML sources.
    • getBamlVersion

      @Input public abstract org.gradle.api.provider.Property<String> getBamlVersion()
      The resolved CLI version (from baml --version). An @Input so a toolchain bump retriggers generation. Wired by BamlPlugin to a provider that returns an empty string when the executable is missing or fails to run — in which case generate() fails with an install hint (never at configuration time).
    • getOutputDir

      @OutputDirectory public abstract org.gradle.api.file.DirectoryProperty getOutputDir()
      build/generated/sources/baml/java/main — the generated tree root.
    • getExecOperations

      @Inject public abstract org.gradle.process.ExecOperations getExecOperations()
    • getFileSystemOperations

      @Inject public abstract org.gradle.api.file.FileSystemOperations getFileSystemOperations()
    • generate

      public void generate()