|
| 1 | +apply from: 'scripts/versions.gradle' |
| 2 | + |
| 3 | +def baseUrl = "https://github.com/Gold872/elastic-dashboard/releases/download/$elasticGitTag/" |
| 4 | + |
| 5 | +def fileNameWindows = 'Elastic-WPILib-Windows.zip' |
| 6 | + |
| 7 | +def downloadUrlWindows = baseUrl + fileNameWindows |
| 8 | + |
| 9 | +def fileNameMac = 'Elastic-WPILib-macOS.tar.gz' |
| 10 | + |
| 11 | +def downloadUrlMac = baseUrl + fileNameMac |
| 12 | + |
| 13 | +def fileNameMacArm = 'Elastic-WPILib-macOS.tar.gz' |
| 14 | + |
| 15 | +def downloadUrlMacArm = baseUrl + fileNameMacArm |
| 16 | + |
| 17 | +def fileNameLinux = 'Elastic-WPILib-Linux.zip' |
| 18 | + |
| 19 | +def downloadUrlLinux = baseUrl + fileNameLinux |
| 20 | + |
| 21 | +apply plugin: 'de.undercouch.download' |
| 22 | + |
| 23 | +def downloadTaskWindows = tasks.register('downloadElasticWindows', Download) { |
| 24 | + src downloadUrlWindows |
| 25 | + def fileName = file(src.file).name |
| 26 | + dest "$buildDir/downloads/$fileName" |
| 27 | + overwrite true |
| 28 | +} |
| 29 | + |
| 30 | +def downloadTaskMac = tasks.register('downloadElasticMac', Download) { |
| 31 | + src downloadUrlMac |
| 32 | + def fileName = file(src.file).name |
| 33 | + dest "$buildDir/downloads/$fileName" |
| 34 | + overwrite true |
| 35 | +} |
| 36 | + |
| 37 | +def downloadTaskMacArm = tasks.register('downloadElasticMacArm', Download) { |
| 38 | + src downloadUrlMacArm |
| 39 | + def fileName = file(src.file).name |
| 40 | + dest "$buildDir/downloads/$fileName" |
| 41 | + overwrite true |
| 42 | +} |
| 43 | + |
| 44 | +def downloadTaskLinux = tasks.register('downloadElasticLinux', Download) { |
| 45 | + src downloadUrlLinux |
| 46 | + def fileName = file(src.file).name |
| 47 | + dest "$buildDir/downloads/$fileName" |
| 48 | + overwrite true |
| 49 | +} |
| 50 | + |
| 51 | +def elasticConfigFile = file("$buildDir/elasticConfig.json") |
| 52 | + |
| 53 | +def elasticConfigFileTask = tasks.register('elasticConfigFile') { |
| 54 | + it.outputs.file elasticConfigFile |
| 55 | + |
| 56 | + doLast { |
| 57 | + def config = [:] |
| 58 | + config['folder'] = 'elastic' |
| 59 | + config['zipFile'] = 'elastic.zip' |
| 60 | + |
| 61 | + def gbuilder = getGsonBuilder() |
| 62 | + |
| 63 | + gbuilder.setPrettyPrinting() |
| 64 | + def json = gbuilder.create().toJson(config) |
| 65 | + |
| 66 | + elasticConfigFile.parentFile.mkdirs() |
| 67 | + |
| 68 | + elasticConfigFile.text = json |
| 69 | + } |
| 70 | +} |
| 71 | + |
| 72 | +ext.elasticConfigFileSetup = { AbstractArchiveTask zip-> |
| 73 | + zip.dependsOn elasticConfigFileTask |
| 74 | + zip.inputs.file elasticConfigFile |
| 75 | + |
| 76 | + zip.from(elasticConfigFile) { |
| 77 | + rename { 'elasticConfig.json' } |
| 78 | + } |
| 79 | +} |
| 80 | + |
| 81 | +ext.elasticZipSetup = { AbstractArchiveTask zip-> |
| 82 | + if (project.hasProperty('linuxBuild')) { |
| 83 | + zip.dependsOn downloadTaskLinux |
| 84 | + |
| 85 | + zip.inputs.files downloadTaskLinux.get().outputFiles |
| 86 | + |
| 87 | + zip.from(project.zipTree(downloadTaskLinux.get().outputFiles.first())) { |
| 88 | + into '/elastic' |
| 89 | + includeEmptyDirs = false |
| 90 | + } |
| 91 | + } else if (project.hasProperty('macBuild')) { |
| 92 | + zip.dependsOn downloadTaskMac |
| 93 | + |
| 94 | + zip.inputs.files downloadTaskMac.get().outputFiles |
| 95 | + |
| 96 | + // Cannot extract, otherwise breaks mac |
| 97 | + zip.from(downloadTaskMac.get().outputFiles.first()) { |
| 98 | + into '/elastic' |
| 99 | + } |
| 100 | + } else if (project.hasProperty('macBuildArm')) { |
| 101 | + zip.dependsOn downloadTaskMacArm |
| 102 | + |
| 103 | + zip.inputs.files downloadTaskMacArm.get().outputFiles |
| 104 | + |
| 105 | + // Cannot extract, otherwise breaks mac |
| 106 | + zip.from(downloadTaskMacArm.get().outputFiles.first()) { |
| 107 | + into '/elastic' |
| 108 | + } |
| 109 | + } else { |
| 110 | + zip.dependsOn downloadTaskWindows |
| 111 | + |
| 112 | + zip.inputs.files downloadTaskWindows.get().outputFiles |
| 113 | + |
| 114 | + zip.from(project.zipTree(downloadTaskWindows.get().outputFiles.first())) { |
| 115 | + into '/elastic' |
| 116 | + includeEmptyDirs = false |
| 117 | + } |
| 118 | + } |
| 119 | +} |
| 120 | + |
0 commit comments