Gradle plugins for GWT (Google Web Toolkit) projects with optional npm/webpack integration.
Requires Java 11+ and Gradle 7.x - 9.x.
Examples can be found at https://github.com/ascendtech/gwt-examples
| Plugin ID | Description |
|---|---|
us.ascendtech.gwt.modern |
GWT projects with webpack/npm frontend. Compiles to archive for deploy. |
us.ascendtech.gwt.classic |
Traditional GWT projects. Compiles to war. |
us.ascendtech.gwt.lib |
GWT library projects shared across modules. |
us.ascendtech.gwt.dep |
Non-GWT modules that should be included in GWT compilation. |
us.ascendtech.js.npm |
Standalone npm/webpack support for Gradle. |
A plugin for GWT projects using webpack and npm.
build.gradle
plugins {
id "us.ascendtech.gwt.modern" version "0.12.2"
}
gwt {
modules = ['com.company.SomeModule']
}// gwt lib build.gradle
plugins {
id "us.ascendtech.gwt.lib" version "0.12.2"
}
// app build.gradle
plugins {
id "us.ascendtech.gwt.modern" version "0.12.2"
}
gwt {
modules = ['com.company.SomeModule']
}
dependencies {
implementation project(':someGwtLibProject')
}Compile to tar.gz bundle for deploy on web server:
gradle gwtArchive # archive in build/webappRun GWT dev mode with webpack backend:
gradle gwtDev
# new terminal
gradle webpack5Dev
# if using annotation processing (autorest, vue-gwt, simplerest)
# new terminal
gradle compileJava --build-cache -t compileJavaA plugin for traditional GWT projects. Compiles to war.
build.gradle
plugins {
id "us.ascendtech.gwt.classic" version "0.12.2"
}
gwt {
modules = ['com.company.SomeModule']
}// gwt lib build.gradle
plugins {
id "us.ascendtech.gwt.lib" version "0.12.2"
}
// app build.gradle
plugins {
id "us.ascendtech.gwt.classic" version "0.12.2"
}
gwt {
modules = ['com.company.SomeModule']
}
dependencies {
implementation project(':someGwtLibProject')
}Create war:
gradle war # war file in build/libsRun GWT dev mode (Super Dev Mode):
gradle gwtDev| Option | Default | Description |
|---|---|---|
gwtVersion |
"2.13.0" |
GWT SDK version |
modules |
[] |
List of GWT modules to compile or run |
libs |
[] |
Shorthand library dependencies (see below) |
style |
"OBFUSCATED" |
Script output style: DETAILED, OBFUSCATED, or PRETTY |
logLevel |
"INFO" |
Logging detail: ERROR, WARN, INFO, TRACE, DEBUG, SPAM, or ALL |
localWorkers |
available processors | Number of local workers for compiling permutations |
proxy |
"http://localhost:8080" |
Webpack backend address (modern plugin) |
includeGwtUser |
true |
Include gwt-user on the classpath |
extra |
true |
Produce GWT "extra" output directory |
forceRecompile |
true |
Force recompilation (disable up-to-date checks) |
sourceLevel |
"17" |
Java source level for GWT compilation |
incremental |
false |
Enable incremental compilation |
persistentunitcache |
true |
Enable GWT persistent unit cache |
Use the libs option to add common GWT library dependencies:
gwt {
libs = ["elemento-core", "simplerest"]
}| Lib name | Library |
|---|---|
elemento-core |
Elemento 1.6.11 |
elemento-core-legacy |
Elemento 0.9.6 (gwt2 variant when includeGwtUser is true) |
vue |
Vue GWT 1.0.1 (includes annotation processor) |
autorest |
AutoREST 0.11 (includes annotation processor) |
simplerest |
SimpleREST 0.6.0 (includes annotation processor) |
ast-highcharts |
GWT Highcharts 1.3.3 |
ast-aggrid |
AG Grid GWT bindings 0.3.2 |
ast-momentjs |
Moment.js GWT bindings 0.4.0 |
ast-wordcloud |
WordCloud2.js GWT bindings 2.1.0 |
core |
org.gwtproject.core:gwt-core 1.0.0-RC2 |
event |
org.gwtproject.event:gwt-event 1.0.0-RC1 |
places |
org.gwtproject.places:gwt-places 1.0.0-RC1 |
history |
org.gwtproject.user.history:gwt-history 1.0.0-RC1 |
timer |
org.gwtproject.timer:gwt-timer 1.0.0-RC1 |
A plugin for GWT library projects. Apply this to modules that contain GWT source to be shared across projects. The gwt.modern and gwt.classic plugins automatically apply this.
plugins {
id "us.ascendtech.gwt.lib" version "0.12.2"
}
gwt {
libs = ["elemento-core"]
}Library dependencies (both libs and npm dependencies) are automatically propagated to dependent projects.
A plugin for modules that should be included in GWT compilation but that aren't GWT modules themselves.
plugins {
id "us.ascendtech.gwt.dep" version "0.12.2"
}A plugin that downloads and runs npm and webpack. NodeJS is downloaded to ~/.nodejs/<version>/. Supports Linux, macOS, and Windows on x64 and ARM64 architectures.
build.gradle
plugins {
id "us.ascendtech.js.npm" version "0.12.2"
}
// all optional, defaults shown
npm {
nodeJsVersion = "16.13.0"
webpackInputBase = "./src/main/webapp/"
contentBase = "./src/main/webapp/public/"
}| Option | Default | Description |
|---|---|---|
nodeJsVersion |
"16.13.0" |
Node.js version to download and use |
webpackInputBase |
"./src/main/webapp/" |
Webpack input directory (used for up-to-date checks) |
contentBase |
"./src/main/webapp/public/" |
Content base for webpack5LegacyDev task |
webpackOutputBase |
"build/js" |
Webpack output directory (not configurable) |
dependencies |
[] |
npm dependencies to install via Gradle |
devDependencies |
[] |
npm dev dependencies to install via Gradle |
npm {
dependencies = ["vue@2.7.16", "vuetify@2.7.2"]
devDependencies = ["webpack@5.90.0", "webpack-cli@5.1.4"]
}tasks.register<us.ascendtech.js.npm.NpmTask>("npmAuditFix") {
dependsOn("npmInstallDep", "npmInstall")
baseCmd.set("npm")
baseArgs.addAll("audit", "fix")
}gradle npmClean # rm -rf node_modules
gradle npmInstall # npm install
gradle npmInstallSave --npmModule vue # npm install vue --save
gradle npmInstallSaveDev --npmModule vue # npm install vue --save-dev
gradle webpack # webpack-cli --mode=production --output-path build/js
gradle webpack5Dev # webpack serve --mode=development
gradle webpack5LegacyDev # webpack serve --mode=development --content-base <contentBase>const path = require('path');
module.exports = {
resolve: {
extensions: ['*', '.js', '.json']
},
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
}
]
},
entry: {
app: ["./src/main/webapp/js/index.js"]
},
output: {
filename: "bundle.js"
},
devServer: {
port: 8080,
static: {
directory: path.resolve(__dirname, "src", "main", "webapp", "public"),
publicPath: "/",
serveIndex: true,
watch: true,
},
proxy: {
'/api': {
target: 'http://localhost:12111',
ws: true,
changeOrigin: true
}
}
}
}Apache 2.0