This project is no longer maintained

A fork of it that is still supported and has a newer release is available at https://github.com/esoco/gwt-gradle-plugin. Please use the new version if you need GWT support for Gradle.


Putnami Gradle Plugin

This plugin helps to build GWT project with Gradle. The main goals is build webapps and libraries.

Why to use it?

Requirements

Quick start

/ build.gradle
/ src
  |-- main
    |-- java
    |-- resources
    |-- webapp
PROJECT_NAME={your-project}
mkdir $PROJECT_NAME
cd $PROJECT_NAME
mkdir -p src/main/java src/main/resources src/main/webapp
mkdir -p src/test/java src/test/resources
touch build.gradle

To apply the plugin, please add one of the following snippets to your build.gradle file:

Gradle >= 2.1

plugins {
    id "fr.putnami.gwt" version "0.4.0"
}

Currently the "plugins" notation cannot be used for applying the plugin for sub projects, when used from the root build script.

Gradle < 2.1

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'fr.putnami.gwt:putnami-gradle-plugin:0.4.0'
    }
}
apply plugin: 'fr.putnami.gwt'

If you have a multi project build make sure to apply the plugin and the plugin configuration to every project.

Notes

To use the lastest snapshot you can add maven{ url 'https://oss.sonatype.org/content/repositories/snapshots/' } to the buildscript repositories.

On eclipse

apply plugin: 'eclipse'
plugins {
  id "fr.putnami.gwt" version "0.4.0"
}

repositories {
    mavenCentral()
}

putnami{
    module 'your.gwt.module.to.compile'
    /** add gwt nature on eclipse projec. require apply plugin: 'eclipse' to work. default : false*/
    googlePluginEclipse = true
}

Samples

We offer you 3 build samples:

Advanced usages

Plugins

The Putnami Gradle Plugin is usefull either to build GWT's library or webapp.

Debug server side

To debug the server side (jetty), you can use the the below configuration then run gradle gwtDev and attach a remote debugger with your favorite IDE.

putnami{
    jetty {
        /** enable debugging. */
        debugJava = true
        /** debug port to listen. */
        debugPort = 8000
        /** wait for debugger attachment. */
        debugSuspend = false
    }
}

Debug client side

The first way to debug the client side is to use the developer tools of your browsers. All modern browser provide powerfull tools to browse and put breakpoint on the java sources exposed by GWT code server.

