Optimize and improve VelocityCore size

Improve steamwar.devserver.gradle to not upload anything that is up to date!
This commit is contained in:
2025-07-02 11:17:55 +02:00
parent 8677d59cce
commit 6efbda669e
6 changed files with 39 additions and 18 deletions
@@ -22,6 +22,10 @@ plugins {
alias(libs.plugins.shadow) alias(libs.plugins.shadow)
} }
tasks.build {
finalizedBy(tasks.shadowJar)
}
java { java {
sourceCompatibility = JavaVersion.VERSION_17 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17
@@ -34,4 +38,12 @@ dependencies {
implementation(libs.jda) { implementation(libs.jda) {
exclude(module = "opus-java") exclude(module = "opus-java")
} }
implementation(libs.sqlite)
implementation(libs.mysql)
implementation(libs.msgpack)
implementation(libs.apolloprotos)
implementation(libs.nbt)
} }
@@ -22,8 +22,8 @@ package de.steamwar.discord;
import com.velocitypowered.api.plugin.Plugin; import com.velocitypowered.api.plugin.Plugin;
@Plugin( @Plugin(
id = "discordvelocitycore", id = "depencendiesvelocitycore",
name = "DiscordVelocityCore" name = "DepencendiesVelocityCore"
) )
public class Discord { public class Dependencies {
} }
+2 -10
View File
@@ -51,18 +51,10 @@ dependencies {
compileOnly(libs.viavelocity) compileOnly(libs.viavelocity)
compileOnly(project(":VelocityCore:Persistent", "default")) compileOnly(project(":VelocityCore:Persistent", "default"))
compileOnly(project(":VelocityCore:DiscordDependency", "default")) compileOnly(project(":VelocityCore:Dependencies", "default"))
implementation(project(":CommonCore")) implementation(project(":CommonCore"))
implementation(project(":CommandFramework")) implementation(project(":CommandFramework"))
implementation(libs.sqlite)
implementation(libs.mysql)
implementation(libs.msgpack)
implementation(libs.apolloprotos)
implementation(libs.nbt)
} }
tasks.register<DevServer>("DevVelocity") { tasks.register<DevServer>("DevVelocity") {
@@ -70,6 +62,6 @@ tasks.register<DevServer>("DevVelocity") {
description = "Run a Dev Velocity" description = "Run a Dev Velocity"
dependsOn(":VelocityCore:shadowJar") dependsOn(":VelocityCore:shadowJar")
dependsOn(":VelocityCore:Persistent:jar") dependsOn(":VelocityCore:Persistent:jar")
dependsOn(":VelocityCore:DiscordDependency:jar") dependsOn(":VelocityCore:Dependencies:shadowJar")
template = "DevVelocity" template = "DevVelocity"
} }
@@ -60,7 +60,7 @@ import java.util.logging.Logger;
@Plugin( @Plugin(
id = "velocitycore", id = "velocitycore",
name = "VelocityCore", name = "VelocityCore",
dependencies = { @Dependency(id = "persistentvelocitycore"), @Dependency(id = "discordvelocitycore") } dependencies = { @Dependency(id = "persistentvelocitycore"), @Dependency(id = "depencendiesvelocitycore") }
) )
public class VelocityCore implements ReloadablePlugin { public class VelocityCore implements ReloadablePlugin {
+20 -3
View File
@@ -46,6 +46,19 @@ class DevServer extends DefaultTask {
DevServer() { DevServer() {
super() super()
List<Task> upToDateTasks = []
project.gradle.taskGraph.addTaskExecutionListener(new TaskExecutionListener() {
@Override
void beforeExecute(Task task) {
}
@Override
void afterExecute(Task task, TaskState state) {
if (state.upToDate) {
upToDateTasks.add(task);
}
}
})
doFirst { doFirst {
List<Project> projects = [] List<Project> projects = []
projects.add(project) projects.add(project)
@@ -70,7 +83,7 @@ class DevServer extends DefaultTask {
} }
doLast { doLast {
checkHasTemplate() checkHasTemplate()
uploadDependencies() uploadDependencies(upToDateTasks)
startDevServer() startDevServer()
} }
finalizedBy(new Finalizer()) finalizedBy(new Finalizer())
@@ -107,7 +120,7 @@ class DevServer extends DefaultTask {
} }
} }
void uploadDependencies() { void uploadDependencies(List<Task> upToDateTasks) {
def base = plugins == null ? "$template/plugins" : plugins def base = plugins == null ? "$template/plugins" : plugins
println("Uploading to ~/$base") println("Uploading to ~/$base")
this.dependsOn.forEach { this.dependsOn.forEach {
@@ -119,8 +132,12 @@ class DevServer extends DefaultTask {
} else { } else {
throw new GradleException("Illegal argument for uploading dependencies") throw new GradleException("Illegal argument for uploading dependencies")
} }
def archive = archiveTask.archiveFile.get().asFile def archive = archiveTask.archiveFile.get().asFile
if (upToDateTasks.contains(archiveTask)) {
println("Skipping $archive")
return
}
println("Uploading $archive") println("Uploading $archive")
new ProcessBuilder("ssh", host, "-T", "rm $base/${archive.name.replace("-all", "")}").start().waitFor() new ProcessBuilder("ssh", host, "-T", "rm $base/${archive.name.replace("-all", "")}").start().waitFor()
new ProcessBuilder("scp", archive.absolutePath, "$host:~/$base/${archive.name.replace("-all", "")}").start().waitFor() new ProcessBuilder("scp", archive.absolutePath, "$host:~/$base/${archive.name.replace("-all", "")}").start().waitFor()
+1 -1
View File
@@ -247,7 +247,7 @@ include("TutorialSystem")
include( include(
"VelocityCore", "VelocityCore",
"VelocityCore:DiscordDependency", "VelocityCore:Dependencies",
"VelocityCore:Persistent" "VelocityCore:Persistent"
) )