Class BunPlugin
java.lang.Object
io.github.m_segreti.BunPlugin
- All Implemented Interfaces:
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
bunextension (BunExtension) so builds can configure the Bunversionandsystem. - Registers a
bunSetuptask 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: Runsbun installin the project directory.bunTest: Runsbun testin the project directory.bunRun: Runsbun run <script>where<script>comes from-PbunScript=....bunInstallPkg: Runsbun 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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(org.gradle.api.Project project) Applies the plugin to a GradleProject.
-
Constructor Details
-
BunPlugin
public BunPlugin()
-
-
Method Details
-
apply
public void apply(org.gradle.api.Project project) Applies the plugin to a GradleProject.This method is responsible for:
- Creating the
bunextension. - Deriving the resolved Bun version and platform/system.
- Registering
bunSetupand other Bun execution tasks. - Computing the installation directory and executable location using lazy providers.
- Specified by:
applyin interfaceorg.gradle.api.Plugin<org.gradle.api.Project>- Parameters:
project- the project this plugin is being applied to
- Creating the
-