forked from craftercms/craftercms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
global-settings.gradle
123 lines (113 loc) · 6.73 KB
/
global-settings.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
/*
* Copyright (C) 2007-2023 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/>.
*/
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath group: 'org.apache.commons', name: 'commons-lang3', version: project.property('commons-lang3.version')
}
}
import org.apache.commons.lang3.SystemUtils
ext.getPropertySafelyWithDefaults = {
prop, propDefault ->
project.ext.set("ret", project.hasProperty(prop) ? project.property(prop).toString() : propDefault)
return ret
}
def commandTimeout = getPropertySafelyWithDefaults("commandTimeout", 1000000).toInteger()
ext.execDetermineLinuxOSWithVersion = {
def os = new File('/etc/os-release').text.split('\n').find { it.startsWith('NAME=') }?.split('=')[1]
def version = new File('/etc/os-release').text.split('\n').find { it.startsWith('VERSION_ID=') }?.split('=')[1]
if (os == null || version == null) {
println "Cannot determine the operating system."
return "unsupportedOS"
}
version = version.replaceAll("\"", "").replaceAll("\'", "").replaceAll("\\.", "").trim()
switch (os) {
case ~/.*Ubuntu.*/:
return "ubuntu${version}"
case ~/.*Linux Mint.*/:
def ubuntuVersion
def releaseFile = new File('/etc/upstream-release/lsb-release')
if (releaseFile.exists()) {
ubuntuVersion = releaseFile.text.split('\n').find { it.startsWith('DISTRIB_RELEASE=') }?.split('=')[1]
}
if (ubuntuVersion == null) {
// try best to manually map LinuxMint to Ubuntu version
if (version.startsWith("19")) {
ubuntuVersion = "1804"
} else if (version.startsWith("20")) {
ubuntuVersion = "2004"
} else if (version.startsWith("21")) {
ubuntuVersion = "2204"
} else {
// Default, should be updated with new release of LinuxMint
ubuntuVersion = "2204"
}
}
ubuntuVersion = ubuntuVersion.replaceAll("\"", "").replaceAll("\'", "").replaceAll("\\.", "").trim()
return "ubuntu${ubuntuVersion}"
case ~/.*Red Hat Enterprise Linux.*/:
return "rhel${version}"
default:
println "Operating system is not Ubuntu, Linux Mint, or Red Hat."
return "unsupportedOS"
}
}
project.ext.set("overwriteArtifact", getPropertySafelyWithDefaults("refreshDownloads", "false").toBoolean())
project.ext.set("overwriteChangedFiles", getPropertySafelyWithDefaults("overwriteChangedFiles", "true").toBoolean())
project.ext.set("refreshEnv", getPropertySafelyWithDefaults("refreshEnv", "false").toBoolean())
project.ext.set("downloadGrapes", getPropertySafelyWithDefaults("downloadGrapes", "true").toBoolean())
project.ext.set("socialRequired", getPropertySafelyWithDefaults("crafter.social", "false").toBoolean()
|| getPropertySafelyWithDefaults("socialRequired", "false").toBoolean())
project.ext.set("profileRequired", (getPropertySafelyWithDefaults("crafter.profile", "false").toBoolean()
|| (getPropertySafelyWithDefaults("profileRequired", "false").toBoolean()
|| socialRequired)))
project.ext.set("unitTest", getPropertySafelyWithDefaults("unitTest", "false").toBoolean())
project.ext.set("startMongoDB", getPropertySafelyWithDefaults("startMongodb", (profileRequired || socialRequired)).toBoolean())
project.ext.set("startSearch", getPropertySafelyWithDefaults("startSearch", getPropertySafelyWithDefaults("withSearch", "true")).toBoolean())
project.ext.set("startCommand", project.hasProperty("debug") ? "debug" : "start")
project.ext.set("stopCommand", "stop")
project.ext.set("statusCommand", "status")
project.ext.set("gitUrl", getPropertySafelyWithDefaults("gitUrl", "https://github.com/craftercms/"))
project.ext.set("gitRemote", getPropertySafelyWithDefaults("gitRemote", "origin"))
project.ext.set("shallowClone", getPropertySafelyWithDefaults("shallowClone", "false").toBoolean())
project.ext.set("gitBranch", "develop") // craftercms branch flag
project.ext.set("bundlesDir", getPropertySafelyWithDefaults(bundlesDir, "./bundles"))
project.ext.set("crafterCmd", getPropertySafelyWithDefaults("crafterCmd", "./crafter.sh"))
project.ext.set("currentPlatform", getPropertySafelyWithDefaults("currentPlatform", SystemUtils.IS_OS_MAC_OSX ? "darwin" : "linux"))
project.ext.set("currentArch", getPropertySafelyWithDefaults("currentArch", SystemUtils.OS_ARCH == "aarch64" ? "aarch64" : "x86_64"))
project.ext.set("openSearchPlatform", getPropertySafelyWithDefaults("openSearchPlatform", "linux"))
project.ext.set("openSearchArch", getPropertySafelyWithDefaults("openSearchArch", "x64"))
project.ext.set("mongodbPlatform", getPropertySafelyWithDefaults("mongodbPlatform", currentPlatform == "darwin" ? "osx" : currentPlatform))
project.ext.set("mongodbBinary", getPropertySafelyWithDefaults("mongodbBinary", currentPlatform == "darwin" ? "macos" : currentPlatform))
project.ext.set("mongoExtension", getPropertySafelyWithDefaults("mongoExtension", currentPlatform == "darwin" ? "zip" : "tgz"))
if (currentPlatform == "darwin") {
project.ext.set("mongodbArch", getPropertySafelyWithDefaults("mongodbArch", currentArch == "aarch64" ? "arm64" : "x86_64"))
project.ext.set("mongoshArch", getPropertySafelyWithDefaults("mongoshArch", currentArch == "aarch64" ? "arm64" : "x64"))
project.ext.set("mongoToolsArch", getPropertySafelyWithDefaults("mongoToolsArch", currentArch == "aarch64" ? "macos-arm64" : "macos-x86_64"))
} else {
project.ext.set("mongodbArch", getPropertySafelyWithDefaults("mongodbArch", "x86_64-${execDetermineLinuxOSWithVersion()}"))
project.ext.set("mongoshArch", getPropertySafelyWithDefaults("mongoshArch", "x64"))
project.ext.set("mongoToolsArch", getPropertySafelyWithDefaults("mongoToolsArch", "${execDetermineLinuxOSWithVersion()}-x86_64"))
}
project.ext.set("pushDockerImages", getPropertySafelyWithDefaults("pushDockerImages", "false").toBoolean())
project.ext.set("tagDockerImages", getPropertySafelyWithDefaults("tagDockerImages", ""))
project.ext.set("rootlessDockerImages", getPropertySafelyWithDefaults("rootlessDockerImages", "false").toBoolean())
project.ext.set("dockerTag", getPropertySafelyWithDefaults("dockerTag", ""))
project.ext.set("dockerEnterprise", getPropertySafelyWithDefaults("dockerEnterprise", "false").toBoolean())
project.ext.set("dockerAuthoringBundle", getPropertySafelyWithDefaults("dockerAuthoringBundle", ""))
project.ext.set("dockerDeliveryBundle", getPropertySafelyWithDefaults("dockerDeliveryBundle", ""))