mirror of
https://github.com/GayPizzaSpecifications/concrete.git
synced 2025-08-04 13:41:33 +00:00
Take review comments.
This commit is contained in:
@ -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>("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"])
|
||||
}
|
||||
|
@ -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<String>()
|
||||
|
||||
@get:Input
|
||||
var disableServerGui = true
|
||||
|
||||
@TaskAction
|
||||
fun runPaperServer() {
|
||||
val concrete = project.extensions.getByType<ConcreteExtension>()
|
||||
@ -22,7 +29,14 @@ open class RunPaperServer : DefaultTask() {
|
||||
project.javaexec {
|
||||
classpath(paperJarFile.absolutePath)
|
||||
workingDir(minecraftServerDirectory)
|
||||
args("nogui")
|
||||
|
||||
val allServerArguments = mutableListOf<String>()
|
||||
allServerArguments.addAll(additionalServerArguments)
|
||||
if (disableServerGui) {
|
||||
allServerArguments.add("nogui")
|
||||
}
|
||||
|
||||
args(allServerArguments)
|
||||
mainClass.set(mainClassName)
|
||||
}
|
||||
}
|
||||
|
@ -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 <reified T> 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 <T> Project.findTargetParent(valid: Project.() -> Boolean, extract: Project.() -> T, error: () -> String): T {
|
||||
if (valid(this)) {
|
||||
return extract(this)
|
||||
|
Reference in New Issue
Block a user