You can also use the eclipse plugin SDBG ( http://sdbg.github.io/) to debug in your IDE. Once the plugin installed you have to:

  1. run the task gwtDev or gwtCodeServer
  2. in the eclipse debug configuration add a launch chrome.
  3. set the url (I.E. http://localhost:8080/)
  4. set the project where the sources are.
  5. Run the configuration
  6. Add some breakpoints.

And enjoy.

Tasks and configuration

putnami{
    /** Module to compile, can be multiple */
    module 'fr.putnami.gradle.sample.multimodule.app.App'

    /** GWT version */
    gwtVersion = "2.7.0"
    /** Add the gwt-servlet lib */
    gwtServletLib = true
    /** Add the gwt-elemental lib */
    gwtElementalLib = false
    /** Jetty version */
    jettyVersion = "9.2.7.v20150116"
}

Can be tuned with the following parametters:

putnami{
    compile {
        /** The level of logging detail (ERROR, WARN, INFO, TRACE, DEBUG, SPAM, ALL) */
        logLevel = "INFO"
        /** Compile a report that tells the "Story of Your Compile". */
        compileReport = true
        /** Compile quickly with minimal optimizations. */
        draftCompile = true
        /** Include assert statements in compiled output. */
        checkAssertions = false
        /** Script output style. (OBF, PRETTY, DETAILED)*/
        style = "OBF"
        /** Sets the optimization level used by the compiler. 0=none 9=maximum. */
        optimize = 5
        /** Fail compilation if any input file contains an error. */
        failOnError = false
        /** Specifies Java source level. ("1.6", "1.7")*/
        sourceLevel = "1.7"
        /** The number of local workers to use when compiling permutations. */
        localWorkers = 2
        /** The number of local workers to use when compiling permutations. */
        localWorkersMem = 2048
        /** Emit extra information allow chrome dev tools to display Java identifiers in many places instead of JavaScript functions. (NONE, ONLY_METHOD_NAME, ABBREVIATED, FULL)*/
        methodNameDisplayMode = "NONE"
        /** Specifies JsInterop mode (NONE, JS, CLOSURE). JsInterop Experimental (GWT 2.7) */
        jsInteropMode = "JS"
        /** Generate and export JsInterop (since GWT 2.8) */
        generateJsInteropExports = true

        /** Extra args can be used to experiment arguments */
        extraArgs = ["-firstArgument", "-secondArgument"]

        /** shown all compile errors */
        strict = false

        /** Java args */
        maxHeapSize="1024m"
        minHeapSize="512m"
        maxPermSize="128m"
        debugJava = true
        debugPort = 8000
        debugSuspend = false
        javaArgs = ["-Xmx256m", "-Xms256m"]
    }
}

Note : This task depends on the gwtCompile task.

Can be tuned with the following parametters:

putnami{
    jetty {
        /** interface to listen on. */
        bindAddress = "127.0.0.1"
        /** request log filename. */
        logRequestFile
        /** info/warn/debug log filename. */
        logFile
        /** port to listen on. */
        port = 8080
        /** port to listen for stop command. */
        stopPort = 8089
        /** security string for stop command. */
        stopKey = "JETTY-STOP"

        /** Java args */
        maxHeapSize="1024m"
        minHeapSize="512m"
        maxPermSize="128m"
        debugJava = true
        debugPort = 8000
        debugSuspend = false
        javaArgs = ["-Xmx256m", "-Xms256m"]
    }
}

The SDM is tuned with the following parametters, the jetty is configured from the previous configuration.

putnami{
    dev {
        /** The ip address of the code server. */
        bindAddress = "127.0.0.1"
        /** Stop compiling if a module has a Java file with a compile error, even if unused. */
        failOnError = false
        /** Precompile modules. */
        precompile = false
        /** The port where the code server will run. */
        port = 9876
        /** EXPERIMENTAL: Don't implicitly depend on "client" and "public" when a module doesn't define anydependencies. */
        enforceStrictResources = false
        /** Specifies Java source level ("1.6", "1.7").
        sourceLevel = "1.6"
        /** The level of logging detail (ERROR, WARN, INFO, TRACE, DEBUG, SPAM, ALL) */
        logLevel = "INFO"
        /** Specifies JsInterop mode (NONE, JS, CLOSURE). JsInterop Experimental (GWT 2.7) */
        jsInteropMode = "JS"
        /** Generate and export JsInterop (since GWT 2.8) */
        generateJsInteropExports = true
        /** Emit extra information allow chrome dev tools to display Java identifiers in many placesinstead of JavaScript functions. (NONE, ONLY_METHOD_NAME, ABBREVIATED, FULL) */
        methodNameDisplayMode = "NONE"
        /** shown all compile errors */
        strict = false
        /** disable this internal server */
        noServer = false

        /** Extra args can be used to experiment arguments */
        extraArgs = ["-firstArgument", "-secondArgument"]

        /** Java args */
        maxHeapSize="1024m"
        minHeapSize="512m"
        maxPermSize="128m"
        debugJava = true
        debugPort = 8000
        debugSuspend = false
        javaArgs = ["-Xmx256m", "-Xms256m"]
    }
}

Help and Contribute

We need you! Any help is welcome. And there is many ways to help us:

Be a nice community member

If you tried and you love PWT. We will be glad to count you as community members. So please :

Of course you will get all our thankfulness if you blog, share and spread PWT around you. All the backlinks on http://putnami.org are very welcome.

Report issues

All issues about bugs or enhancement are precious and will be given careful consideration. We're going to help you in the best delay as can (generally in the day time).

To report an issue, please use the project issue tracker

Contribute

You'd love to contribute your code, nice :) First be sure that your code respect the project code style and formating. All the documentation is here

If you are an eclipse user, it could be nice if you follow the workspace setup instructions.

Every pull request will be review with a great consideration, and with a full open mind.

License

The framework is delivered under LGPL v 3.0.

The LGPL v 3.0 allows a free usage of PWT for commercial and open source projects. We equally guarantees that PWT is and will open source for ever.

PWT doesn't affect the license of your application. Using PWT is free of charge so fill free to use and integrate it.

You can have a look at the licence details on a https://www.gnu.org/licenses/lgpl-3.0.txt.



We hope that this plugin will help you to build great apps.

Best regards.

@PutnamiTeam