Skip to content

Commit

Permalink
Update Deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
Nobody314159 committed May 9, 2024
1 parent a080706 commit 71f0a55
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 89 deletions.
91 changes: 2 additions & 89 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import net.minecrell.pluginyml.bukkit.BukkitPluginDescription
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.hidetake.groovy.ssh.core.Remote
import org.hidetake.groovy.ssh.core.RunHandler
import org.hidetake.groovy.ssh.core.Service
import org.hidetake.groovy.ssh.session.SessionHandler
import net.ltgt.gradle.errorprone.errorprone
import net.ltgt.gradle.errorprone.CheckSeverity

Expand All @@ -13,9 +9,9 @@ plugins {
id("com.palantir.git-version") version "0.12.2"
id("com.github.johnrengelman.shadow") version "7.1.2"
id("net.minecrell.plugin-yml.bukkit") version "0.5.1" // Generates plugin.yml
id("org.hidetake.ssh") version "2.10.1"
id("net.ltgt.errorprone") version "2.0.2"
id("net.ltgt.nullaway") version "1.3.0"
id("com.playmonumenta.deployment") version "1.0"
checkstyle
pmd
}
Expand Down Expand Up @@ -127,87 +123,4 @@ tasks.withType<JavaCompile>().configureEach {
}
}

val basicssh = remotes.create("basicssh") {
host = "admin-eu.playmonumenta.com"
port = 8822
user = "epic"
agent = System.getenv("IDENTITY_FILE") == null
identity = if (System.getenv("IDENTITY_FILE") == null) null else file(System.getenv("IDENTITY_FILE"))
knownHosts = allowAnyHosts
}

val adminssh = remotes.create("adminssh") {
host = "admin-eu.playmonumenta.com"
port = 9922
user = "epic"
agent = System.getenv("IDENTITY_FILE") == null
identity = if (System.getenv("IDENTITY_FILE") == null) null else file(System.getenv("IDENTITY_FILE"))
knownHosts = allowAnyHosts
}

tasks.create("stage-deploy") {
val shadowJar by tasks.named<ShadowJar>("shadowJar")
dependsOn(shadowJar)
doLast {
ssh.runSessions {
session(basicssh) {
put(shadowJar.archiveFile.get().getAsFile(), "/home/epic/stage/m12/server_config/plugins")
execute("cd /home/epic/stage/m12/server_config/plugins && rm -f LibraryOfSouls.jar && ln -s " + shadowJar.archiveFileName.get() + " LibraryOfSouls.jar")
}
}
}
}

tasks.create("volt-deploy") {
val shadowJar by tasks.named<ShadowJar>("shadowJar")
dependsOn(shadowJar)
doLast {
ssh.runSessions {
session(basicssh) {
put(shadowJar.archiveFile.get().getAsFile(), "/home/epic/volt/m12/server_config/plugins")
execute("cd /home/epic/volt/m12/server_config/plugins && rm -f LibraryOfSouls.jar && ln -s " + shadowJar.archiveFileName.get() + " LibraryOfSouls.jar")
}
}
}
}

tasks.create("build-deploy") {
val shadowJar by tasks.named<ShadowJar>("shadowJar")
dependsOn(shadowJar)
doLast {
ssh.runSessions {
session(adminssh) {
put(shadowJar.archiveFile.get().getAsFile(), "/home/epic/project_epic/server_config/plugins")
execute("cd /home/epic/project_epic/server_config/plugins && rm -f LibraryOfSouls.jar && ln -s " + shadowJar.archiveFileName.get() + " LibraryOfSouls.jar")
}
}
}
}

tasks.create("play-deploy") {
val shadowJar by tasks.named<ShadowJar>("shadowJar")
dependsOn(shadowJar)
doLast {
ssh.runSessions {
session(adminssh) {
put(shadowJar.archiveFile.get().getAsFile(), "/home/epic/play/m8/server_config/plugins")
put(shadowJar.archiveFile.get().getAsFile(), "/home/epic/play/m11/server_config/plugins")
put(shadowJar.archiveFile.get().getAsFile(), "/home/epic/play/m13/server_config/plugins")
put(shadowJar.archiveFile.get().getAsFile(), "/home/epic/play/m15/server_config/plugins")
execute("cd /home/epic/play/m8/server_config/plugins && rm -f LibraryOfSouls.jar && ln -s " + shadowJar.archiveFileName.get() + " LibraryOfSouls.jar")
execute("cd /home/epic/play/m11/server_config/plugins && rm -f LibraryOfSouls.jar && ln -s " + shadowJar.archiveFileName.get() + " LibraryOfSouls.jar")
execute("cd /home/epic/play/m13/server_config/plugins && rm -f LibraryOfSouls.jar && ln -s " + shadowJar.archiveFileName.get() + " LibraryOfSouls.jar")
execute("cd /home/epic/play/m15/server_config/plugins && rm -f LibraryOfSouls.jar && ln -s " + shadowJar.archiveFileName.get() + " LibraryOfSouls.jar")
}
}
}
}

fun Service.runSessions(action: RunHandler.() -> Unit) =
run(delegateClosureOf(action))

fun RunHandler.session(vararg remotes: Remote, action: SessionHandler.() -> Unit) =
session(*remotes, delegateClosureOf(action))

fun SessionHandler.put(from: Any, into: Any) =
put(hashMapOf("from" to from, "into" to into))
ssh.easySetup(tasks.named<ShadowJar>("shadowJar").get(), "LibraryOfSouls")
16 changes: 16 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
plugins {
// Support convention plugins written in Kotlin. Convention plugins are build scripts in 'src/main' that automatically become available as plugins in the main build.
`kotlin-dsl`
}

repositories {
// Use the plugin portal to apply community plugins in convention plugins.
gradlePluginPortal()
mavenCentral()
}

dependencies {
implementation("com.github.mwiede:jsch:0.2.17")
implementation("net.java.dev.jna:jna:5.14.0")
implementation("net.java.dev.jna:jna-platform:5.14.0")
}
7 changes: 7 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
rootProject.name = "libraryofsouls"

pluginManagement {
repositories {
gradlePluginPortal()
maven("https://maven.floweytf.com/releases/")
}
}

0 comments on commit 71f0a55

Please sign in to comment.