webforJ build plugin 26.01
The webforJ build plugin runs webforJ's build time work as part of your Maven or Gradle build. You add it once, and it binds its goals to the phases you already run, with no separate frontend project to keep in sync. It drives the frontend bundler, compiling the frontend, running the frontend tests, and serving the development watch.
Adding the plugin
A webforJ project created from an archetype already has the plugin. To add it to an existing project:
- Maven
- Gradle
Declaring the plugin with <extensions>true</extensions> binds its goals to the build with no execution blocks to write:
<plugin>
<groupId>com.webforj</groupId>
<artifactId>webforj-maven-plugin</artifactId>
<extensions>true</extensions>
</plugin>
Add the plugin through a buildscript classpath dependency and apply it:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "com.webforj:webforj-gradle-plugin:${webforjVersion}"
}
}
apply plugin: 'com.webforj'
Goals
The plugin binds four goals, each to a phase you already run, so a normal mvn package or gradle build produces an app with its frontend compiled in, and mvn test runs the frontend tests alongside the Java tests.
| Maven goal | Gradle task | Phase | What it does |
|---|---|---|---|
bundle | webforjBundle | prepare-package | Compiles the frontend for production |
test | webforjTest | test | Runs the frontend tests |
clean | webforjCleanFrontend | clean | Removes the generated frontend |
watch | webforjWatch | run by hand | Rebuilds on change during development |
The watch goal is the one you run by hand during development, alongside the app. Its reload behavior is covered in Frontend watch.