From 75c80b5e240e45ce0e47b47739395a47a0ad1d1b Mon Sep 17 00:00:00 2001 From: jianglai Date: Tue, 12 Feb 2019 08:11:02 -0800 Subject: [PATCH] Create WAR files ready for deployment This makes sure that the WAR files created by running "gradle stage" can be deployed by appcfg (tested the pubapi service on alpha). We need to copy all the static html files regardless of the service because the error.html handler is registered for sandbox and production environments across services. Without those files the gradle app engine plugin refuses to create the WAR files. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=233608424 --- .gitignore | 2 +- cloudbuild-nomulus.yaml | 6 +++++- gradle/build.gradle | 35 +++++++++++++++++++++++++++-------- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 7d0db63f6..25a177842 100644 --- a/.gitignore +++ b/.gitignore @@ -82,7 +82,7 @@ autogenerated/ # We don't want to ignore the gradle jar files !/gradle/gradle/wrapper/**/*.jar - +.gradle/ /gradle/.gradle /gradle/**/WEB-INF /gradle/**/build diff --git a/cloudbuild-nomulus.yaml b/cloudbuild-nomulus.yaml index dc31e30a5..33102887b 100644 --- a/cloudbuild-nomulus.yaml +++ b/cloudbuild-nomulus.yaml @@ -30,6 +30,7 @@ steps: - '-x' - 'autoLintGradle' - '-PrepositoryUrl=gcs://domain-registry-maven-repository' + - '-Penvironment=${_ENVIRONMENT}' dir: 'gradle' # Tar the deployment files as we cannot upload directories to GCS. - name: 'alpine' @@ -47,12 +48,15 @@ steps: # Tar files to upload to GCS. artifacts: objects: - location: 'gs://${PROJECT_ID}-deploy/${TAG_NAME}' + location: 'gs://${PROJECT_ID}-deploy/${TAG_NAME}/${_ENVIRONMENT}' paths: - 'gradle/services/default.tar' - 'gradle/services/pubapi.tar' - 'gradle/services/backend.tar' - 'gradle/services/tools.tar' timeout: 3600s +# Default values +substitutions: + _ENVIRONMENT: alpha options: machineType: 'N1_HIGHCPU_8' diff --git a/gradle/build.gradle b/gradle/build.gradle index f78728f51..e16df56a0 100644 --- a/gradle/build.gradle +++ b/gradle/build.gradle @@ -224,16 +224,32 @@ subprojects { ':services:tools', ':services:pubapi'] + def environments = ['production', 'sandbox', 'alpha', 'crash'] + + def projects = ['production': 'domain-registry', + 'sandbox' : 'domain-registry-sandbox', + 'alpha' : 'domain-registry-alpha', + 'crash' : 'domain-registry-crash'] + // Set up all of the deployment projects. if (services.contains(project.path)) { + def environment = rootProject.findProperty("environment") + if (environment == null) { + environment = 'alpha' + } + def gcpProject = projects[environment] + if (gcpProject == null) { + throw new GradleException("-Penvironment must be one of ${environments}.") + } + apply plugin: 'war' // Set this directory before applying the appengine plugin so that the // plugin will recognize this as an app-engine standard app (and also // obtains the appengine-web.xml from the correct location) project.convention.plugins['war'].webAppDirName = - "../../../java/google/registry/env/crash/${project.name}" + "../../../java/google/registry/env/${environment}/${project.name}" apply plugin: 'com.google.cloud.tools.appengine' @@ -244,13 +260,19 @@ subprojects { } } - if (project.path.contains("default")) { - def coreResourcesDir = "${rootDir}/core/build/resources/main" + def coreResourcesDir = "${rootDir}/core/build/resources/main" + war { + from("${coreResourcesDir}/google/registry/ui/html") { + include "*.html" + } + } + + if (project.path == ":services:default") { war { from("${coreResourcesDir}/google/registry/ui") { include "registrar_bin*" into("assets/js") - rename { String filename -> filename.replace("bin", "dbg")} + rename { String filename -> filename.replace("bin", "dbg") } } from("${coreResourcesDir}/google/registry/ui") { include "registrar_bin*" @@ -264,16 +286,13 @@ subprojects { include "**/*" into("assets/images") } - from("${coreResourcesDir}/google/registry/ui/html") { - include "*.html" - } } } appengine { deploy { // TODO: change this to a variable. - project = 'domain-registry-crash' + project = gcpProject } }