mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-04 16:49:11 +00:00
Remove plugins.gradle and factor into common extension
This commit is contained in:
+6
-11
@@ -6,15 +6,11 @@ buildscript {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
|
||||
classpath group: 'com.moandjiezana.toml', name: 'toml4j', version: '0.7.1'
|
||||
classpath group: 'org.jetbrains.kotlin', name: 'kotlin-gradle-plugin', version: "$kotlinVersion"
|
||||
}
|
||||
}
|
||||
|
||||
ext.pluginsDir = "$projectDir/src/plugins"
|
||||
|
||||
apply plugin: 'kotlin'
|
||||
apply from: 'plugins.gradle'
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
@@ -24,12 +20,6 @@ sourceSets {
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url { 'https://dl.bintray.com/kotlin/kotlinx/' }
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile project(':cache')
|
||||
compile project(':net')
|
||||
@@ -41,6 +31,11 @@ dependencies {
|
||||
compile group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-jdk8', version: '0.16'
|
||||
compile group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core', version: '0.16'
|
||||
|
||||
project(":game:plugin").subprojects.each { plugin ->
|
||||
println(plugin)
|
||||
runtime plugin
|
||||
}
|
||||
|
||||
testCompile group: 'org.assertj', name: 'assertj-core', version: '3.8.0'
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
apply plugin: 'kotlin'
|
||||
|
||||
|
||||
dependencies {
|
||||
compile project(':game')
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
apolloPlugin {
|
||||
name = "Banking"
|
||||
packageName = "org.apollo.game.plugin.banking"
|
||||
authors = [
|
||||
"Major",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
import com.moandjiezana.toml.Toml
|
||||
|
||||
import java.nio.file.Paths
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath group: 'com.moandjiezana.toml', name: 'toml4j', version: '0.7.1'
|
||||
}
|
||||
}
|
||||
|
||||
subprojects {
|
||||
if (it.buildFile.exists()) {
|
||||
apply plugin: 'apollo-plugin'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
url { 'https://dl.bintray.com/kotlin/kotlinx/' }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task("convertPluginTomlToGradle") {
|
||||
def pluginTree = fileTree(dir: "${project.rootDir}/game/src/plugins/")
|
||||
def pluginDefinitions = pluginTree.matching {
|
||||
include "**/*.toml"
|
||||
}
|
||||
|
||||
pluginDefinitions.each { file ->
|
||||
def meta = new Toml()
|
||||
meta.read(file.absoluteFile)
|
||||
|
||||
def pluginFolder = Paths.get(file.parentFile.absolutePath)
|
||||
def name = meta.getString("name", pluginFolder.getFileName().toString())
|
||||
def normalizedName = name.replaceAll("[^a-zA-Z0-9_]", '_').toLowerCase()
|
||||
def description = meta.getString("description", "")
|
||||
def packageName = meta.getString("package", "org.apollo.game.plugin")
|
||||
def authors = meta.getList("authors", new ArrayList())
|
||||
def dependencies = meta.getList("dependencies", new ArrayList())
|
||||
|
||||
def buildFile = new File(pluginFolder.toFile(), 'build.gradle')
|
||||
buildFile.withWriter('UTF-8') { writer ->
|
||||
writer.write("apolloPlugin {\n")
|
||||
writer.write(" name = \"$normalizedName\"\n")
|
||||
|
||||
if (packageName != "org.apollo.game.plugin") {
|
||||
writer.write(" packageName = \"$packageName\"\n")
|
||||
}
|
||||
|
||||
if (description.length() > 0) {
|
||||
writer.write(" description = \"$description\"\n")
|
||||
}
|
||||
|
||||
if (authors.size > 0) {
|
||||
writer.write(" authors = [\n")
|
||||
authors.each { writer.write(" \"$it\",\n") }
|
||||
writer.write(" ]\n")
|
||||
}
|
||||
|
||||
if (dependencies.size > 0) {
|
||||
writer.write(" dependencies = [\n")
|
||||
dependencies.each { writer.write(" \"$it\",\n") }
|
||||
writer.write(" ]\n")
|
||||
}
|
||||
|
||||
writer.write("}")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
apolloPlugin {
|
||||
name = "private-messaging"
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
apolloPlugin {
|
||||
name = "Chat commands"
|
||||
packageName = "org.apollo.game.plugin.cmd"
|
||||
authors = [
|
||||
"Graham",
|
||||
"Major",
|
||||
"lare96",
|
||||
"cubeee",
|
||||
]
|
||||
dependencies = [
|
||||
"util:command",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
apolloPlugin {
|
||||
name = "consumables"
|
||||
packageName = "org.apollo.game.plugin.consumables"
|
||||
authors = [
|
||||
"Gary Tierney",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
apolloPlugin {
|
||||
name = "training-dummy"
|
||||
packageName = "org.apollo.game.plugin.entity"
|
||||
authors = [
|
||||
"Gary Tierney",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
apolloPlugin {
|
||||
name = "emote-tab"
|
||||
packageName = "org.apollo.game.plugin.widget"
|
||||
authors = [
|
||||
"Gary Tierney",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
apolloPlugin {
|
||||
name = "following"
|
||||
packageName = "org.apollo.game.plugin.entity"
|
||||
authors = [
|
||||
"Gary Tierney",
|
||||
]
|
||||
dependencies = [
|
||||
"walkto",
|
||||
"command_utilities",
|
||||
"player_action",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
apolloPlugin {
|
||||
name = "player_action"
|
||||
packageName = "org.apollo.game.plugin.entity"
|
||||
authors = [
|
||||
"Gary Tierney",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
apolloPlugin {
|
||||
name = "spawning"
|
||||
packageName = "org.apollo.game.plugin.entity"
|
||||
authors = [
|
||||
"Gary Tierney",
|
||||
]
|
||||
dependencies = [
|
||||
"entity_lookup",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
apolloPlugin {
|
||||
name = "walkto"
|
||||
packageName = "org.apollo.plugin.entity.walkto"
|
||||
authors = [
|
||||
"Gary Tierney",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
apolloPlugin {
|
||||
name = "al-kharid npc spawns"
|
||||
packageName = "org.apollo.game.plugin.locations"
|
||||
authors = [
|
||||
"Jesse W",
|
||||
]
|
||||
dependencies = [
|
||||
"spawning",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
apolloPlugin {
|
||||
name = "edgeville npc spawns"
|
||||
packageName = "org.apollo.game.plugin.locations"
|
||||
authors = [
|
||||
"Jesse W",
|
||||
]
|
||||
dependencies = [
|
||||
"spawning",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
apolloPlugin {
|
||||
name = "falador npc spawns"
|
||||
packageName = "org.apollo.game.plugin.locations"
|
||||
authors = [
|
||||
"Jesse W",
|
||||
]
|
||||
dependencies = [
|
||||
"spawning",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
apolloPlugin {
|
||||
name = "lumbridge npc spawns"
|
||||
packageName = "org.apollo.game.plugin.locations"
|
||||
authors = [
|
||||
"Gary Tierney",
|
||||
]
|
||||
dependencies = [
|
||||
"spawning",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
apolloPlugin {
|
||||
name = "tutorial island npc spawns"
|
||||
packageName = "org.apollo.game.plugin.locations"
|
||||
authors = [
|
||||
"Jesse W",
|
||||
]
|
||||
dependencies = [
|
||||
"spawning",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
apolloPlugin {
|
||||
name = "varrock npc spawns"
|
||||
packageName = "org.apollo.game.plugin.locations"
|
||||
authors = [
|
||||
"Jesse W",
|
||||
]
|
||||
dependencies = [
|
||||
"spawning",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
apolloPlugin {
|
||||
name = "logout"
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
apolloPlugin {
|
||||
name = "run"
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
apolloPlugin {
|
||||
name = "command utilities"
|
||||
packageName = "org.apollo.game.plugins.util"
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
apolloPlugin {
|
||||
name = "entity lookup"
|
||||
packageName = "org.apollo.game.plugins.util"
|
||||
}
|
||||
@@ -1,210 +0,0 @@
|
||||
import com.moandjiezana.toml.Toml
|
||||
import org.apollo.build.tasks.KotlinScriptCompileTask
|
||||
|
||||
import java.nio.file.Paths
|
||||
|
||||
def PLUGIN_VERIFICATION_GROUP = "plugin-verification"
|
||||
def PLUGIN_BUILD_GROUP = "plugin-build"
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath group: 'com.moandjiezana.toml', name: 'toml4j', version: '0.7.1'
|
||||
}
|
||||
}
|
||||
|
||||
task testPlugins {
|
||||
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
pluginTesting {
|
||||
kotlin {
|
||||
srcDir 'src/pluginTesting/kotlin'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
pluginTestingCompile sourceSets.test.output
|
||||
pluginTestingCompile sourceSets.test.compileClasspath
|
||||
}
|
||||
|
||||
check.dependsOn testPlugins
|
||||
|
||||
class PluginBuildData {
|
||||
PluginBuildData(String normalizedName, SourceSet mainSources, SourceSet testSources,
|
||||
FileCollection scriptFiles, List<String> dependencyNames) {
|
||||
this.normalizedName = normalizedName
|
||||
this.mainSources = mainSources
|
||||
this.testSources = testSources
|
||||
this.scriptFiles = scriptFiles
|
||||
this.dependencyNames = dependencyNames
|
||||
}
|
||||
|
||||
String normalizedName
|
||||
SourceSet mainSources
|
||||
SourceSet testSources
|
||||
FileCollection scriptFiles
|
||||
List<String> dependencyNames
|
||||
}
|
||||
|
||||
Map<String, PluginBuildData> pluginMap = new HashMap<>()
|
||||
|
||||
def configurePluginDependencies(SourceSet mainSources, SourceSet testSources,
|
||||
List<PluginBuildData> pluginDependencies) {
|
||||
|
||||
def testConfiguration = testSources.compileConfigurationName
|
||||
def mainConfiguration = mainSources.compileConfigurationName
|
||||
|
||||
// Add this plugin as a runtime dependency to the main game project
|
||||
dependencies.add(configurations.runtime.name, mainSources.output)
|
||||
|
||||
pluginDependencies.each {
|
||||
dependencies.add(mainConfiguration, it.mainSources.output)
|
||||
dependencies.add(testConfiguration, it.testSources.output)
|
||||
}
|
||||
|
||||
dependencies.add(mainConfiguration, configurations.compile)
|
||||
dependencies.add(mainConfiguration, sourceSets.main.output)
|
||||
|
||||
dependencies.add(testConfiguration, mainSources.output)
|
||||
dependencies.add(testConfiguration, configurations.testCompile)
|
||||
dependencies.add(testConfiguration, sourceSets.test.output)
|
||||
dependencies.add(testConfiguration, sourceSets.test.compileClasspath)
|
||||
dependencies.add(testConfiguration, sourceSets.pluginTesting.output)
|
||||
}
|
||||
|
||||
def configurePluginTasks(String name, SourceSet mainSources, SourceSet testSources,
|
||||
FileCollection scriptFiles, List<PluginBuildData> pluginDependencies) {
|
||||
def taskName = name.split("_").collect { it.capitalize() }.join("")
|
||||
|
||||
def testsTask = task("test${taskName}", type: Test) {
|
||||
group = "plugin-verification"
|
||||
|
||||
testClassesDirs = testSources.output.classesDirs
|
||||
classpath = testSources.runtimeClasspath + mainSources.runtimeClasspath
|
||||
|
||||
binResultsDir = file("$buildDir/plugin-test-results/binary/$name")
|
||||
|
||||
reports {
|
||||
junitXml.destination = "$buildDir/plugin-tests/$name"
|
||||
}
|
||||
|
||||
testLogging {
|
||||
events "passed", "skipped", "failed"
|
||||
}
|
||||
}
|
||||
|
||||
testPlugins.dependsOn testsTask
|
||||
|
||||
if (!scriptFiles.empty) {
|
||||
def compileScriptsTask = task("compile${taskName}Scripts", type: KotlinScriptCompileTask) {
|
||||
group = "plugin-compile"
|
||||
|
||||
def outputDir = mainSources.output.classesDir
|
||||
|
||||
inputs.files scriptFiles
|
||||
outputsDir = outputDir
|
||||
|
||||
compileClasspath = sourceSets.main.compileClasspath +
|
||||
sourceSets.main.runtimeClasspath +
|
||||
mainSources.compileClasspath +
|
||||
mainSources.runtimeClasspath
|
||||
|
||||
scriptDefinitionClass = "org.apollo.game.plugin.kotlin.KotlinPluginScript"
|
||||
mustRunAfter tasks[mainSources.classesTaskName]
|
||||
}
|
||||
|
||||
testPlugins.dependsOn compileScriptsTask
|
||||
tasks[mainSources.classesTaskName].finalizedBy compileScriptsTask
|
||||
}
|
||||
}
|
||||
|
||||
def pluginTree = fileTree(dir: "$pluginsDir")
|
||||
def pluginDefinitions = pluginTree.matching {
|
||||
include '**/meta.toml'
|
||||
}
|
||||
|
||||
class PluginScriptFile {
|
||||
def scriptFileName
|
||||
def pluginDir
|
||||
|
||||
PluginScriptFile(scriptFileName, pluginDir) {
|
||||
this.scriptFileName = scriptFileName
|
||||
this.pluginDir = pluginDir
|
||||
}
|
||||
}
|
||||
|
||||
def pluginFiles = new ArrayList<PluginScriptFile>()
|
||||
|
||||
pluginDefinitions.each { file ->
|
||||
def meta = new Toml()
|
||||
meta.read(file.absoluteFile)
|
||||
|
||||
def pluginFolder = Paths.get(file.parentFile.absolutePath)
|
||||
def name = meta.getString("name", pluginFolder.getFileName().toString())
|
||||
def normalizedName = name.replaceAll("[^a-zA-Z0-9_]", '_').toLowerCase()
|
||||
def displayNameArray = normalizedName.split("_").collect { it.capitalize() }.join("").toCharArray()
|
||||
displayNameArray[0] = displayNameArray[0].toLowerCase()
|
||||
|
||||
def sourceSetName = new String(displayNameArray)
|
||||
|
||||
def packageName = meta.getString("package", "org.apollo.game.plugin")
|
||||
def authors = meta.getList("authors", new ArrayList())
|
||||
def dependencies = meta.getList("dependencies", new ArrayList())
|
||||
|
||||
def scripts = fileTree(file.parentFile) {
|
||||
include '**/*.plugin.kts'
|
||||
exclude '*.kt'
|
||||
}
|
||||
|
||||
def srcsDir = meta.getString("config.src", "src/")
|
||||
def testDir = meta.getString("config.test", "test/")
|
||||
|
||||
def mainSources = sourceSets.create("${sourceSetName}Main") {
|
||||
kotlin {
|
||||
srcDir pluginFolder.resolve(srcsDir).toString()
|
||||
exclude '*.kts'
|
||||
}
|
||||
}
|
||||
|
||||
def testSources = sourceSets.create("${sourceSetName}Test") {
|
||||
kotlin {
|
||||
srcDir pluginFolder.resolve(testDir).toString()
|
||||
}
|
||||
}
|
||||
|
||||
scripts.files.forEach {
|
||||
def scriptFileName = it.getName()
|
||||
|
||||
//@todo - also compare package
|
||||
def existingFile = pluginFiles.find { it.scriptFileName == scriptFileName }
|
||||
if (existingFile != null) {
|
||||
throw new GradleException("Duplicate script file found named ${scriptFileName} in ${pluginFolder}, " +
|
||||
"also exists in ${existingFile.pluginDir}")
|
||||
}
|
||||
|
||||
pluginFiles.add(new PluginScriptFile(scriptFileName, pluginFolder))
|
||||
}
|
||||
|
||||
def pluginData = new PluginBuildData(normalizedName, mainSources, testSources, scripts, dependencies)
|
||||
pluginMap.put(normalizedName, pluginData)
|
||||
}
|
||||
|
||||
pluginMap.values().each {
|
||||
def dependencies = it.dependencyNames.collect { name -> pluginMap.get(name) }
|
||||
|
||||
configurePluginDependencies(it.mainSources, it.testSources, dependencies)
|
||||
configurePluginTasks(it.normalizedName, it.mainSources, it.testSources, it.scriptFiles, dependencies)
|
||||
}
|
||||
|
||||
task testPluginsReport(type: TestReport) {
|
||||
destinationDir = file("$buildDir/reports/plugin-tests")
|
||||
reportOn tasks.findAll { it.group.equals("plugin-verification"); }
|
||||
}
|
||||
|
||||
testPlugins.finalizedBy testPluginsReport
|
||||
@@ -23,6 +23,6 @@ fun <T : PlayerEvent> on_player_event(type: () -> KClass<T>): KotlinPlayerHandle
|
||||
fun on_command(command: String, privileges: PrivilegeLevel): KotlinPlayerHandlerProxyTrait<Command> = null!!
|
||||
fun on_button(button: Int): KotlinPlayerHandlerProxyTrait<ButtonMessage> = null!!
|
||||
|
||||
fun start(callback: (World) -> Unit) = {}
|
||||
fun start(callback: (World) -> Unit) {}
|
||||
fun stop(callback: (World) -> Unit) = {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user