|
| 1 | +/* |
| 2 | + * Copyright 2020 The Terasology Foundation |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +// Uses Bellsoft Liberica JRE |
| 18 | +def jreVersion = '8u212' |
| 19 | +def jreUrlBase = "https://download.bell-sw.com/java/$jreVersion/bellsoft-jre$jreVersion" |
| 20 | +def jreUrlFilenames = [ |
| 21 | + lwjreLinux64 : 'linux-amd64.tar.gz', |
| 22 | + lwjreLinux : 'linux-i586.tar.gz', |
| 23 | + lwjre : 'windows-i586.zip', |
| 24 | + lwjreOSX : 'macos-amd64.zip' |
| 25 | +] |
| 26 | + |
| 27 | +task downloadJreAll { |
| 28 | + group 'Download' |
| 29 | + description 'Downloads JRE for all platforms' |
| 30 | +} |
| 31 | + |
| 32 | +jreUrlFilenames.each { os, file -> |
| 33 | + def packedJre = new File("$rootDir/jre/$jreVersion/$file") |
| 34 | + def unpackedJre = new File("$distsDir/app/$os") |
| 35 | + |
| 36 | + def downloadTask = task("downloadJre$os") { |
| 37 | + group 'Download' |
| 38 | + description "Downloads JRE for $os" |
| 39 | + |
| 40 | + doFirst { |
| 41 | + download { |
| 42 | + src "$jreUrlBase-$file" |
| 43 | + dest packedJre |
| 44 | + overwrite false |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + doLast { |
| 49 | + // Unpack the JRE |
| 50 | + if (!unpackedJre.exists()) { |
| 51 | + unpackedJre.mkdirs() |
| 52 | + copy { |
| 53 | + from(file.endsWith("zip") |
| 54 | + ? zipTree(packedJre) |
| 55 | + : tarTree(packedJre)) { |
| 56 | + eachFile { fcd -> |
| 57 | + fcd.relativePath = new RelativePath( |
| 58 | + true, fcd.relativePath.segments.drop(1)) |
| 59 | + } |
| 60 | + includeEmptyDirs = false |
| 61 | + } |
| 62 | + into unpackedJre |
| 63 | + } |
| 64 | + } |
| 65 | + } |
| 66 | + } |
| 67 | + |
| 68 | + downloadJreAll.dependsOn downloadTask |
| 69 | +} |
| 70 | + |
| 71 | + |
0 commit comments