diff --git a/samples/mixed/bukkit-plugins/common-library/src/main/kotlin/lgbt/mystic/foundation/conrete/sample/common/CommonExtensions.kt b/samples/mixed/bukkit-plugins/common-library/src/main/kotlin/lgbt/mystic/foundation/concrete/sample/common/CommonExtensions.kt similarity index 78% rename from samples/mixed/bukkit-plugins/common-library/src/main/kotlin/lgbt/mystic/foundation/conrete/sample/common/CommonExtensions.kt rename to samples/mixed/bukkit-plugins/common-library/src/main/kotlin/lgbt/mystic/foundation/concrete/sample/common/CommonExtensions.kt index 45f1959..befb662 100644 --- a/samples/mixed/bukkit-plugins/common-library/src/main/kotlin/lgbt/mystic/foundation/conrete/sample/common/CommonExtensions.kt +++ b/samples/mixed/bukkit-plugins/common-library/src/main/kotlin/lgbt/mystic/foundation/concrete/sample/common/CommonExtensions.kt @@ -1,4 +1,4 @@ -package lgbt.mystic.foundation.conrete.sample.common +package lgbt.mystic.foundation.concrete.sample.common import org.bukkit.plugin.java.JavaPlugin diff --git a/samples/mixed/bukkit-plugins/goodbye-world/src/main/kotlin/lgbt/mystic/foundation/concrete/sample/goodbyeworld/GoodbyeWorldPlugin.kt b/samples/mixed/bukkit-plugins/goodbye-world/src/main/kotlin/lgbt/mystic/foundation/concrete/sample/goodbyeworld/GoodbyeWorldPlugin.kt index d9f0226..d0cd43f 100644 --- a/samples/mixed/bukkit-plugins/goodbye-world/src/main/kotlin/lgbt/mystic/foundation/concrete/sample/goodbyeworld/GoodbyeWorldPlugin.kt +++ b/samples/mixed/bukkit-plugins/goodbye-world/src/main/kotlin/lgbt/mystic/foundation/concrete/sample/goodbyeworld/GoodbyeWorldPlugin.kt @@ -1,7 +1,7 @@ package lgbt.mystic.foundation.concrete.sample.goodbyeworld -import lgbt.mystic.foundation.conrete.sample.common.logOnDisable -import lgbt.mystic.foundation.conrete.sample.common.logOnEnable +import lgbt.mystic.foundation.concrete.sample.common.logOnDisable +import lgbt.mystic.foundation.concrete.sample.common.logOnEnable import org.bukkit.plugin.java.JavaPlugin class GoodbyeWorldPlugin : JavaPlugin() { diff --git a/samples/mixed/bukkit-plugins/hello-world/src/main/kotlin/lgbt/mystic/foundation/concrete/sample/helloworld/HelloWorldPlugin.kt b/samples/mixed/bukkit-plugins/hello-world/src/main/kotlin/lgbt/mystic/foundation/concrete/sample/helloworld/HelloWorldPlugin.kt index 55941a4..f071e08 100644 --- a/samples/mixed/bukkit-plugins/hello-world/src/main/kotlin/lgbt/mystic/foundation/concrete/sample/helloworld/HelloWorldPlugin.kt +++ b/samples/mixed/bukkit-plugins/hello-world/src/main/kotlin/lgbt/mystic/foundation/concrete/sample/helloworld/HelloWorldPlugin.kt @@ -1,8 +1,8 @@ package lgbt.mystic.foundation.concrete.sample.helloworld import lgbt.mystic.foundation.concrete.other.OtherLibrary -import lgbt.mystic.foundation.conrete.sample.common.logOnDisable -import lgbt.mystic.foundation.conrete.sample.common.logOnEnable +import lgbt.mystic.foundation.concrete.sample.common.logOnDisable +import lgbt.mystic.foundation.concrete.sample.common.logOnEnable import org.bukkit.plugin.java.JavaPlugin class HelloWorldPlugin : JavaPlugin() { diff --git a/samples/mixed/gradle/wrapper/gradle-wrapper.properties b/samples/mixed/gradle/wrapper/gradle-wrapper.properties index 41dfb87..aa991fc 100644 --- a/samples/mixed/gradle/wrapper/gradle-wrapper.properties +++ b/samples/mixed/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/samples/simple/gradle/wrapper/gradle-wrapper.properties b/samples/simple/gradle/wrapper/gradle-wrapper.properties index 41dfb87..aa991fc 100644 --- a/samples/simple/gradle/wrapper/gradle-wrapper.properties +++ b/samples/simple/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/kotlin/lgbt/mystic/foundation/concrete/ConcretePluginPlugin.kt b/src/main/kotlin/lgbt/mystic/foundation/concrete/ConcretePluginPlugin.kt index 5caa317..697cf33 100644 --- a/src/main/kotlin/lgbt/mystic/foundation/concrete/ConcretePluginPlugin.kt +++ b/src/main/kotlin/lgbt/mystic/foundation/concrete/ConcretePluginPlugin.kt @@ -11,7 +11,7 @@ class ConcretePluginPlugin : ConcreteProjectPlugin() { project.plugins.apply("com.github.johnrengelman.shadow") - (project.tasks.getByName("processResources") as ProcessResources).apply { + project.tasks.find("processResources")!!.apply { val props = mapOf("version" to project.version.toString()) inputs.properties(props) filteringCharset = "UTF-8" @@ -24,7 +24,7 @@ class ConcretePluginPlugin : ConcreteProjectPlugin() { archiveClassifier.set("plugin") } - project.tasks["assemble"].dependsOn(project.tasks["shadowJar"]) + project.tasks.addTaskDependency("assemble", "shadowJar") project.concreteRootProject.tasks["setupPaperServer"].dependsOn(project.tasks["shadowJar"]) } diff --git a/src/main/kotlin/lgbt/mystic/foundation/concrete/RunPaperServer.kt b/src/main/kotlin/lgbt/mystic/foundation/concrete/RunPaperServer.kt index ea76298..c0dbfad 100644 --- a/src/main/kotlin/lgbt/mystic/foundation/concrete/RunPaperServer.kt +++ b/src/main/kotlin/lgbt/mystic/foundation/concrete/RunPaperServer.kt @@ -1,6 +1,7 @@ package lgbt.mystic.foundation.concrete import org.gradle.api.DefaultTask +import org.gradle.api.tasks.Input import org.gradle.api.tasks.TaskAction import org.gradle.kotlin.dsl.getByType import java.io.File @@ -11,6 +12,12 @@ open class RunPaperServer : DefaultTask() { outputs.upToDateWhen { false } } + @get:Input + var additionalServerArguments = mutableListOf() + + @get:Input + var disableServerGui = true + @TaskAction fun runPaperServer() { val concrete = project.extensions.getByType() @@ -22,7 +29,14 @@ open class RunPaperServer : DefaultTask() { project.javaexec { classpath(paperJarFile.absolutePath) workingDir(minecraftServerDirectory) - args("nogui") + + val allServerArguments = mutableListOf() + allServerArguments.addAll(additionalServerArguments) + if (disableServerGui) { + allServerArguments.add("nogui") + } + + args(allServerArguments) mainClass.set(mainClassName) } } diff --git a/src/main/kotlin/lgbt/mystic/foundation/concrete/extensions.kt b/src/main/kotlin/lgbt/mystic/foundation/concrete/extensions.kt index 4f260c8..0448c93 100644 --- a/src/main/kotlin/lgbt/mystic/foundation/concrete/extensions.kt +++ b/src/main/kotlin/lgbt/mystic/foundation/concrete/extensions.kt @@ -7,9 +7,20 @@ import org.gradle.api.tasks.TaskOutputs import java.nio.file.FileSystems import java.nio.file.Path +/** + * Checks if the project has the [ConcretePluginPlugin] applied. + */ internal fun Project.isPluginProject() = plugins.hasPlugin(ConcretePluginPlugin::class.java) + +/** + * Finds all projects in the project's hierarchy that are plugins. + */ internal fun Project.findPluginProjects() = allprojects.filter { project -> project.isPluginProject() } +internal fun TaskContainer.addTaskDependency(dependent: String, dependency: String) { + getByName(dependent).dependsOn(getByName(dependency)) +} + internal inline fun TaskContainer.find(name: String) = findByName(name) as T? @@ -26,6 +37,10 @@ internal val Project.concreteRootExtension: ConcreteExtension error = { "Failed to find concrete root. Did you apply the concrete root plugin?" } ) +/** + * Finds the concrete root project, which is the first project in the project hierarchy + * that has the concrete extension. + */ internal val Project.concreteRootProject: Project get() = findTargetParent( valid = { extensions.findByType(ConcreteExtension::class.java) != null }, @@ -33,6 +48,11 @@ internal val Project.concreteRootProject: Project error = { "Failed to find concrete root. Did you apply the concrete root plugin?" } ) +/** + * Scans a project hierarchy looking for a project matching the criteria specified in [valid]. + * If found, [extract] is called and the result is returned. If no matching project is found, [error] is called + * and passed to RuntimeException as an error string. + */ internal fun Project.findTargetParent(valid: Project.() -> Boolean, extract: Project.() -> T, error: () -> String): T { if (valid(this)) { return extract(this)