mirror of
https://github.com/apple/pkl.git
synced 2026-05-25 16:19:20 +02:00
Run spotless apply
This commit is contained in:
@@ -1,6 +1,21 @@
|
||||
import org.gradle.util.GradleVersion
|
||||
/**
|
||||
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import groovy.json.JsonSlurper
|
||||
import java.net.URI
|
||||
import org.gradle.util.GradleVersion
|
||||
|
||||
@Suppress("unused")
|
||||
class GradleVersionInfo(json: Map<String, Any>) {
|
||||
@@ -38,15 +53,19 @@ class GradleVersionInfo(json: Map<String, Any>) {
|
||||
val wrapperChecksumUrl: String by json
|
||||
|
||||
companion object {
|
||||
private fun fetchAll(): List<GradleVersionInfo> = fetchMultiple("https://services.gradle.org/versions/all")
|
||||
private fun fetchAll(): List<GradleVersionInfo> =
|
||||
fetchMultiple("https://services.gradle.org/versions/all")
|
||||
|
||||
fun fetchReleases(): List<GradleVersionInfo> = fetchAll().filter { it.isReleaseVersion }
|
||||
|
||||
fun fetchCurrent(): GradleVersionInfo = fetchSingle("https://services.gradle.org/versions/current")
|
||||
fun fetchCurrent(): GradleVersionInfo =
|
||||
fetchSingle("https://services.gradle.org/versions/current")
|
||||
|
||||
fun fetchRc(): GradleVersionInfo? = fetchSingleOrNull("https://services.gradle.org/versions/release-candidate")
|
||||
fun fetchRc(): GradleVersionInfo? =
|
||||
fetchSingleOrNull("https://services.gradle.org/versions/release-candidate")
|
||||
|
||||
fun fetchNightly(): GradleVersionInfo = fetchSingle("https://services.gradle.org/versions/nightly")
|
||||
fun fetchNightly(): GradleVersionInfo =
|
||||
fetchSingle("https://services.gradle.org/versions/nightly")
|
||||
|
||||
private fun fetchSingle(url: String): GradleVersionInfo {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
@@ -61,8 +80,9 @@ class GradleVersionInfo(json: Map<String, Any>) {
|
||||
|
||||
private fun fetchMultiple(url: String): List<GradleVersionInfo> {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return (JsonSlurper().parse(URI(url).toURL()) as List<Map<String, Any>>)
|
||||
.map { GradleVersionInfo(it) }
|
||||
return (JsonSlurper().parse(URI(url).toURL()) as List<Map<String, Any>>).map {
|
||||
GradleVersionInfo(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user