16
16
17
17
plugins {
18
18
id ' distribution'
19
+ id ' de.undercouch.download' version ' 5.4.0'
20
+ }
21
+
22
+ def jdkConfig = [
23
+ ' Linux-x64' : [
24
+ url : ' https://download.java.net/java/GA/jdk17.0.2/dfd4a8d0985749f896bed50d7138ee7f/8/GPL/openjdk-17.0.2_linux-x64_bin.tar.gz' ,
25
+ dir : ' jdk-17.0.2+7'
26
+ ],
27
+ ' Windows-x64' : [
28
+ url : ' https://download.java.net/java/GA/jdk17.0.2/dfd4a8d0985749f896bed50d7138ee7f/8/GPL/openjdk-17.0.2_windows-x64_bin.zip' ,
29
+ dir : ' jdk-17.0.2+7'
30
+ ],
31
+ ' Darwin-x64' : [
32
+ url : ' https://download.java.net/java/GA/jdk17.0.2/dfd4a8d0985749f896bed50d7138ee7f/8/GPL/openjdk-17.0.2_macos-x64_bin.tar.gz' ,
33
+ dir : ' jdk-17.0.2+7/Contents/Home'
34
+ ]
35
+ ]
36
+
37
+ def down = project. hasProperty(' isDownload' ) ? project. property(' isDownload' ). toBoolean() : false
38
+
39
+ tasks. register(' downloadJdk' ) {
40
+ if (! down) {
41
+ return
42
+ }
43
+ doLast {
44
+ jdkConfig. each { platform , config ->
45
+ def destFile = file(" ${ buildDir} /jdk/${ platform} .${ config.url.split(/\./).last()} " )
46
+ def outputDir = file(" ${ buildDir} /jdk/${ platform} " )
47
+
48
+ download. run {
49
+ src config. url
50
+ dest destFile
51
+ overwrite false
52
+ }
53
+
54
+ destFile. setReadable(true , false )
55
+ destFile. setWritable(true )
56
+
57
+ mkdir(outputDir)
58
+ outputDir. setWritable(true , false )
59
+
60
+ if (destFile. name. endsWith(' .gz' )) {
61
+ copy {
62
+ from tarTree(resources. gzip(destFile))
63
+ into outputDir
64
+ eachFile { fcd ->
65
+ fcd. path = fcd. path. replaceFirst(/ ^[^\/ ]+\/ / , ' ' )
66
+ }
67
+ includeEmptyDirs = false
68
+ }
69
+ } else if (destFile. name. endsWith(' .zip' )) {
70
+ copy {
71
+ from zipTree(destFile)
72
+ into outputDir
73
+ eachFile { fcd ->
74
+ fcd. path = fcd. path. replaceFirst(/ ^[^\/ ]+\/ / , ' ' )
75
+ }
76
+ includeEmptyDirs = false
77
+ }
78
+ }
79
+ fileTree(outputDir). each { file ->
80
+ file. setReadable(true , false )
81
+ file. setExecutable(true , false )
82
+ }
83
+ }
84
+ }
19
85
}
20
86
21
87
task copyDepends (type : Copy ) {
@@ -26,6 +92,13 @@ task copyDepends(type: Copy) {
26
92
}
27
93
into layout. projectDirectory. dir(" dingo" )
28
94
95
+ from(fileTree(" ${ buildDir} /jdk" )) {
96
+ include(' *-x64/**' )
97
+ exclude(' *.gz' )
98
+ exclude(' *.zip' )
99
+ }
100
+ into layout. projectDirectory. dir(" dingo" )
101
+
29
102
from(project(' :dingo-executor' ). layout. buildDirectory) {
30
103
include(' libs/dingo-executor-*-all.jar' )
31
104
}
@@ -70,7 +143,7 @@ task copyDepends(type: Copy) {
70
143
}
71
144
72
145
tasks. register(' packageDistribution' , Zip ) {
73
- dependsOn(copyDepends)
146
+ dependsOn(copyDepends, downloadJdk )
74
147
archiveFileName = " dingo.zip"
75
148
destinationDirectory = layout. buildDirectory. dir(' distributions' )
76
149
from layout. projectDirectory. dir(" dingo" )
0 commit comments