Skip to content

Commit

Permalink
added runServer task
Browse files Browse the repository at this point in the history
  • Loading branch information
mfnalex committed Feb 17, 2024
1 parent 9748c0a commit b0120d5
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 20 deletions.
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ build/
!**/src/test/**/build/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
.idea
*.iws
*.iml
Expand Down Expand Up @@ -40,4 +36,8 @@ bin/
.vscode/

### Mac OS ###
.DS_Store
.DS_Store

### Run Paper ###
/run/
!/run/eula.txt
54 changes: 41 additions & 13 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jetbrains.kotlin.incremental.deleteRecursivelyOrThrow

version = "git-${getGitCommitHash()}"

Expand All @@ -7,6 +8,7 @@ plugins {
// id("basics.kotlin-conventions")
id("com.github.johnrengelman.shadow") apply false
id("org.jlleitschuh.gradle.ktlint") version "12.1.0"
id("xyz.jpenilla.run-paper") version "2.1.0"
}

allprojects {
Expand All @@ -26,30 +28,31 @@ subprojects {
}

tasks.register("copyAllToTestServer") {
group = "basics"
group = "basics custom testserver"
description = "Copies the plugin and all modules to the test server"
dependsOn("plugin:copyPluginToTestServer")
dependsOn("copyAllModulesToTestServer")
}

tasks.register<Copy>("distribution") {
group = "basics"
description = "Bundle the plugin and all modules into a single directory."
val distribution =
tasks.register<Copy>("distribution") {
group = "basics"
description = "Bundle the plugin and all modules into a single directory."

dependsOn(tasks.build)
dependsOn(tasks.build)

into("build/dist/basics-$version")
into("build/dist/basics-$version")

from(project(":plugin").tasks.getByName("shadowJar", ShadowJar::class).archiveFile)
from(project(":plugin").tasks.getByName("shadowJar", ShadowJar::class).archiveFile)

project(":modules").subprojects.forEach { module ->
module.tasks.withType<ShadowJar>().forEach { shadowTask ->
from(shadowTask.archiveFile) {
into("Basics/modules")
project(":modules").subprojects.forEach { module ->
module.tasks.withType<ShadowJar>().forEach { shadowTask ->
from(shadowTask.archiveFile) {
into("Basics/modules")
}
}
}
}
}

tasks.register<Zip>("zipDistribution") {
group = "basics"
Expand All @@ -71,7 +74,7 @@ tasks.register<Zip>("zipDistribution") {
}

tasks.register("copyAllModulesToTestServer") {
group = "basics-test"
group = "basics custom testserver"
description = "Copies all modules to the test server"
val copyAllModulesTask = this
subprojects.forEach { module ->
Expand All @@ -86,3 +89,28 @@ tasks.register("printVersion") {
println(version)
}
}

tasks {
runServer {

group = "basics"
description = "Runs the server with the Basics plugin and all modules"

dependsOn(distribution)

val distFolder = project.rootDir.resolve("build/dist/basics-${project.version}")
val serverFolder = project.rootDir.resolve("run")
val pluginsFolder = serverFolder.resolve("plugins")
val basicsFolder = pluginsFolder.resolve("Basics")

doFirst {
basicsFolder.deleteRecursivelyOrThrow()
distFolder.copyRecursively(pluginsFolder, true)
}
minecraftVersion("1.20.4")
}
}

runPaper {
disablePluginJarDetection()
}
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/basics.module.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ tasks.processResources {

val moduleName = project.name
tasks.register("copyModule${moduleName.pascalCase()}ToTestServer", CopyModule::class) {
group = "basics-test"
group = "basics custom testserver"
description = "Copies the ${moduleName} module to the test server"
from(tasks.getByName("shadowJar", ShadowJar::class).archiveFile)
into(getServerModulesDirectory())
Expand Down
2 changes: 1 addition & 1 deletion plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ tasks.shadowJar {
}

tasks.register("copyPluginToTestServer", Copy::class) {
group = "basics-test"
group = "basics custom testserver"
description = "Copies the plugin to the test server"
from(tasks.shadowJar.get().archiveFile)
into(getServerPluginsDirectory())
Expand Down
1 change: 1 addition & 0 deletions run/eula.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
eula=true

0 comments on commit b0120d5

Please sign in to comment.