-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle
81 lines (71 loc) · 3.26 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import gov.nyc.doitt.nyc.gis.gradle.*
plugins {
id 'base'
id 'org.hidetake.ssh' version '1.1.2'
}
ext {
appName = 'nyc-tile-example'
ver = 'v0.2.3'
pkgDir = "${buildDir}/${appName}/${ver}"
remoteDir = 'tiles'
}
task copyFiles() {
file(pkgDir).mkdirs()
copy {
from 'src/main/webapp'
into pkgDir
}
println 'replaceHostName.doFirst ' + file("${pkgDir}/openlayers.html").exists()
}
task replaceHostName(dependsOn: [copyFiles]) {
def tilehost = project.hasProperty('tilehost') ? project.getProperty('tilehost') : ''
if (tilehost != ''){
ant.taskdef(name: 'replace', classname: 'org.apache.tools.ant.taskdefs.Replace')
def olTilehost = (tilehost =~ /\-/).replaceFirst('{1-4}-')
def leafTilehost = (tilehost =~ /\-/).replaceFirst('{s}-')
def arcTilehost = (tilehost =~ /\-/).replaceFirst('{subDomain}-')
ant.replace(file: "${pkgDir}/openlayers-tms.html", token: 'maps{1-4}.nyc.gov', value: olTilehost)
ant.replace(file: "${pkgDir}/openlayers-xyz.html", token: 'maps{1-4}.nyc.gov', value: olTilehost)
ant.replace(file: "${pkgDir}/openlayers-wmts.html", token: 'maps.nyc.gov', value: tilehost)
ant.replace(file: "${pkgDir}/leaflet-tms.html", token: 'maps{s}.nyc.gov', value: leafTilehost)
ant.replace(file: "${pkgDir}/leaflet-xyz.html", token: 'maps{s}.nyc.gov', value: leafTilehost)
ant.replace(file: "${pkgDir}/arcgis3-tms.html", token: 'maps{subDomain}.nyc.gov', value: arcTilehost)
ant.replace(file: "${pkgDir}/arcgis3-xyz.html", token: 'maps{subDomain}.nyc.gov', value: arcTilehost)
ant.replace(file: "${pkgDir}/arcgis3-wmts.html", token: 'maps.nyc.gov', value: tilehost)
ant.replace(file: "${pkgDir}/arcgis4-tms.html", token: 'maps{subDomain}.nyc.gov', value: arcTilehost)
ant.replace(file: "${pkgDir}/arcgis4-xyz.html", token: 'maps{subDomain}.nyc.gov', value: arcTilehost)
ant.replace(file: "${pkgDir}/index.html", token: 'maps{1-4}.nyc.gov', value: olTilehost)
ant.replace(file: "${pkgDir}/index.html", token: 'maps{s}.nyc.gov', value: leafTilehost)
ant.replace(file: "${pkgDir}/index.html", token: 'maps{subDomain}.nyc.gov', value: arcTilehost)
ant.replace(file: "${pkgDir}/index.html", token: 'https://maps.nyc.gov', value: "https://${tilehost}")
}
}
task archive(type: Zip, dependsOn: [replaceHostName]) {
archiveName = "nyc-tile-example-${ver}.zip"
from {pkgDir}
}
remotes {
deployTarget {}
}
task deploy(dependsOn: [archive]) << {
def mobileDir = project.ext['mobile.dir']
def archiveDir = "${mobileDir}/${appName}/archive"
def deployDir = "${mobileDir}/${remoteDir}"
remotes.deployTarget.host = project.ext["${env}.host"]
remotes.deployTarget.user = project.ext["${env}.user"]
remotes.deployTarget.identity = file("${System.properties['user.home']}/.ssh/id_rsa")
ssh.run {
session(remotes.deployTarget) {
execute "mkdir -p ${archiveDir}"
execute "mkdir -p ${deployDir}"
put "build/distributions/${archive.archiveName}", archiveDir
execute "cp -R ${deployDir} ${deployDir}.bak"
execute "rm -rf ${deployDir}"
execute "unzip ${archiveDir}/${archive.archiveName} -d ${deployDir}"
execute "rm -rf ${deployDir}.bak"
}
}
}
task wrapper(type: Wrapper) {
gradleVersion '3.1'
}