-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathjdk.gradle
173 lines (144 loc) · 3.92 KB
/
jdk.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
enum TargetOS {
WINDOWS_AMD64( 'windows-x64','windows-amd64', 'zip', '' ),
LINUX_AMD64( 'linux-x64','linux-amd64', 'tar.gz', '' ),
LINUX_ARM64( 'linux-aarch64','linux-aarch64', 'tar.gz', '' ),
MAC_AMD64( 'macos-x64','darwin-amd64', 'tar.gz', 'Contents/Home' ),
MAC_ARM64( 'macos-aarch64','darwin-aarch64', 'tar.gz', 'Contents/Home' ),
GENERIC( null, null, null, null )
String downloadPlatform
String downloadExt
String archiveJavaHome
String graalvmVersion = '23.1.3'
String vmDownloadPlatform
String jdkVersion = '21.0.3'
TargetOS( String vmDownloadPlatform, String downloadPlatform, String downloadExt, String archiveJavaHome )
{
this.vmDownloadPlatform = vmDownloadPlatform
this.downloadPlatform = downloadPlatform
this.downloadExt = downloadExt
this.archiveJavaHome = archiveJavaHome
this.graalvmVersion = graalvmVersion
}
String toJdkPackageName()
{
return "graalvm-jdk-${jdkVersion}_${vmDownloadPlatform}_bin"
}
String toJdkPackageFile()
{
def jdkPackageName = toJdkPackageName()
return "${jdkPackageName}.${downloadExt}"
}
String toDownloadString()
{
def jdkPackageFile = toJdkPackageFile()
return "https://download.oracle.com/graalvm/21/archive/${jdkPackageFile}"
}
static from( String targetPlatform )
{
if ( targetPlatform == 'windows' )
{
return WINDOWS_AMD64
}
else if ( targetPlatform == 'linux' )
{
return LINUX_AMD64
}
else if ( targetPlatform == 'linux-arm64' )
{
return LINUX_ARM64
}
else if ( targetPlatform == 'mac' )
{
return MAC_AMD64
}
else if ( targetPlatform == 'mac-arm64' )
{
return MAC_ARM64
}
else if ( targetPlatform == 'generic' )
{
return GENERIC
}
else
{
throw new GradleException( 'Build target platform not supported: ' + targetPlatform )
}
}
}
def getTargetOS()
{
if ( ext.targetOS != null )
{
return ext.targetOS
}
ext.targetOS = TargetOS.from( getTargetOsName() )
return ext.targetOS
}
def getJdkPackageFile()
{
return isGenericBuild() ? null : getTargetOS().toJdkPackageFile()
}
def getJdkPackageName()
{
return isGenericBuild() ? null : getTargetOS().toJdkPackageName()
}
def getJdkDownloadUrl()
{
return isGenericBuild() ? null : getTargetOS().toDownloadString()
}
def isGenericBuild()
{
return getTargetOS() == TargetOS.GENERIC
}
def getArchiveJavaHome()
{
return getTargetOS().archiveJavaHome
}
def isSdkBuild()
{
return getTargetTypeName() == 'sdk'
}
def withDistTar()
{
return ['linux', 'linux-arm64', 'mac', 'mac-arm64', 'generic'].contains( getTargetOsName() )
}
def withDistZip()
{
return ['windows', 'generic'].contains( getTargetOsName() )
}
def withJava()
{
return !isGenericBuild()
}
def isArm64() {
return [ 'linux-arm64', 'mac-arm64'].contains( getTargetOsName() )
}
def getTargetOsName()
{
return project.findProperty( 'os' ) ?: 'generic'
}
def getTargetTypeName()
{
return project.findProperty( 'type' ) ?: 'server'
}
def getTargetBaseName()
{
return 'enonic-xp-' + getTargetOsName() + ( isGenericBuild() ? '' : '-' + getTargetTypeName() )
}
ext {
targetOS = null
targetType = null
jdkPackageFile = null
getJdkPackageFile = this.&getJdkPackageFile
getJdkPackageName = this.&getJdkPackageName
getJdkDownloadUrl = this.&getJdkDownloadUrl
getArchiveJavaHome = this.&getArchiveJavaHome
isGenericBuild = this.&isGenericBuild
isSdkBuild = this.&isSdkBuild
getTargetBaseName = this.&getTargetBaseName
getTargetTypeName = this.&getTargetTypeName
withDistTar = this.&withDistTar
withDistZip = this.&withDistZip
withJava = this.&withJava
isArm64 = this.&isArm64
}