Frontend Gradle plugin Latest release 10.0.0 Stargazers

Build Node.js-based applications with Gradle and Corepack

This plugin allows to build a Node.js-based application relying on a package manager supported by Corepack: npm, pnpm, Yarn. It is inspired by the philosophy of the Frontend Maven plugin, an equivalent plugin for Maven. Follow the quick start guide, and build your frontend application. Take a look at the Release notes if you are migrating from a previous version.

Features

Distribution management

By default, the plugin downloads and installs a Node.js distribution. Multiple Gradle (sub-)projects may use the distribution downloaded by one of them, or even use a distribution already installed in the workstation to avoid network overhead and duplication. The plugin may also use a HTTP proxy server when downloading the Node.js distribution, to take advantage of any caching facility, and submit to the organization's security rules. Basic authentication scheme is supported for both distribution and proxy servers. In case of connectivity issues, downloading the Node.js distribution is also retryable, with a configurable exponential backoff strategy.

Support of multiple package managers

The plugin delegates installation of your favorite package manager to Corepack. Choose your package manager among npm, pnpm, Yarn, set the packageManager property in your package.json file, and Corepack downloads and activates the distribution expected for each (sub-)project.

Configurable dependencies installation

Depending on the environment, installing frontend dependencies using the package.json file may require a different command (e.g. npm ci).

Built-in tasks

No need to define tasks to build, clean, check, or publish the frontend application through Gradle lifecycle. The plugin provides ready-to-use tasks out of the box, and ensures their implementation matches Gradle's recommendations. Plug scripts from a package.json file with the DSL, and run gradlew build.

Customization

For more complex use cases, the plugin provides types to register custom tasks and run commands with Node.js, Corepack, npm, pnpm, Yarn.

They use this plugin, thanks to these organizations!

Under the hood
  • Lazy configuration: tasks configuration is delayed until necessary thanks to the use of Gradle lazy configuration API, to optimize performance of builds and ease chaining tasks I/O.
  • Self-contained domain design: the plugin design is influenced by clean coding principles. The domain layer is isolated from any framework and infrastructure. Writing cross-platform unit tests and maintaining the plugin is easier. Code coverage and predictability increase.