Young Gyu Park | 3ff7fcf | 2018-05-29 19:07:27 +0900 | [diff] [blame] | 1 | import org.apache.tools.ant.filters.ReplaceTokens |
| 2 | import com.google.cloud.tools.gradle.appengine.core.DeployTask |
| 3 | |
| 4 | buildscript { |
| 5 | ext { |
| 6 | springBootVersion = '1.5.13.RELEASE' |
| 7 | objectifyVersion = '6.0' |
Young Gyu Park | ef1bbb9 | 2018-10-16 17:46:08 +0900 | [diff] [blame] | 8 | jacksonVersion = '2.9.7' |
Young Gyu Park | 3ff7fcf | 2018-05-29 19:07:27 +0900 | [diff] [blame] | 9 | googleCloudVersion = '0.47.0-alpha' |
Young Gyu Park | cfe2ba5 | 2018-09-27 18:16:19 +0900 | [diff] [blame] | 10 | googleJavaFormatVersion = '0.7.1' |
Young Gyu Park | ef1bbb9 | 2018-10-16 17:46:08 +0900 | [diff] [blame] | 11 | googleHttpClientVersion = '1.25.0' |
Young Gyu Park | cfe2ba5 | 2018-09-27 18:16:19 +0900 | [diff] [blame] | 12 | appGradlePluginVersion = '2.0.0-rc3' |
Young Gyu Park | ef1bbb9 | 2018-10-16 17:46:08 +0900 | [diff] [blame] | 13 | googleSheetsAPI = 'v4-rev548-1.25.0' |
Young Gyu Park | 3ff7fcf | 2018-05-29 19:07:27 +0900 | [diff] [blame] | 14 | } |
| 15 | repositories { |
| 16 | jcenter() |
| 17 | mavenCentral() |
| 18 | maven { |
Young Gyu Park | cfe2ba5 | 2018-09-27 18:16:19 +0900 | [diff] [blame] | 19 | url "https://plugins.gradle.org/m2/" |
| 20 | } |
| 21 | maven { |
Young Gyu Park | 3ff7fcf | 2018-05-29 19:07:27 +0900 | [diff] [blame] | 22 | url 'https://oss.sonatype.org/content/repositories/snapshots/' |
| 23 | } |
| 24 | } |
| 25 | dependencies { |
Young Gyu Park | 021de0e | 2018-07-23 11:12:04 +0900 | [diff] [blame] | 26 | classpath "com.google.cloud.tools:appengine-gradle-plugin:${appGradlePluginVersion}" // latest App Engine Gradle tasks |
Young Gyu Park | 3ff7fcf | 2018-05-29 19:07:27 +0900 | [diff] [blame] | 27 | classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}" |
Young Gyu Park | 3ff7fcf | 2018-05-29 19:07:27 +0900 | [diff] [blame] | 28 | } |
| 29 | } |
| 30 | |
Young Gyu Park | cfe2ba5 | 2018-09-27 18:16:19 +0900 | [diff] [blame] | 31 | plugins { |
| 32 | id 'war' // standard Web Archive plugin |
| 33 | id "com.github.sherter.google-java-format" version "0.7.1" |
| 34 | } |
| 35 | |
| 36 | apply plugin: 'com.google.cloud.tools.appengine-standard' // App Engine tasks |
| 37 | |
Young Gyu Park | 3ff7fcf | 2018-05-29 19:07:27 +0900 | [diff] [blame] | 38 | apply from: rootProject.file('gradle/profiles.gradle') |
| 39 | |
| 40 | group = 'com.android.vts' |
| 41 | version = '4' |
Young Gyu Park | cfe2ba5 | 2018-09-27 18:16:19 +0900 | [diff] [blame] | 42 | description = "Google Android VTS dashboard" |
Young Gyu Park | 3ff7fcf | 2018-05-29 19:07:27 +0900 | [diff] [blame] | 43 | |
| 44 | sourceCompatibility = 1.8 |
| 45 | targetCompatibility = 1.8 |
| 46 | |
| 47 | |
| 48 | repositories { |
| 49 | maven { |
| 50 | url 'https://oss.sonatype.org/content/repositories/snapshots' // SNAPSHOT repository (if needed) |
| 51 | } |
| 52 | mavenCentral() |
| 53 | jcenter() |
| 54 | } |
| 55 | |
| 56 | dependencies { |
| 57 | compile 'com.google.appengine:appengine-api-1.0-sdk:+' // Latest App Engine Api's |
| 58 | providedCompile 'javax.servlet:javax.servlet-api:3.1.0' |
| 59 | |
| 60 | compile 'jstl:jstl:1.2' |
| 61 | |
Young Gyu Park | 8558606 | 2018-08-21 16:25:41 +0900 | [diff] [blame] | 62 | compile group: 'org.apache.commons', name: 'commons-lang3', version:'3.7' |
Young Gyu Park | 3ff7fcf | 2018-05-29 19:07:27 +0900 | [diff] [blame] | 63 | compile group: 'org.apache.commons', name: 'commons-math3', version:'3.6.1' |
| 64 | compile group: 'commons-codec', name: 'commons-codec', version:'1.9' |
| 65 | compile group: 'com.google.cloud', name: 'google-cloud', version: "${googleCloudVersion}" |
| 66 | compile group: 'com.google.code.gson', name: 'gson', version:'2.7' |
| 67 | compile group: 'com.googlecode.objectify', name: 'objectify', version: "${objectifyVersion}" |
| 68 | compile group: 'org.json', name: 'json', version:'20180130' |
Young Gyu Park | ef1bbb9 | 2018-10-16 17:46:08 +0900 | [diff] [blame] | 69 | compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: "${jacksonVersion}" |
| 70 | compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: "${jacksonVersion}" |
| 71 | compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: "${jacksonVersion}" |
| 72 | |
Young Gyu Park | 3ff7fcf | 2018-05-29 19:07:27 +0900 | [diff] [blame] | 73 | compile group: 'com.google.apis', name: 'google-api-services-oauth2', version:'v1-rev136-1.23.0' |
Young Gyu Park | c0204c1 | 2018-06-26 11:36:17 +0900 | [diff] [blame] | 74 | compile group: 'com.google.http-client', name: 'google-http-client', version: "${googleHttpClientVersion}" |
| 75 | compile group: 'com.google.http-client', name: 'google-http-client-protobuf', version: "${googleHttpClientVersion}" |
| 76 | compile group: 'com.google.visualization', name: 'visualization-datasource', version:'1.1.1' |
Young Gyu Park | 3ff7fcf | 2018-05-29 19:07:27 +0900 | [diff] [blame] | 77 | |
Young Gyu Park | 82a17c3 | 2018-10-22 10:55:32 +0900 | [diff] [blame] | 78 | compile group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.11.1' |
| 79 | |
Young Gyu Park | ef1bbb9 | 2018-10-16 17:46:08 +0900 | [diff] [blame] | 80 | compile(group: 'com.google.api-client', name: 'google-api-client', version: "${googleHttpClientVersion}") { |
| 81 | exclude(module: 'guava-jdk5') |
| 82 | } |
| 83 | compile group: 'com.google.oauth-client', name: 'google-oauth-client-jetty', version: "${googleHttpClientVersion}" |
| 84 | compile group: 'com.google.apis', name: 'google-api-services-sheets', version: "${googleSheetsAPI}" |
| 85 | |
Young Gyu Park | 8558606 | 2018-08-21 16:25:41 +0900 | [diff] [blame] | 86 | testCompile group: 'junit', name: 'junit', version: '4.12' |
| 87 | testCompile group: 'org.mockito', name: 'mockito-core', version: '2.21.0' |
Young Gyu Park | 3ff7fcf | 2018-05-29 19:07:27 +0900 | [diff] [blame] | 88 | testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-api', version:'5.0.3' |
| 89 | |
| 90 | testCompile 'com.google.appengine:appengine-testing:+' |
| 91 | testCompile 'com.google.appengine:appengine-api-stubs:+' |
| 92 | testCompile 'com.google.appengine:appengine-tools-sdk:+' |
| 93 | |
| 94 | providedCompile group: 'org.projectlombok', name: 'lombok', version: '1.16.20' |
| 95 | } |
| 96 | |
| 97 | // Always run unit tests |
| 98 | appengineDeploy.dependsOn test |
| 99 | appengineStage.dependsOn test |
| 100 | |
| 101 | googleJavaFormat { |
| 102 | toolVersion = '1.6' |
| 103 | options style: 'AOSP' |
| 104 | source = sourceSets*.allJava |
| 105 | include '**/*.java' |
| 106 | exclude '**/*Template.java' |
| 107 | exclude 'src/test/template_*' |
| 108 | } |
| 109 | |
| 110 | appengine { // App Engine tasks configuration |
Young Gyu Park | cfe2ba5 | 2018-09-27 18:16:19 +0900 | [diff] [blame] | 111 | tools { |
| 112 | // configure the Cloud Sdk tooling |
| 113 | } |
| 114 | |
Young Gyu Park | 3ff7fcf | 2018-05-29 19:07:27 +0900 | [diff] [blame] | 115 | run { |
| 116 | environment = [ |
| 117 | GOOGLE_CLOUD_PROJECT: "android-vts-staging", |
| 118 | // DATASTORE_USE_PROJECT_ID_AS_APP_ID: "true", |
| 119 | ] |
| 120 | port = 8080 |
| 121 | jvmFlags = [ |
| 122 | "-Xdebug", |
Young Gyu Park | 3ff7fcf | 2018-05-29 19:07:27 +0900 | [diff] [blame] | 123 | "-Dappengine.fullscan.seconds=5" |
| 124 | ] |
| 125 | } |
Young Gyu Park | cfe2ba5 | 2018-09-27 18:16:19 +0900 | [diff] [blame] | 126 | stage { |
| 127 | // configure staging for deployment |
| 128 | } |
Young Gyu Park | 3ff7fcf | 2018-05-29 19:07:27 +0900 | [diff] [blame] | 129 | deploy { // deploy configuration |
Young Gyu Park | cfe2ba5 | 2018-09-27 18:16:19 +0900 | [diff] [blame] | 130 | version = project.property("appEngineVersion") |
| 131 | projectId = project.property("projectIdList") |
Young Gyu Park | 3ff7fcf | 2018-05-29 19:07:27 +0900 | [diff] [blame] | 132 | |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | test { |
| 137 | useJUnit() |
| 138 | testLogging.showStandardStreams = true |
| 139 | beforeTest { descriptor -> |
| 140 | logger.lifecycle("test: " + descriptor + " Running") |
| 141 | } |
| 142 | |
| 143 | onOutput { descriptor, event -> |
| 144 | logger.lifecycle("test: " + descriptor + ": " + event.message ) |
| 145 | } |
| 146 | afterTest { descriptor, result -> |
| 147 | logger.lifecycle("test: " + descriptor + ": " + result ) |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | |
| 152 | tasks.addRule("Pattern: vtsGaeDeploy<ID>") { String taskName -> |
| 153 | if (taskName.startsWith("vtsGaeDeploy-")) { |
| 154 | |
| 155 | def projectId = taskName.replace("vtsGaeDeploy-", "") |
Young Gyu Park | 021de0e | 2018-07-23 11:12:04 +0900 | [diff] [blame] | 156 | def version = project.property("appEngineVersion") |
| 157 | |
Young Gyu Park | cfe2ba5 | 2018-09-27 18:16:19 +0900 | [diff] [blame] | 158 | def appengineWebCopy = tasks.create(name: "appengineWebCopy-${projectId}", type: Copy) { |
| 159 | from "${webAppDirName}/WEB-INF/appengine-web.xml" |
| 160 | into "${appengine.stage.sourceDirectory}/WEB-INF" |
| 161 | filter(ReplaceTokens, tokens: [PROJECT_ID: projectId]) |
| 162 | } |
| 163 | appengineWebCopy.dependsOn appengineStage |
| 164 | appengineWebCopy.mustRunAfter appengineStage |
Young Gyu Park | 3ff7fcf | 2018-05-29 19:07:27 +0900 | [diff] [blame] | 165 | |
Young Gyu Park | cfe2ba5 | 2018-09-27 18:16:19 +0900 | [diff] [blame] | 166 | def gcsConfigCopy = task("gcsConfigCopy-${projectId}") { |
Young Gyu Park | 3ff7fcf | 2018-05-29 19:07:27 +0900 | [diff] [blame] | 167 | doFirst { |
| 168 | println "============ resource folder processing ============" |
| 169 | |
| 170 | if (project.loadConfigFromGcs.toBoolean()) { |
| 171 | exec { |
| 172 | println "The resources folder will be copied from GCS!" |
| 173 | commandLine "gsutil", |
| 174 | "cp", |
| 175 | "-R", |
| 176 | "${project.gcsConfigPath}${project.mode}/dashboard/${projectId}/resources/*", |
| 177 | "$appengine.stage.stagingDirectory/WEB-INF/classes" |
| 178 | } |
| 179 | } else { |
| 180 | println "The local resource folder will be used!" |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | doLast { |
Young Gyu Park | 3ff7fcf | 2018-05-29 19:07:27 +0900 | [diff] [blame] | 185 | |
Young Gyu Park | 3ff7fcf | 2018-05-29 19:07:27 +0900 | [diff] [blame] | 186 | } |
| 187 | } |
Young Gyu Park | cfe2ba5 | 2018-09-27 18:16:19 +0900 | [diff] [blame] | 188 | gcsConfigCopy.dependsOn appengineWebCopy |
| 189 | gcsConfigCopy.mustRunAfter appengineWebCopy |
Young Gyu Park | 3ff7fcf | 2018-05-29 19:07:27 +0900 | [diff] [blame] | 190 | |
Young Gyu Park | cfe2ba5 | 2018-09-27 18:16:19 +0900 | [diff] [blame] | 191 | def deployTaskList = [appengineDeploy] |
Young Gyu Park | 3ff7fcf | 2018-05-29 19:07:27 +0900 | [diff] [blame] | 192 | |
| 193 | def vtsGaeDeployTask = task(taskName) { |
| 194 | |
| 195 | doFirst { |
Young Gyu Park | cfe2ba5 | 2018-09-27 18:16:19 +0900 | [diff] [blame] | 196 | println "--------------> setup deploying tasks <-------------" |
Young Gyu Park | 3ff7fcf | 2018-05-29 19:07:27 +0900 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | doLast { |
Young Gyu Park | 3ff7fcf | 2018-05-29 19:07:27 +0900 | [diff] [blame] | 200 | def commandKeyList = [ |
| 201 | 'enableAppengineDeployCron': appengineDeployCron, |
| 202 | 'enableAppengineDeployDispatch': appengineDeployDispatch, |
| 203 | 'enableAppengineDeployDos': appengineDeployDos, |
| 204 | 'enableAppengineDeployIndex': appengineDeployIndex, |
| 205 | 'enableAppengineDeployQueue': appengineDeployQueue |
| 206 | ] |
| 207 | |
| 208 | commandKeyList.each { key, value -> |
| 209 | if (project.hasProperty(key) && project.getProperty(key).toBoolean()) { |
Young Gyu Park | cfe2ba5 | 2018-09-27 18:16:19 +0900 | [diff] [blame] | 210 | deployTaskList.push(value) |
Young Gyu Park | 3ff7fcf | 2018-05-29 19:07:27 +0900 | [diff] [blame] | 211 | } |
| 212 | } |
| 213 | } |
| 214 | } |
| 215 | |
Young Gyu Park | cfe2ba5 | 2018-09-27 18:16:19 +0900 | [diff] [blame] | 216 | vtsGaeDeployTask.dependsOn gcsConfigCopy |
| 217 | vtsGaeDeployTask.mustRunAfter gcsConfigCopy |
| 218 | vtsGaeDeployTask.finalizedBy deployTaskList |
Young Gyu Park | 3ff7fcf | 2018-05-29 19:07:27 +0900 | [diff] [blame] | 219 | } |
| 220 | } |
| 221 | |
| 222 | task vtsGaeMultiDeploy { |
| 223 | dependsOn { |
| 224 | def taskList = [] |
| 225 | def projectIdList = project.property("projectIdList") |
| 226 | projectIdList.split(",").each { projectId -> |
| 227 | taskList.push(tasks.findByName("vtsGaeDeploy-${projectId.trim()}".toString())) |
| 228 | } |
| 229 | return taskList |
| 230 | } |
| 231 | } |