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
This commit is contained in:
jianglai 2019-02-12 08:11:02 -08:00
parent 0b3fee4ef1
commit 75c80b5e24
3 changed files with 33 additions and 10 deletions

2
.gitignore vendored
View file

@ -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

View file

@ -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'

View file

@ -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
}
}