mirror of
https://github.com/GayPizzaSpecifications/concrete.git
synced 2025-08-04 05:31:34 +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
|
import org.bukkit.plugin.java.JavaPlugin
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
package lgbt.mystic.foundation.concrete.sample.goodbyeworld
|
package lgbt.mystic.foundation.concrete.sample.goodbyeworld
|
||||||
|
|
||||||
import lgbt.mystic.foundation.conrete.sample.common.logOnDisable
|
import lgbt.mystic.foundation.concrete.sample.common.logOnDisable
|
||||||
import lgbt.mystic.foundation.conrete.sample.common.logOnEnable
|
import lgbt.mystic.foundation.concrete.sample.common.logOnEnable
|
||||||
import org.bukkit.plugin.java.JavaPlugin
|
import org.bukkit.plugin.java.JavaPlugin
|
||||||
|
|
||||||
class GoodbyeWorldPlugin : JavaPlugin() {
|
class GoodbyeWorldPlugin : JavaPlugin() {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package lgbt.mystic.foundation.concrete.sample.helloworld
|
package lgbt.mystic.foundation.concrete.sample.helloworld
|
||||||
|
|
||||||
import lgbt.mystic.foundation.concrete.other.OtherLibrary
|
import lgbt.mystic.foundation.concrete.other.OtherLibrary
|
||||||
import lgbt.mystic.foundation.conrete.sample.common.logOnDisable
|
import lgbt.mystic.foundation.concrete.sample.common.logOnDisable
|
||||||
import lgbt.mystic.foundation.conrete.sample.common.logOnEnable
|
import lgbt.mystic.foundation.concrete.sample.common.logOnEnable
|
||||||
import org.bukkit.plugin.java.JavaPlugin
|
import org.bukkit.plugin.java.JavaPlugin
|
||||||
|
|
||||||
class HelloWorldPlugin : JavaPlugin() {
|
class HelloWorldPlugin : JavaPlugin() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
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
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
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
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
@ -11,7 +11,7 @@ class ConcretePluginPlugin : ConcreteProjectPlugin() {
|
|||||||
|
|
||||||
project.plugins.apply("com.github.johnrengelman.shadow")
|
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())
|
val props = mapOf("version" to project.version.toString())
|
||||||
inputs.properties(props)
|
inputs.properties(props)
|
||||||
filteringCharset = "UTF-8"
|
filteringCharset = "UTF-8"
|
||||||
@ -24,7 +24,7 @@ class ConcretePluginPlugin : ConcreteProjectPlugin() {
|
|||||||
archiveClassifier.set("plugin")
|
archiveClassifier.set("plugin")
|
||||||
}
|
}
|
||||||
|
|
||||||
project.tasks["assemble"].dependsOn(project.tasks["shadowJar"])
|
project.tasks.addTaskDependency("assemble", "shadowJar")
|
||||||
|
|
||||||
project.concreteRootProject.tasks["setupPaperServer"].dependsOn(project.tasks["shadowJar"])
|
project.concreteRootProject.tasks["setupPaperServer"].dependsOn(project.tasks["shadowJar"])
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package lgbt.mystic.foundation.concrete
|
package lgbt.mystic.foundation.concrete
|
||||||
|
|
||||||
import org.gradle.api.DefaultTask
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.tasks.Input
|
||||||
import org.gradle.api.tasks.TaskAction
|
import org.gradle.api.tasks.TaskAction
|
||||||
import org.gradle.kotlin.dsl.getByType
|
import org.gradle.kotlin.dsl.getByType
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@ -11,6 +12,12 @@ open class RunPaperServer : DefaultTask() {
|
|||||||
outputs.upToDateWhen { false }
|
outputs.upToDateWhen { false }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@get:Input
|
||||||
|
var additionalServerArguments = mutableListOf<String>()
|
||||||
|
|
||||||
|
@get:Input
|
||||||
|
var disableServerGui = true
|
||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
fun runPaperServer() {
|
fun runPaperServer() {
|
||||||
val concrete = project.extensions.getByType<ConcreteExtension>()
|
val concrete = project.extensions.getByType<ConcreteExtension>()
|
||||||
@ -22,7 +29,14 @@ open class RunPaperServer : DefaultTask() {
|
|||||||
project.javaexec {
|
project.javaexec {
|
||||||
classpath(paperJarFile.absolutePath)
|
classpath(paperJarFile.absolutePath)
|
||||||
workingDir(minecraftServerDirectory)
|
workingDir(minecraftServerDirectory)
|
||||||
args("nogui")
|
|
||||||
|
val allServerArguments = mutableListOf<String>()
|
||||||
|
allServerArguments.addAll(additionalServerArguments)
|
||||||
|
if (disableServerGui) {
|
||||||
|
allServerArguments.add("nogui")
|
||||||
|
}
|
||||||
|
|
||||||
|
args(allServerArguments)
|
||||||
mainClass.set(mainClassName)
|
mainClass.set(mainClassName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,20 @@ import org.gradle.api.tasks.TaskOutputs
|
|||||||
import java.nio.file.FileSystems
|
import java.nio.file.FileSystems
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the project has the [ConcretePluginPlugin] applied.
|
||||||
|
*/
|
||||||
internal fun Project.isPluginProject() = plugins.hasPlugin(ConcretePluginPlugin::class.java)
|
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 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) =
|
internal inline fun <reified T> TaskContainer.find(name: String) =
|
||||||
findByName(name) as T?
|
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?" }
|
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
|
internal val Project.concreteRootProject: Project
|
||||||
get() = findTargetParent(
|
get() = findTargetParent(
|
||||||
valid = { extensions.findByType(ConcreteExtension::class.java) != null },
|
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?" }
|
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 {
|
internal fun <T> Project.findTargetParent(valid: Project.() -> Boolean, extract: Project.() -> T, error: () -> String): T {
|
||||||
if (valid(this)) {
|
if (valid(this)) {
|
||||||
return extract(this)
|
return extract(this)
|
||||||
|
Reference in New Issue
Block a user