Class BunSetupTask

java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
io.github.m_segreti.BunSetupTask
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>

public abstract class BunSetupTask extends org.gradle.api.DefaultTask
Gradle task responsible for downloading and verifying the Bun runtime into a project-local directory.

The Bun distribution is downloaded as a zip file from the official GitHub releases, verified using a published SHA-256 checksum, and extracted under:

   <project>/.gradle/bun/<version>/<platform>/
 

This task is designed to be:

  • Idempotent — if Bun is already in place, no work is performed.
  • Reproducible — the exact version and platform are controlled via task inputs.
  • Isolated — Portable installation does not affect any global/system Bun installation.

Inputs

  • getVersion() — the Bun version to install (or "latest").
  • getSystem() — the target system/platform for the Bun distribution.

Outputs

Other Bun-related tasks should declare a dependency on this task to ensure Bun is available before execution.

  • Nested Class Summary

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

    org.gradle.api.Named.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
    abstract org.gradle.api.file.DirectoryProperty
    Root directory where Bun installations are stored.
    abstract org.gradle.api.provider.Property<Boolean>
    Whether to disable SSL certificate verification during downloads.
    abstract org.gradle.api.provider.Property<BunSystem>
    The system/platform variant of Bun to install.
    abstract org.gradle.api.provider.Property<String>
    The Bun version to install.
    void
    run()
    Executes the Bun setup process.

    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, 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, notCompatibleWithConfigurationCache
  • Constructor Details

    • BunSetupTask

      public BunSetupTask()
  • Method Details

    • getVersion

      @Input public abstract org.gradle.api.provider.Property<String> getVersion()
      The Bun version to install.

      May be an explicit version string (e.g. "1.1.0") or "latest". The value is normalized at execution time.

      Returns:
      a property representing the Bun version
    • getSystem

      @Input public abstract org.gradle.api.provider.Property<BunSystem> getSystem()
      The system/platform variant of Bun to install.

      This determines which release asset is downloaded (operating system and CPU architecture).

      Returns:
      a property representing the target BunSystem
    • getDisableSslVerification

      @Input public abstract org.gradle.api.provider.Property<Boolean> getDisableSslVerification()
      Whether to disable SSL certificate verification during downloads.

      Useful in corporate environments with SSL-intercepting proxies.

      Returns:
      a property representing whether SSL verification is disabled
    • getBunRootDir

      @OutputDirectory public abstract org.gradle.api.file.DirectoryProperty getBunRootDir()
      Root directory where Bun installations are stored.

      Each installed version/system combination will be placed under a subdirectory of this location.

      Returns:
      a directory property pointing to the Bun root directory
    • run

      public void run() throws IOException
      Executes the Bun setup process.

      The task performs the following steps:

      1. Resolves and normalizes the configured version and system.
      2. Determines the installation and zip file locations.
      3. Downloads the Bun zip if it does not already exist.
      4. Verifies the zip integrity using a SHA-256 checksum.
      5. Extracts the zip if Bun is not already installed.
      6. Ensures the Bun executable is available and usable.

      If the Bun executable is already present, the task exits early without performing any additional work.

      Throws:
      IOException - if installation or verification fails