Home

Awesome

Gradle GAE plugin

Google App Engine Logo

<table border="1"> <tr> <td>The development of this plugin has been taken over by Google. Please refer to its new GitHub repository <a href="https://github.com/GoogleCloudPlatform/gradle-appengine-plugin">GoogleCloudPlatform/gradle-appengine-plugin</a>. Development on this repository is discontinued.</td> </tr> </table>

The plugin provides tasks for uploading, downloading, running and managing Google App Engine (GAE) projects in any given Gradle build. It extends the War plugin.

Usage

To use the GAE plugin, include in your build script:

apply plugin: 'gae'

The plugin JAR needs to be defined in the classpath of your build script. It is directly available on Maven Central. Alternatively, you can download it from GitHub and deploy it to your local repository. The following code snippet shows an example on how to retrieve it from Maven Central:

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'org.gradle.api.plugins:gradle-gae-plugin:0.9'
    }
}

Note: The plugin requires you to set the environment variable APPENGINE_HOME or the system property google.appengine.sdk pointing to your current Google App Engine SDK installation. In case you have both variables set the system property takes precedence over the environment variable. Alternatively, you can choose to automatically download the SDK by setting the convention property downloadSdk to true. This option requires you to specify the SDK version you want to use by setting the configuration gaeSdk.

dependencies {
    gaeSdk 'com.google.appengine:appengine-java-sdk:1.7.3'
}

Tasks

The GAE plugin defines the following tasks:

Project layout

The GAE plugin uses the same layout as the Gradle War plugin. The only difference is the addition of the functionalTest source set (located in src/functionalTest by default) which is used by the gaeFunctionalTest task.

Convention properties

The GAE plugin defines the following convention properties in the gae closure:

Within gae you can define optional properties in a closure named appcfg:

The task gaeDownloadApp requires you to at least define the application ID and directory to write the files to. Define the tasks' properties in the closure app:

The task gaeLogs requires you to at least define the file to write the logs to. Define the tasks' properties in the closure logs:

The task gaeUpdate allows you to specify upload specific settings. Define the tasks' properties in the closure update:

Example

gae {
    httpPort = 8085
    optimizeWar = true

    appcfg {
        email = 'benjamin.muschko@gmail.com'
        passIn = true

        logs {
            severity = 1
            outputFile = file('mylogs.txt')
        }

        app {
            id = 'sample-app'
        }
    }
}

FAQ

Can I use the plugin with a Gaelyk project?

Gaelyk's template project uses this plugin out-of-the-box so no additional configuration needs to be done. If you start your project from scratch and decide to use the plugin please refer to the following sections to configure it properly.

Gaelyk <= 1.1

Yes, you just have to configure the WAR plugin to point to the correct web application (by default war) and source code (by default src) directory. If you want to stick to the default source directory simply create the subdirectory src/main/groovy.

apply plugin: 'groovy'

sourceSets {
    main {
        groovy {
            srcDirs = ['src']
        }
    }
}

webAppDirName = file('war')

When editing a Groovlets/Groovy templates in Gaelyk the server automatically deploys the change and you see it take effect almost instantly. The plugin provides support for that. Simply set the warDir convention property and leave the server running.

gae {
    warDir = file('war')
}

Gaelyk >= 1.2

Starting with version 1.2 Gaelyk adopted Gradle's default directory structure. The following changes are required to leverage Gaelyk's hot-reloading feature.

gae {
    warDir = file('src/main/webapp')
}

sourceSets.main.output.classesDir = 'src/main/webapp/WEB-INF/classes'
<br> **How do I remote debug the local development server?**

You can use the convention property jvmFlags to set the JVM debug parameters. Make sure to set the TCP port you want your JVM to listen on. The following example show how to set the JVM flags to listen on port 8000.

gae {
    jvmFlags = ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000']
}
<br> **How do I run functional tests on the local development server?**

If you want to execute your tests in the container alongside the rest of your application you have to configure the gaeRun task to run in daemon mode. Starting with version 0.7 of the plugin this has become even easier. It provides the task gaeFunctionalTest which lets you define your functional test dependencies via the configuration functionalTestCompile. On top of that the task has been fully integrated into the build lifecycle.

One of the most prominent functional testing libraries in the Groovy ecosystem is Geb, an expressive and powerful browser automation solution. Please refer to this short and sweet tutorial for a quickstart.