mirror of
https://github.com/GayPizzaSpecifications/concrete.git
synced 2025-08-03 21:21:33 +00:00
Take review comments.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
package lgbt.mystic.foundation.conrete.sample.common
|
||||
package lgbt.mystic.foundation.concrete.sample.common
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin
|
||||
|
@ -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() {
|
||||
|
@ -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() {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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