generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add versions service, refactor Version sealed class
- Loading branch information
Showing
3 changed files
with
104 additions
and
28 deletions.
There are no files selected for viewing
101 changes: 73 additions & 28 deletions
101
src/main/kotlin/com/github/cnrture/quickprojectwizard/gradle/Version.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,77 @@ | ||
package com.github.cnrture.quickprojectwizard.gradle | ||
|
||
import com.github.cnrture.quickprojectwizard.gradle.network.VersionModel | ||
import io.ktor.client.statement.* | ||
import kotlinx.serialization.json.Json | ||
import io.ktor.client.HttpClient | ||
import io.ktor.client.engine.cio.CIO | ||
import io.ktor.client.request.get | ||
import io.ktor.client.statement.HttpResponse | ||
|
||
object Versions { | ||
val versionList = mutableMapOf( | ||
"agp" to "8.5.2", | ||
"kotlin" to "2.0.20", | ||
"core-ktx" to "1.13.1", | ||
"junit" to "4.13.2", | ||
"junit-ext" to "1.2.1", | ||
"espresso-core" to "3.6.1", | ||
"appcompat" to "1.7.0", | ||
"material" to "1.12.0", | ||
"ksp" to "2.0.20-1.0.24", | ||
"lifecycle-runtime-ktx" to "2.8.4", | ||
"activity-compose" to "1.9.1", | ||
"compose-bom" to "2024.08.00", | ||
"activity" to "1.9.1", | ||
"constraintlayout" to "2.1.4", | ||
"coilVersion" to "2.7.0", | ||
"glideVersion" to "4.16.0", | ||
"glideCompose" to "1.0.0-beta01", | ||
"room" to "2.6.1", | ||
"retrofit" to "2.11.0", | ||
"ktor" to "2.3.12", | ||
"hilt" to "2.52", | ||
"hiltNavigationCompose" to "1.2.0", | ||
"navigation" to "2.7.7", | ||
"ktlint" to "11.3.2", | ||
"detekt" to "1.23.5", | ||
"googleServices" to "4.4.2", | ||
"firebase" to "33.2.0", | ||
"workManagerVersion" to "2.9.1", | ||
) | ||
} | ||
|
||
sealed class Version(val name: String, val value: String) { | ||
data object Agp : Version("agp", "8.5.2") | ||
data object Kotlin : Version("kotlin", "2.0.20") | ||
data object CoreKtx : Version("core-ktx", "1.13.1") | ||
data object Junit : Version("junit", "4.13.2") | ||
data object JunitExt : Version("junit-ext", "1.2.1") | ||
data object EspressoCore : Version("espresso-core", "3.6.1") | ||
data object AppCompat : Version("appcompat", "1.7.0") | ||
data object Material : Version("material", "1.12.0") | ||
data object Ksp : Version("ksp", "2.0.20-1.0.24") | ||
data object LifecycleRuntimeKtx : Version("lifecycle-runtime-ktx", "2.8.4") | ||
data object ActivityCompose : Version("activity-compose", "1.9.1") | ||
data object ComposeBom : Version("compose-bom", "2024.08.00") | ||
data object Activity : Version("activity", "1.9.1") | ||
data object ConstraintLayout : Version("constraintlayout", "2.1.4") | ||
data object Coil : Version("coilVersion", "2.7.0") | ||
data object GlideXml : Version("glideVersion", "4.16.0") | ||
data object GlideCompose : Version("glideCompose", "1.0.0-beta01") | ||
data object Room : Version("room", "2.6.1") | ||
data object Retrofit : Version("retrofit", "2.11.0") | ||
data object Ktor : Version("ktor", "2.3.12") | ||
data object Hilt : Version("hilt", "2.52") | ||
data object HiltNavigationCompose : Version("hiltNavigationCompose", "1.2.0") | ||
data object Navigation : Version("navigation", "2.7.7") | ||
data object KtLint : Version("ktlint", "11.3.2") | ||
data object Detekt : Version("detekt", "1.23.5") | ||
data object GoogleServices : Version("googleServices", "4.4.2") | ||
data object Firebase : Version("firebase", "33.2.0") | ||
data object WorkManager : Version("workManagerVersion", "2.9.1") | ||
data object Agp : Version("agp", Versions.versionList["agp"] ?: "8.5.2") | ||
data object Kotlin : Version("kotlin", Versions.versionList["kotlin"] ?: "2.0.20") | ||
data object CoreKtx : Version("core-ktx", Versions.versionList["core-ktx"] ?: "1.13.1") | ||
data object Junit : Version("junit", Versions.versionList["junit"] ?: "4.13.2") | ||
data object JunitExt : Version("junit-ext", Versions.versionList["junit-ext"] ?: "1.2.1") | ||
data object EspressoCore : Version("espresso-core", Versions.versionList["espresso-core"] ?: "3.6.1") | ||
data object AppCompat : Version("appcompat", Versions.versionList["appcompat"] ?: "1.7.0") | ||
data object Material : Version("material", Versions.versionList["material"] ?: "1.12.0") | ||
data object Ksp : Version("ksp", Versions.versionList["ksp"] ?: "2.0.20-1.0.24") | ||
data object LifecycleRuntimeKtx : | ||
Version("lifecycle-runtime-ktx", Versions.versionList["lifecycle-runtime-ktx"] ?: "2.8.4") | ||
|
||
data object ActivityCompose : Version("activity-compose", Versions.versionList["activity-compose"] ?: "1.9.1") | ||
data object ComposeBom : Version("compose-bom", Versions.versionList["compose-bom"] ?: "2024.08.00") | ||
data object Activity : Version("activity", Versions.versionList["activity"] ?: "1.9.1") | ||
data object ConstraintLayout : Version("constraintlayout", Versions.versionList["constraintlayout"] ?: "2.1.4") | ||
data object Coil : Version("coilVersion", Versions.versionList["coilVersion"] ?: "2.7.0") | ||
data object GlideXml : Version("glideVersion", Versions.versionList["glideVersion"] ?: "4.16.0") | ||
data object GlideCompose : Version("glideCompose", Versions.versionList["glideCompose"] ?: "1.0.0-beta01") | ||
data object Room : Version("room", Versions.versionList["room"] ?: "2.6.1") | ||
data object Retrofit : Version("retrofit", Versions.versionList["retrofit"] ?: "2.11.0") | ||
data object Ktor : Version("ktor", Versions.versionList["ktor"] ?: "2.3.12") | ||
data object Hilt : Version("hilt", Versions.versionList["hilt"] ?: "2.52") | ||
data object HiltNavigationCompose : | ||
Version("hiltNavigationCompose", Versions.versionList["hiltNavigationCompose"] ?: "1.2.0") | ||
|
||
data object Navigation : Version("navigation", Versions.versionList["navigation"] ?: "2.7.7") | ||
data object KtLint : Version("ktlint", Versions.versionList["ktlint"] ?: "11.3.2") | ||
data object Detekt : Version("detekt", Versions.versionList["detekt"] ?: "1.23.5") | ||
data object GoogleServices : Version("googleServices", Versions.versionList["googleServices"] ?: "4.4.2") | ||
data object Firebase : Version("firebase", Versions.versionList["firebase"] ?: "33.2.0") | ||
data object WorkManager : Version("workManagerVersion", Versions.versionList["workManagerVersion"] ?: "2.9.1") | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/kotlin/com/github/cnrture/quickprojectwizard/gradle/network/GetVersions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.github.cnrture.quickprojectwizard.gradle.network | ||
|
||
import com.github.cnrture.quickprojectwizard.gradle.Versions | ||
import io.ktor.client.* | ||
import io.ktor.client.engine.cio.* | ||
import io.ktor.client.request.* | ||
import io.ktor.client.statement.* | ||
import kotlinx.serialization.json.Json | ||
|
||
suspend fun getVersions() { | ||
val client = HttpClient(CIO) { | ||
this.engine { | ||
requestTimeout = 2000 | ||
} | ||
} | ||
val response: HttpResponse = client.get("https://api.canerture.com/qpwizard/versions") | ||
val versions = Json.decodeFromString<List<VersionModel>>(response.bodyAsText()) | ||
versions.forEach { | ||
Versions.versionList[it.name] = it.value | ||
} | ||
client.close() | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/kotlin/com/github/cnrture/quickprojectwizard/gradle/network/VersionModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.github.cnrture.quickprojectwizard.gradle.network | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class VersionModel( | ||
val name: String, | ||
val value: String, | ||
) |