Class BunPlugin

java.lang.Object
io.github.m_segreti.BunPlugin
All Implemented Interfaces:
org.gradle.api.Plugin<org.gradle.api.Project>

public class BunPlugin extends Object implements org.gradle.api.Plugin<org.gradle.api.Project>
Gradle plugin that downloads and runs the Bun runtime in a local project.

This plugin:

  • Creates a bun extension (BunExtension) so builds can configure the Bun version and system.
  • Registers a bunSetup task that downloads/unpacks Bun into <project>/.gradle/bun/....
  • Registers a small set of convenience tasks (bunInstall, bunTest, bunRun, bunInstallPkg) that execute Bun commands using the installed executable.

Installation is isolated per project and per version/system combination to avoid interfering with any global Bun install.

Configuration


 bun {
   version = "1.1.0" // defaults to "latest"
   system = BunSystem.WINDOWS_X64 // defaults to auto-detect
 }
 

Tasks

  • bunSetup: Downloads and installs Bun (dependency of all Bun execution tasks).
  • bunInstall: Runs bun install in the project directory.
  • bunTest: Runs bun test in the project directory.
  • bunRun: Runs bun run <script> where <script> comes from -PbunScript=....
  • bunInstallPkg: Runs bun add <package> where <package> comes from -PbunPkg=....

Notes

  • This plugin currently wires the Bun executable lazily via Providers to keep configuration time fast.
  • Only a subset of Bun commands are implemented as tasks at the moment. I'll get to more eventually.
  • Constructor Details

    • BunPlugin

      public BunPlugin()
  • Method Details

    • apply

      public void apply(org.gradle.api.Project project)
      Applies the plugin to a Gradle Project.

      This method is responsible for:

      • Creating the bun extension.
      • Deriving the resolved Bun version and platform/system.
      • Registering bunSetup and other Bun execution tasks.
      • Computing the installation directory and executable location using lazy providers.
      Specified by:
      apply in interface org.gradle.api.Plugin<org.gradle.api.Project>
      Parameters:
      project - the project this plugin is being applied to