stioner.plugin.2024.9.2.source-code.CheckQuestionerVersion.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plugin Show documentation
Show all versions of plugin Show documentation
Questioner Gradle plugin for CS 124.
@file:Suppress("InvalidPackageDeclaration")
package edu.illinois.cs.cs125.questioner.plugin
import kotlinx.coroutines.runBlocking
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.TaskAction
import java.net.URI
open class CheckQuestionerVersion : DefaultTask() {
init {
group = "Verification"
description = "Check questioner version."
}
@TaskAction
fun print() = runBlocking {
try {
URI("http://www.google.com").toURL().openConnection().let {
it.connect()
it.getInputStream().close()
}
} catch (e: Exception) {
project.logger.warn("Unable to retrieve latest Questioner version. Check your network connection?")
}
if (!isLatestVersion()) {
val latestVersion = getLatestQuestionerVersion()
project.logger.warn("\nPlease upgrade your build.gradle.kts to use the latest version of Questioner: $latestVersion\n")
}
}
}