blob: 9dc853849ef0ec4862b6490673a76d54fcfb7fa8 [file] [log] [blame]
Young Gyu Park3ff7fcf2018-05-29 19:07:27 +09001import org.apache.tools.ant.filters.ReplaceTokens
2import com.google.cloud.tools.gradle.appengine.core.DeployTask
3
4buildscript {
5 ext {
6 springBootVersion = '1.5.13.RELEASE'
7 objectifyVersion = '6.0'
Young Gyu Parkef1bbb92018-10-16 17:46:08 +09008 jacksonVersion = '2.9.7'
Young Gyu Park3ff7fcf2018-05-29 19:07:27 +09009 googleCloudVersion = '0.47.0-alpha'
Young Gyu Parkcfe2ba52018-09-27 18:16:19 +090010 googleJavaFormatVersion = '0.7.1'
Young Gyu Parkef1bbb92018-10-16 17:46:08 +090011 googleHttpClientVersion = '1.25.0'
Young Gyu Parkcfe2ba52018-09-27 18:16:19 +090012 appGradlePluginVersion = '2.0.0-rc3'
Young Gyu Parkef1bbb92018-10-16 17:46:08 +090013 googleSheetsAPI = 'v4-rev548-1.25.0'
Young Gyu Park3ff7fcf2018-05-29 19:07:27 +090014 }
15 repositories {
16 jcenter()
17 mavenCentral()
18 maven {
Young Gyu Parkcfe2ba52018-09-27 18:16:19 +090019 url "https://plugins.gradle.org/m2/"
20 }
21 maven {
Young Gyu Park3ff7fcf2018-05-29 19:07:27 +090022 url 'https://oss.sonatype.org/content/repositories/snapshots/'
23 }
24 }
25 dependencies {
Young Gyu Park021de0e2018-07-23 11:12:04 +090026 classpath "com.google.cloud.tools:appengine-gradle-plugin:${appGradlePluginVersion}" // latest App Engine Gradle tasks
Young Gyu Park3ff7fcf2018-05-29 19:07:27 +090027 classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
Young Gyu Park3ff7fcf2018-05-29 19:07:27 +090028 }
29}
30
Young Gyu Parkcfe2ba52018-09-27 18:16:19 +090031plugins {
32 id 'war' // standard Web Archive plugin
33 id "com.github.sherter.google-java-format" version "0.7.1"
34}
35
36apply plugin: 'com.google.cloud.tools.appengine-standard' // App Engine tasks
37
Young Gyu Park3ff7fcf2018-05-29 19:07:27 +090038apply from: rootProject.file('gradle/profiles.gradle')
39
40group = 'com.android.vts'
41version = '4'
Young Gyu Parkcfe2ba52018-09-27 18:16:19 +090042description = "Google Android VTS dashboard"
Young Gyu Park3ff7fcf2018-05-29 19:07:27 +090043
44sourceCompatibility = 1.8
45targetCompatibility = 1.8
46
47
48repositories {
49 maven {
50 url 'https://oss.sonatype.org/content/repositories/snapshots' // SNAPSHOT repository (if needed)
51 }
52 mavenCentral()
53 jcenter()
54}
55
56dependencies {
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 Park85586062018-08-21 16:25:41 +090062 compile group: 'org.apache.commons', name: 'commons-lang3', version:'3.7'
Young Gyu Park3ff7fcf2018-05-29 19:07:27 +090063 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 Parkef1bbb92018-10-16 17:46:08 +090069 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 Park3ff7fcf2018-05-29 19:07:27 +090073 compile group: 'com.google.apis', name: 'google-api-services-oauth2', version:'v1-rev136-1.23.0'
Young Gyu Parkc0204c12018-06-26 11:36:17 +090074 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 Park3ff7fcf2018-05-29 19:07:27 +090077
Young Gyu Park82a17c32018-10-22 10:55:32 +090078 compile group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.11.1'
79
Young Gyu Parkef1bbb92018-10-16 17:46:08 +090080 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 Park85586062018-08-21 16:25:41 +090086 testCompile group: 'junit', name: 'junit', version: '4.12'
87 testCompile group: 'org.mockito', name: 'mockito-core', version: '2.21.0'
Young Gyu Park3ff7fcf2018-05-29 19:07:27 +090088 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
98appengineDeploy.dependsOn test
99appengineStage.dependsOn test
100
101googleJavaFormat {
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
110appengine { // App Engine tasks configuration
Young Gyu Parkcfe2ba52018-09-27 18:16:19 +0900111 tools {
112 // configure the Cloud Sdk tooling
113 }
114
Young Gyu Park3ff7fcf2018-05-29 19:07:27 +0900115 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 Park3ff7fcf2018-05-29 19:07:27 +0900123 "-Dappengine.fullscan.seconds=5"
124 ]
125 }
Young Gyu Parkcfe2ba52018-09-27 18:16:19 +0900126 stage {
127 // configure staging for deployment
128 }
Young Gyu Park3ff7fcf2018-05-29 19:07:27 +0900129 deploy { // deploy configuration
Young Gyu Parkcfe2ba52018-09-27 18:16:19 +0900130 version = project.property("appEngineVersion")
131 projectId = project.property("projectIdList")
Young Gyu Park3ff7fcf2018-05-29 19:07:27 +0900132
133 }
134}
135
136test {
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
152tasks.addRule("Pattern: vtsGaeDeploy<ID>") { String taskName ->
153 if (taskName.startsWith("vtsGaeDeploy-")) {
154
155 def projectId = taskName.replace("vtsGaeDeploy-", "")
Young Gyu Park021de0e2018-07-23 11:12:04 +0900156 def version = project.property("appEngineVersion")
157
Young Gyu Parkcfe2ba52018-09-27 18:16:19 +0900158 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 Park3ff7fcf2018-05-29 19:07:27 +0900165
Young Gyu Parkcfe2ba52018-09-27 18:16:19 +0900166 def gcsConfigCopy = task("gcsConfigCopy-${projectId}") {
Young Gyu Park3ff7fcf2018-05-29 19:07:27 +0900167 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 Park3ff7fcf2018-05-29 19:07:27 +0900185
Young Gyu Park3ff7fcf2018-05-29 19:07:27 +0900186 }
187 }
Young Gyu Parkcfe2ba52018-09-27 18:16:19 +0900188 gcsConfigCopy.dependsOn appengineWebCopy
189 gcsConfigCopy.mustRunAfter appengineWebCopy
Young Gyu Park3ff7fcf2018-05-29 19:07:27 +0900190
Young Gyu Parkcfe2ba52018-09-27 18:16:19 +0900191 def deployTaskList = [appengineDeploy]
Young Gyu Park3ff7fcf2018-05-29 19:07:27 +0900192
193 def vtsGaeDeployTask = task(taskName) {
194
195 doFirst {
Young Gyu Parkcfe2ba52018-09-27 18:16:19 +0900196 println "--------------> setup deploying tasks <-------------"
Young Gyu Park3ff7fcf2018-05-29 19:07:27 +0900197 }
198
199 doLast {
Young Gyu Park3ff7fcf2018-05-29 19:07:27 +0900200 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 Parkcfe2ba52018-09-27 18:16:19 +0900210 deployTaskList.push(value)
Young Gyu Park3ff7fcf2018-05-29 19:07:27 +0900211 }
212 }
213 }
214 }
215
Young Gyu Parkcfe2ba52018-09-27 18:16:19 +0900216 vtsGaeDeployTask.dependsOn gcsConfigCopy
217 vtsGaeDeployTask.mustRunAfter gcsConfigCopy
218 vtsGaeDeployTask.finalizedBy deployTaskList
Young Gyu Park3ff7fcf2018-05-29 19:07:27 +0900219 }
220}
221
222task 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}