Search code examples
javagoogle-app-enginegradle

How to set a custom version when deploying an app engine application?


I am deploying an app to Google app engine standard. It's a Java/Kotlin application, but the question isn't necessarily specific to that. I am using the latest Gradle plugin, and the answer could be specific to that.

Like over all those years, I specify a project ID, let's say MyProject, and a version number/string, let's say 1-2-0. Both pieces of information would historically go into the appengine-web.xml file (app.yaml for Python). They still can be set there, but are then being ignored, as the deployment process points out prominently.

The project ID MyProject must now be specified as part of the general glcoud command-line interface configuration (that can be viewed through gcloud config configurations list). The Gradle plugin seems to be picking it up from there just fine.

For the version 1-2-0, however, I cannot figure out where and how to set it. So, on deployment I always end up with a new default like 20170604t124930, and lots of redundant app versions.

For a prior Python app that I used appcfg (or was it a glcoud command?) to deploy for, I specified both project ID and version as command line arguments. The Gradle pluging must be finding (or not finding) this information somewhere else. The Gradle file's version = '1.2.0-SNAPSHOT' of course is just for the generated jar/war. The many suggestions on the web, the official Google documentation (!), and this site like here are outdated, contradictory, or both (therefore, you'll excuse my lengthy, rather detailed post). Thanks!


Solution

  • The simple answer can be found at the bottom of the App Engine Gradle Plugin Tasks and Properties. Just add this to build.gradle:

    appengine.deploy.version = '1-2-0'

    Or, as part of the more extensive app engine plugin configuration:

    appengine {
    
      deploy {
        ...
        version = '1-2-0
      }
    }
    

    My confusion seems to stem from the fact that there is the old Gradle plugin and the new one, and handling did change quite a bit between the two. In particular, the new plugin is more dependent on the glcoud configuration. The plugin as-is does allow to set the project ID (appengine.deploy.project) in the Gradle configuration, yet, when not specified there, just takes the default from the list of available projects (command line: gcloud config list project -- the old appcfg isn't used anymore).

    However, there is no such default for the version in the environment, when the version is missing from the Gradle configuration. A new timestamp string is taken on every deploy in this case.