mirror of
https://github.com/GayPizzaSpecifications/concrete.git
synced 2025-08-04 13:41:33 +00:00
Paper server update rework and support for offline mode.
This commit is contained in:
@ -16,7 +16,7 @@ open class SetupPaperServer : DefaultTask() {
|
||||
|
||||
@get:Input
|
||||
@set:Option(option = "update", description = "Update Paper Server")
|
||||
var shouldUpdatePaperServer = false
|
||||
var shouldUpdatePaperServer = true
|
||||
|
||||
private val paperVersionClient = PaperVersionClient()
|
||||
|
||||
@ -58,6 +58,14 @@ open class SetupPaperServer : DefaultTask() {
|
||||
}
|
||||
|
||||
private fun downloadLatestBuild(paperVersionGroup: String, paperJarFile: File) {
|
||||
if (project.gradle.startParameter.isOffline) {
|
||||
if (!paperJarFile.exists()) {
|
||||
throw RuntimeException("Offline mode is enabled and Paper has not been downloaded.")
|
||||
} else {
|
||||
logger.lifecycle("Offline mode is enabled, skipping Paper update.")
|
||||
return
|
||||
}
|
||||
}
|
||||
val builds = paperVersionClient.getVersionBuilds(paperVersionGroup)
|
||||
val build = builds.last()
|
||||
val download = build.downloads["application"]!!
|
||||
|
@ -2,6 +2,7 @@ package lgbt.mystic.foundation.concrete
|
||||
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.tasks.TaskContainer
|
||||
import org.gradle.api.tasks.TaskOutputs
|
||||
import java.nio.file.FileSystems
|
||||
import java.nio.file.Path
|
||||
@ -9,43 +10,41 @@ import java.nio.file.Path
|
||||
internal fun Project.isPluginProject() = plugins.hasPlugin(ConcretePluginPlugin::class.java)
|
||||
internal fun Project.findPluginProjects() = allprojects.filter { project -> project.isPluginProject() }
|
||||
|
||||
internal inline fun <reified T> TaskContainer.find(name: String) =
|
||||
findByName(name) as T?
|
||||
|
||||
internal val Project.shadowJarTask: ShadowJar?
|
||||
get() =
|
||||
if (project.tasks.names.contains("shadowJar"))
|
||||
project.tasks.getByName("shadowJar") as ShadowJar
|
||||
else null
|
||||
get() = project.tasks.find<ShadowJar>("shadowJar")
|
||||
|
||||
internal val Project.shadowJarOutputs: TaskOutputs?
|
||||
get() = shadowJarTask?.outputs
|
||||
|
||||
internal val Project.concreteRootExtension: ConcreteExtension
|
||||
get() {
|
||||
val direct = extensions.findByType(ConcreteExtension::class.java)
|
||||
if (direct != null) {
|
||||
return direct
|
||||
}
|
||||
|
||||
if (parent != null) {
|
||||
return parent!!.concreteRootExtension
|
||||
}
|
||||
|
||||
throw RuntimeException("Failed to find concrete extension. Did you apply the concrete root plugin?")
|
||||
}
|
||||
get() = findTargetParent(
|
||||
valid = { extensions.findByType(ConcreteExtension::class.java) != null },
|
||||
extract = { extensions.findByType(ConcreteExtension::class.java)!! },
|
||||
error = { "Failed to find concrete root. Did you apply the concrete root plugin?" }
|
||||
)
|
||||
|
||||
internal val Project.concreteRootProject: Project
|
||||
get() {
|
||||
val direct = extensions.findByType(ConcreteExtension::class.java)
|
||||
if (direct != null) {
|
||||
return this
|
||||
}
|
||||
get() = findTargetParent(
|
||||
valid = { extensions.findByType(ConcreteExtension::class.java) != null },
|
||||
extract = { this },
|
||||
error = { "Failed to find concrete root. Did you apply the concrete root plugin?" }
|
||||
)
|
||||
|
||||
if (parent != null) {
|
||||
return parent!!.concreteRootProject
|
||||
}
|
||||
|
||||
throw RuntimeException("Failed to find concrete root. Did you apply the concrete root plugin?")
|
||||
internal fun <T> Project.findTargetParent(valid: Project.() -> Boolean, extract: Project.() -> T, error: () -> String): T {
|
||||
if (valid(this)) {
|
||||
return extract(this)
|
||||
}
|
||||
|
||||
if (parent != null) {
|
||||
return parent!!.findTargetParent(valid, extract, error)
|
||||
}
|
||||
|
||||
throw RuntimeException(error())
|
||||
}
|
||||
|
||||
internal fun TaskOutputs.allFilesRelativeToPath(root: Path): List<Path> = files.map { root.relativize(it.toPath()) }
|
||||
|
||||
internal fun Path.toUnixString() = toString().replace(FileSystems.getDefault().separator, "/")
|
||||
|
Reference in New Issue
Block a user