Repository navigation
Expand file tree
/
Copy pathbuild.gradle
More file actions
197 lines (175 loc) · 5.34 KB
/
Copy pathbuild.gradle
File metadata and controls
197 lines (175 loc) · 5.34 KB
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
191
192
193
194
195
196
197
/*
* Copyright (C) 2007-2026 Crafter Software Corporation. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
plugins {
// The "de.undercouch.download" plugin allows Gradle to download files from the internet during the build process,
// making it easy to automate the retrieval of external dependencies, resources, or other files as part of your build.
id "de.undercouch.download" version "${undercouchDownloadVersion}"
}
apply plugin: "groovy"
apply plugin: 'de.undercouch.download'
project.version = craftercmsVersion
apply from: "global-settings.gradle"
apply from: "commons.gradle"
apply from: "modules.gradle"
apply from: "environments.gradle"
apply from: "downloads.gradle"
apply from: "deploy.gradle"
apply from: "run.gradle"
apply from: "docker.gradle"
apply from: "release.gradle"
apply from: "gradle/javadoc.gradle"
task splash() {
description = 'Displays splash screen'
doFirst {
splash()
}
}
task preFlightCheck() {
description = 'Checks dependencies'
dependsOn = ["splash"]
doFirst {
if (JavaVersion.current() != JavaVersion.VERSION_21) {
throw new GradleException("The java version used ${JavaVersion.current()} is not the expected version ${project.targetCompatibility}.")
}
def lsofCheck = "lsof -v"
if (!lsofCheck.execute()) {
throw new GradleException("'lsof' command not found, please make sure it is installed and accessible.")
}
}
}
task download() {
description = 'Downloads dependencies if required.'
dependsOn = ["preFlightCheck"]
doFirst {
def performDownload = true
getDownloads().each { download ->
downloadArtifact(
download['name'],
download['url'],
download['destinationFile'],
download['checksumAlgorithm'],
overwriteArtifact,
download['verifyArtifact'] == false ? false : true /* verify artifact */,
download['expand'].toBoolean(),
download['expandFolder']
)
}
}
}
task selfUpdate() {
description = 'Updates the CrafterCMS parent project.'
dependsOn = ["preFlightCheck"]
doFirst {
execCommand(["git", "pull", gitRemote, gitBranch], "${projectDir}")
}
}
task buildBaseEnvs() {
description = 'Build base target environments.'
dependsOn = ["download"]
doFirst {
getEnvironments().each { environment ->
println "Deploying the foundation of $environment"
prepareEnvironment(environment, refreshEnv, overwriteChangedFiles, downloadGrapes)
}
}
}
task buildBom() {
description = 'Builds the Software Bill of Materials (BOM).'
dependsOn = ["preFlightCheck"]
doFirst {
println "Build the Software Bill of Materials (BOM)"
getBuildModules().each { module ->
println "Building BOM for $module"
buildBom(module)
}
println "Aggregate BOMs"
aggregateBoms("${projectDir}")
}
}
task deploy() {
group = 'deployment'
description = 'Deploys module artifacts and prepares the authoring/delivery environments. ' +
'Use :<module>:deploy (e.g. :studio:deploy -Penv=authoring) to deploy a single module.'
mustRunAfter build
dependsOn = ["buildBaseEnvs"]
// Module deploy tasks are attached in deploy.gradle (projectsEvaluated).
}
// Nested build so clean/build/deploy are ordered and see scripts updated by selfUpdate,
// without spawning a second Gradle process against this project.
task upgrade(type: GradleBuild) {
description = 'Upgrades all modules and redeploys them'
dependsOn = ["selfUpdate"]
dir = projectDir
tasks = ['clean', 'build', 'deploy']
}
task start() {
description = 'Starts CrafterCMS'
doFirst {
getEnvironments().each { environment ->
println "Starting $environment"
def command = [startCommand]
if (!startSearch)
command += ["skipSearch"]
runEnvironment(environment, command)
}
}
}
task stop() {
description = 'Stops CrafterCMS'
doFirst {
getEnvironments().each { environment ->
println "Stopping $environment"
def command = [stopCommand]
if (!startSearch)
command += ["skipSearch"]
runEnvironment(environment, command)
}
}
}
task status() {
description = 'Reports CrafterCMS status'
doFirst {
getEnvironments().each { environment ->
def command = [statusCommand]
if (!startSearch)
command += ["skipSearch"]
runEnvironment(environment, command)
}
}
}
task bundle() {
description = 'Bundles the authoring/delivery environments into tarballs for distribution.'
dependsOn = ["deploy"]
doFirst {
getEnvironments().each { environment ->
println "Bundling $environment"
bundleEnvironment(environment, bundlesDir)
}
}
}
gradle.buildFinished {
// The root build dir only holds throwaway output, except for the aggregated javadoc sites
def rootBuildDir = project.layout.buildDirectory.get().asFile
def keep = aggregateJavadocDirName.tokenize('/').first()
rootBuildDir.listFiles()?.each { file ->
if (file.name != keep) {
file.directory ? file.deleteDir() : file.delete()
}
}
if (rootBuildDir.list()?.length == 0) {
rootBuildDir.deleteDir()
}
}