| 1238 | } |
| 1239 | |
| 1240 | fun assetsFileChecksum(asset: Asset): String? { |
| 1241 | return if (isCiCd) { |
| 1242 | val stagedChecksum = stagedChecksumFor(asset, rootProject.projectDir) |
| 1243 | if (stagedChecksum.exists()) { |
| 1244 | stagedChecksum.readText().trim() |
| 1245 | } else { |
| 1246 | throw GradleException("Failed to find checksum in ${stagedChecksum.absolutePath}") |
| 1247 | } |
| 1248 | } else { |
| 1249 | val checksumUrl = asset.url + ".md5" |
| 1250 | val conn = URL(checksumUrl).openConnection() as HttpURLConnection |
| 1251 | conn.requestMethod = "GET" |
| 1252 | conn.setRequestProperty("User-Agent", "Mozilla/5.0") |
| 1253 | conn.instanceFollowRedirects = true |
| 1254 | conn.connectTimeout = 10_000 |
| 1255 | conn.readTimeout = 10_000 |
| 1256 | |
| 1257 | return try { |
| 1258 | val status = conn.responseCode |
| 1259 | |
| 1260 | if (status == HttpURLConnection.HTTP_OK) { |
| 1261 | conn.inputStream.bufferedReader().use { it.readText().trim() } |
| 1262 | } else { |
| 1263 | throw GradleException("Failed to fetch checksum from $checksumUrl (HTTP $status: ${conn.responseMessage})") |
| 1264 | } |
| 1265 | } finally { |
| 1266 | conn.disconnect() |
| 1267 | } |
| 1268 | } |
| 1269 | } |
| 1270 | |
| 1271 | fun assetsDownload( |
| 1272 | assets: List<Asset>, |
no test coverage detected