forked from craftercms/craftercms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.gradle
190 lines (166 loc) · 5.55 KB
/
deploy.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
apply from: "commons.gradle"
apply from: "environments.gradle"
ext.commonDeployArtifacts = [
[
module: 'deployer',
from: "${projectDir}/src/deployer/target/crafter-deployer.jar",
into: "/bin/crafter-deployer/"
],
[
module: 'engine',
from: "${projectDir}/src/engine/target/ROOT.war",
into: "/bin/apache-tomcat/webapps/"
],
[
module: 'profile',
from: "${projectDir}/src/profile/server/target/crafter-profile.war",
into: "/bin/apache-tomcat/webapps/"
],
[
module: 'profile-admin',
from: "${projectDir}/src/profile/admin-console/target/crafter-profile-admin.war",
into: "/bin/apache-tomcat/webapps/"
],
[
module: 'social',
from: "${projectDir}/src/social/server/target/crafter-social.war",
into: "/bin/apache-tomcat/webapps/"
],
[
module: 'social-admin',
from: "${projectDir}/src/social/admin/target/crafter-social-admin.war",
into: "/bin/apache-tomcat/webapps/"
],
[
module: 'cli',
from: "${projectDir}/src/cli/target/cli",
into: "/bin/"
]
]
ext.authoringDeployArtifacts = [
[
module: 'studio',
from: "${projectDir}/src/studio/target/studio.war",
into: "/bin/apache-tomcat/webapps/"
]
]
ext.deliveryDeployArtifacts = [
]
ext.commonDeployPermissions = [
[
items: [
"/crafter-cli"
],
permissions: [
"+x"
]
]
]
ext.authoringDeployPermissions = [
]
ext.deliveryDeployPermissions = [
]
ext.deployBaseEnvironment = { envFolder, modules, overwriteChangedFiles, profileRequired, socialRequired ->
// Deploy Crafter binaries into env
commonDeployArtifacts.each { item ->
def name = item.module
def from = item.from
def into = item.into
def exclude = ""
def performSync = true
// Skip Profile if it's not required nor is Social required (since Social depends on Profile)
if ((name == "profile" || name == "profile-admin")
&& (!profileRequired && !socialRequired)) {
performSync = false
}
// Skip Social if not required
if ((name == "social" || name == "social-admin")
&& !socialRequired) {
performSync = false
}
if (modules.find { it == name } == null) {
performSync = false
}
if (performSync) {
syncFolder("${projectDir}", from, envFolder + into, exclude, overwriteChangedFiles, true)
}
}
// Create CLI Symlink
// TODO: This is a bit messy, clean it up
def command = ["ln", "-sf", "cli/bin/crafter-cli", "bin/crafter-cli"]
execCommand(command, envFolder)
commonDeployPermissions.each { group ->
command = ["chmod"]
group['permissions'].each { permission ->
command << permission
}
group['items'].each { item ->
command << "bin" + item
}
execCommand(command, envFolder)
}
}
ext.deployAuthoringEnvironment = { modules, overwriteChangedFiles, profileRequired, socialRequired ->
deployBaseEnvironment("${authoringEnvDir}", modules, overwriteChangedFiles, profileRequired, socialRequired)
// Deploy Crafter binaries into env
authoringDeployArtifacts.each { item ->
def name = item.module
def from = item.from
def into = item.into
def exclude = ""
def performSync = true
if (modules.find { it == name } == null) {
performSync = false
}
if (performSync) {
syncFolder("${projectDir}", from, "${authoringEnvDir}" + into, exclude, overwriteChangedFiles, true)
}
}
authoringDeployPermissions.each { group ->
def command = ["chmod"]
group['permissions'].each { permission ->
command << permission
}
group['items'].each { item ->
command << "bin" + item
}
execCommand(command, "${authoringEnvDir}")
}
}
ext.deployDeliveryEnvironment = { modules, overwriteChangedFiles, profileRequired, socialRequired ->
deployBaseEnvironment("${deliveryEnvDir}", modules, overwriteChangedFiles, profileRequired, socialRequired)
// Deploy Crafter binaries into env
deliveryDeployArtifacts.each { item ->
def name = item.module
def from = item.from
def into = item.into
def exclude = ""
def performSync = true
if (modules.find { it == name } == null) {
performSync = false
}
if (performSync) {
syncFolder("${projectDir}", from, "${deliveryEnvDir}" + into, exclude, overwriteChangedFiles, true)
}
}
deliveryUpdatePermissions.each { group ->
def command = ["chmod"]
group['permissions'].each { permission ->
command << permission
}
group['items'].each { item ->
command << "bin" + item
}
execCommand(command, "${deliveryEnvDir}")
}
}
ext.deployEnvironment = { environment, modules, overwriteChangedFiles, profileRequired, socialRequired ->
if (environment == "authoring") {
deployAuthoringEnvironment(modules, overwriteChangedFiles, profileRequired, socialRequired)
} else if (environment == "delivery") {
deployDeliveryEnvironment(modules, overwriteChangedFiles, profileRequired, socialRequired)
} else {
logger.error("Unknown environment \"" + environment + "\"")
throw new GradleException("Unknown environment \"" + environment + "\"")
}
}