diff --git a/.gitignore b/.gitignore index 1b37aca0..8de8fb06 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ /lib/ */target/ */build/ +**/build/ \ No newline at end of file diff --git a/buildSrc/src/main/groovy/org/apollo/build/plugin/ApolloPlugin.groovy b/buildSrc/src/main/groovy/org/apollo/build/plugin/ApolloPlugin.groovy index e312c143..f8f4459b 100644 --- a/buildSrc/src/main/groovy/org/apollo/build/plugin/ApolloPlugin.groovy +++ b/buildSrc/src/main/groovy/org/apollo/build/plugin/ApolloPlugin.groovy @@ -7,6 +7,6 @@ class ApolloPlugin implements Plugin { @Override void apply(Project project) { - project.extensions.create('apolloPlugin', ApolloPluginExtension, project) + project.extensions.create('plugin', ApolloPluginExtension, project) } } diff --git a/buildSrc/src/main/groovy/org/apollo/build/plugin/ApolloPluginExtension.groovy b/buildSrc/src/main/groovy/org/apollo/build/plugin/ApolloPluginExtension.groovy index 00743dcf..67fa8344 100644 --- a/buildSrc/src/main/groovy/org/apollo/build/plugin/ApolloPluginExtension.groovy +++ b/buildSrc/src/main/groovy/org/apollo/build/plugin/ApolloPluginExtension.groovy @@ -3,9 +3,10 @@ package org.apollo.build.plugin import org.apollo.build.plugin.tasks.ApolloScriptCompileTask import org.gradle.api.Project import org.gradle.api.file.FileTree +import org.gradle.api.tasks.testing.Test class ApolloPluginExtension { - private Project project + final Project project /** * The name of this plugin (defaults to the project name). @@ -73,29 +74,49 @@ class ApolloPluginExtension { } } - project.dependencies.add('compile', gameProject) - project.dependencies.add('testCompile', pluginTestingProject.sourceSets.test.output) + def mainSources = project.sourceSets.main + def gameCompileConfiguration = gameProject.configurations.getByName("compile") + def gameSources = gameProject.sourceSets.main + def gameDependencies = gameCompileConfiguration.dependencies - dependencies.each { - project.dependencies.add('compile', project.findProject(":game:plugin:$it")) + gameDependencies.each { + project.dependencies.add('compile', it) } - project.tasks.create('compileScripts', ApolloScriptCompileTask) { - def mainSources = project.sourceSets.main - def outputDir = mainSources.output.classesDir + project.dependencies.add('compile', gameSources.output) + project.dependencies.add('testCompile', pluginTestingProject) + project.dependencies.add('testCompile', project.sourceSets.main.output) + def kotlinCompileTask = project.tasks['compileKotlin'] + + project.tasks.create('compileScripts', ApolloScriptCompileTask) { FileTree filtered = project.fileTree(srcDir).matching { include '*.kts' } inputs.files filtered.files - outputsDir = outputDir + outputsDir = new File("${project.buildDir}/classes/main") compileClasspath = mainSources.compileClasspath + mainSources.runtimeClasspath scriptDefinitionClass = "org.apollo.game.plugin.kotlin.KotlinPluginScript" - mustRunAfter project.tasks['classes'] + mustRunAfter kotlinCompileTask } + + kotlinCompileTask.finalizedBy project.tasks['compileScripts'] } + + def getDependencies() { + return dependencies + } + + def setDependencies(List dependencies) { + dependencies.each { + project.dependencies.add('compile', project.findProject(":game:plugin:$it")) + } + + this.dependencies = dependencies + } + } diff --git a/buildSrc/src/main/groovy/org/apollo/build/plugin/tasks/ApolloScriptCompileTask.groovy b/buildSrc/src/main/groovy/org/apollo/build/plugin/tasks/ApolloScriptCompileTask.groovy index 2846531b..7189dc57 100644 --- a/buildSrc/src/main/groovy/org/apollo/build/plugin/tasks/ApolloScriptCompileTask.groovy +++ b/buildSrc/src/main/groovy/org/apollo/build/plugin/tasks/ApolloScriptCompileTask.groovy @@ -10,6 +10,7 @@ import org.jetbrains.kotlin.cli.common.messages.MessageRenderer import org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector class ApolloScriptCompileTask extends DefaultTask { + @Input File outputsDir @Input @@ -47,12 +48,11 @@ class ApolloScriptCompileTask extends DefaultTask { def normalizedPrefix = normalizedFilename.subSequence(0, normalizedFilename.lastIndexOf('.')) FileFilter filter = { - it.name.startsWith(normalizedPrefix) + return it.name.startsWith(normalizedPrefix) } - def binaries = outputsDir.listFiles FileFilter { dir, name -> name.startsWith(normalizedPrefix) } - - binaries.forEach { + def binaries = outputsDir.listFiles(filter) + binaries.each { it.delete() } } diff --git a/game/build.gradle b/game/build.gradle index d1d4bab3..cb8af5e7 100644 --- a/game/build.gradle +++ b/game/build.gradle @@ -32,7 +32,6 @@ dependencies { compile group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core', version: '0.16' project(":game:plugin").subprojects.each { plugin -> - println(plugin) runtime plugin } diff --git a/game/plugin-testing/build.gradle b/game/plugin-testing/build.gradle index 2c0f8547..534eabbf 100644 --- a/game/plugin-testing/build.gradle +++ b/game/plugin-testing/build.gradle @@ -2,5 +2,15 @@ apply plugin: 'kotlin' dependencies { - compile project(':game') + def gameProject = project(':game') + + compile gameProject.sourceSets.main.output + compile group: 'org.assertj', name: 'assertj-core', version: '3.8.0' + + def gameTestConfiguration = gameProject.configurations.testCompileOnly + def gameTestDependencies = gameTestConfiguration.dependencies + + gameTestDependencies.each { + compile it + } } \ No newline at end of file diff --git a/game/plugin-testing/src/test/kotlin/org/apollo/game/plugin/testing/KotlinPluginTest.kt b/game/plugin-testing/src/main/kotlin/org/apollo/game/plugin/testing/KotlinPluginTest.kt similarity index 100% rename from game/plugin-testing/src/test/kotlin/org/apollo/game/plugin/testing/KotlinPluginTest.kt rename to game/plugin-testing/src/main/kotlin/org/apollo/game/plugin/testing/KotlinPluginTest.kt diff --git a/game/plugin-testing/src/test/kotlin/org/apollo/game/plugin/testing/KotlinPluginTestHelpers.kt b/game/plugin-testing/src/main/kotlin/org/apollo/game/plugin/testing/KotlinPluginTestHelpers.kt similarity index 100% rename from game/plugin-testing/src/test/kotlin/org/apollo/game/plugin/testing/KotlinPluginTestHelpers.kt rename to game/plugin-testing/src/main/kotlin/org/apollo/game/plugin/testing/KotlinPluginTestHelpers.kt diff --git a/game/plugin-testing/src/test/kotlin/org/apollo/game/plugin/testing/fakes/FakePluginContextFactory.kt b/game/plugin-testing/src/main/kotlin/org/apollo/game/plugin/testing/fakes/FakePluginContextFactory.kt similarity index 100% rename from game/plugin-testing/src/test/kotlin/org/apollo/game/plugin/testing/fakes/FakePluginContextFactory.kt rename to game/plugin-testing/src/main/kotlin/org/apollo/game/plugin/testing/fakes/FakePluginContextFactory.kt diff --git a/game/plugin-testing/src/test/kotlin/org/apollo/game/plugin/testing/mockito/KotlinArgMatcher.kt b/game/plugin-testing/src/main/kotlin/org/apollo/game/plugin/testing/mockito/KotlinArgMatcher.kt similarity index 100% rename from game/plugin-testing/src/test/kotlin/org/apollo/game/plugin/testing/mockito/KotlinArgMatcher.kt rename to game/plugin-testing/src/main/kotlin/org/apollo/game/plugin/testing/mockito/KotlinArgMatcher.kt diff --git a/game/plugin-testing/src/test/kotlin/org/apollo/game/plugin/testing/mockito/KotlinMockitoExtensions.kt b/game/plugin-testing/src/main/kotlin/org/apollo/game/plugin/testing/mockito/KotlinMockitoExtensions.kt similarity index 100% rename from game/plugin-testing/src/test/kotlin/org/apollo/game/plugin/testing/mockito/KotlinMockitoExtensions.kt rename to game/plugin-testing/src/main/kotlin/org/apollo/game/plugin/testing/mockito/KotlinMockitoExtensions.kt diff --git a/game/plugin/bank/build.gradle b/game/plugin/bank/build.gradle index b128b5e0..ba8a32fa 100644 --- a/game/plugin/bank/build.gradle +++ b/game/plugin/bank/build.gradle @@ -1,5 +1,5 @@ -apolloPlugin { - name = "Banking" +plugin { + name = "banking" packageName = "org.apollo.game.plugin.banking" authors = [ "Major", diff --git a/game/plugin/build.gradle b/game/plugin/build.gradle index 7635586b..7cb4bb8d 100644 --- a/game/plugin/build.gradle +++ b/game/plugin/build.gradle @@ -1,17 +1,3 @@ -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' @@ -24,51 +10,3 @@ subprojects { } } } - -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("}") - } - } -} \ No newline at end of file diff --git a/game/plugin/chat/private-messaging/build.gradle b/game/plugin/chat/private-messaging/build.gradle index f1f46407..4bd4ef67 100644 --- a/game/plugin/chat/private-messaging/build.gradle +++ b/game/plugin/chat/private-messaging/build.gradle @@ -1,3 +1,3 @@ -apolloPlugin { - name = "private-messaging" +plugin { + name = "private_messaging" } \ No newline at end of file diff --git a/game/plugin/cmd/build.gradle b/game/plugin/cmd/build.gradle index ecb98912..d7520c63 100644 --- a/game/plugin/cmd/build.gradle +++ b/game/plugin/cmd/build.gradle @@ -1,5 +1,5 @@ -apolloPlugin { - name = "Chat commands" +plugin { + name = "chat_commands" packageName = "org.apollo.game.plugin.cmd" authors = [ "Graham", diff --git a/game/plugin/consumables/build.gradle b/game/plugin/consumables/build.gradle index 84c3ff79..97834d7f 100644 --- a/game/plugin/consumables/build.gradle +++ b/game/plugin/consumables/build.gradle @@ -1,4 +1,4 @@ -apolloPlugin { +plugin { name = "consumables" packageName = "org.apollo.game.plugin.consumables" authors = [ diff --git a/game/plugin/consumables/test/FoodOrDrinkTests.kt b/game/plugin/consumables/test/FoodOrDrinkTests.kt index 1394e64b..45457925 100644 --- a/game/plugin/consumables/test/FoodOrDrinkTests.kt +++ b/game/plugin/consumables/test/FoodOrDrinkTests.kt @@ -4,7 +4,6 @@ import org.apollo.game.message.impl.ItemOptionMessage import org.apollo.game.model.entity.Skill import org.apollo.game.plugin.testing.KotlinPluginTest import org.apollo.game.plugin.testing.mockito.KotlinMockitoExtensions.matches -import org.assertj.core.api.Assertions.assertThat import org.junit.Before import org.junit.Test import org.mockito.Mockito.never diff --git a/game/plugin/dummy/build.gradle b/game/plugin/dummy/build.gradle index c76482a9..23142dca 100644 --- a/game/plugin/dummy/build.gradle +++ b/game/plugin/dummy/build.gradle @@ -1,5 +1,5 @@ -apolloPlugin { - name = "training-dummy" +plugin { + name = "training_dummy" packageName = "org.apollo.game.plugin.entity" authors = [ "Gary Tierney", diff --git a/game/plugin/emote-tab/build.gradle b/game/plugin/emote-tab/build.gradle index 64d546aa..d54c23e5 100644 --- a/game/plugin/emote-tab/build.gradle +++ b/game/plugin/emote-tab/build.gradle @@ -1,5 +1,5 @@ -apolloPlugin { - name = "emote-tab" +plugin { + name = "emote_tab" packageName = "org.apollo.game.plugin.widget" authors = [ "Gary Tierney", diff --git a/game/plugin/entity/following/build.gradle b/game/plugin/entity/following/build.gradle index cca1aa0a..da73a832 100644 --- a/game/plugin/entity/following/build.gradle +++ b/game/plugin/entity/following/build.gradle @@ -1,12 +1,12 @@ -apolloPlugin { +plugin { name = "following" packageName = "org.apollo.game.plugin.entity" authors = [ "Gary Tierney", ] dependencies = [ - "walkto", - "command_utilities", - "player_action", + "entity:walk-to", + "util:command", + "entity:player-action", ] } \ No newline at end of file diff --git a/game/plugin/entity/player-action/build.gradle b/game/plugin/entity/player-action/build.gradle index c85b336d..264d895f 100644 --- a/game/plugin/entity/player-action/build.gradle +++ b/game/plugin/entity/player-action/build.gradle @@ -1,4 +1,4 @@ -apolloPlugin { +plugin { name = "player_action" packageName = "org.apollo.game.plugin.entity" authors = [ diff --git a/game/plugin/entity/spawn/build.gradle b/game/plugin/entity/spawn/build.gradle index 48d810a7..e417db46 100644 --- a/game/plugin/entity/spawn/build.gradle +++ b/game/plugin/entity/spawn/build.gradle @@ -1,10 +1,10 @@ -apolloPlugin { +plugin { name = "spawning" packageName = "org.apollo.game.plugin.entity" authors = [ "Gary Tierney", ] dependencies = [ - "entity_lookup", + "util:lookup", ] } \ No newline at end of file diff --git a/game/plugin/entity/walk-to/build.gradle b/game/plugin/entity/walk-to/build.gradle index 7102d620..4f14b86f 100644 --- a/game/plugin/entity/walk-to/build.gradle +++ b/game/plugin/entity/walk-to/build.gradle @@ -1,4 +1,4 @@ -apolloPlugin { +plugin { name = "walkto" packageName = "org.apollo.plugin.entity.walkto" authors = [ diff --git a/game/plugin/locations/al-kharid/build.gradle b/game/plugin/locations/al-kharid/build.gradle index 64a4c527..8eb8ee02 100644 --- a/game/plugin/locations/al-kharid/build.gradle +++ b/game/plugin/locations/al-kharid/build.gradle @@ -1,10 +1,10 @@ -apolloPlugin { - name = "al-kharid npc spawns" +plugin { + name = "al_kharid_npc_spawns" packageName = "org.apollo.game.plugin.locations" authors = [ "Jesse W", ] dependencies = [ - "spawning", + "entity:spawn", ] } \ No newline at end of file diff --git a/game/plugin/locations/al-kharid/meta.toml b/game/plugin/locations/al-kharid/meta.toml index 4e0d3dc6..8c183592 100644 --- a/game/plugin/locations/al-kharid/meta.toml +++ b/game/plugin/locations/al-kharid/meta.toml @@ -1,7 +1,7 @@ name = "al-kharid npc spawns" package = "org.apollo.game.plugin.locations" authors = [ "Jesse W" ] -dependencies = [ "spawning" ] +dependencies = [ "entity:spawn" ] [config] srcDir = "src/" diff --git a/game/plugin/locations/edgeville/build.gradle b/game/plugin/locations/edgeville/build.gradle index e7262e2f..663066a8 100644 --- a/game/plugin/locations/edgeville/build.gradle +++ b/game/plugin/locations/edgeville/build.gradle @@ -1,10 +1,10 @@ -apolloPlugin { - name = "edgeville npc spawns" +plugin { + name = "edgeville_npc_spawns" packageName = "org.apollo.game.plugin.locations" authors = [ "Jesse W", ] dependencies = [ - "spawning", + "entity:spawn", ] } \ No newline at end of file diff --git a/game/plugin/locations/edgeville/meta.toml b/game/plugin/locations/edgeville/meta.toml index 01a8dc33..469f4071 100644 --- a/game/plugin/locations/edgeville/meta.toml +++ b/game/plugin/locations/edgeville/meta.toml @@ -1,7 +1,7 @@ name = "edgeville npc spawns" package = "org.apollo.game.plugin.locations" authors = [ "Jesse W" ] -dependencies = [ "spawning" ] +dependencies = [ "entity:spawn" ] [config] srcDir = "src/" diff --git a/game/plugin/locations/falador/build.gradle b/game/plugin/locations/falador/build.gradle index 47f2171e..ffff3f04 100644 --- a/game/plugin/locations/falador/build.gradle +++ b/game/plugin/locations/falador/build.gradle @@ -1,10 +1,10 @@ -apolloPlugin { - name = "falador npc spawns" +plugin { + name = "falador_npc_spawns" packageName = "org.apollo.game.plugin.locations" authors = [ "Jesse W", ] dependencies = [ - "spawning", + "entity:spawn", ] } \ No newline at end of file diff --git a/game/plugin/locations/falador/meta.toml b/game/plugin/locations/falador/meta.toml index 6ba11a57..49c9aa26 100644 --- a/game/plugin/locations/falador/meta.toml +++ b/game/plugin/locations/falador/meta.toml @@ -1,7 +1,7 @@ name = "falador npc spawns" package = "org.apollo.game.plugin.locations" authors = [ "Jesse W" ] -dependencies = [ "spawning" ] +dependencies = [ "entity:spawn" ] [config] srcDir = "src/" diff --git a/game/plugin/locations/lumbridge/build.gradle b/game/plugin/locations/lumbridge/build.gradle index 6a47562c..a85c254a 100644 --- a/game/plugin/locations/lumbridge/build.gradle +++ b/game/plugin/locations/lumbridge/build.gradle @@ -1,10 +1,10 @@ -apolloPlugin { - name = "lumbridge npc spawns" +plugin { + name = "lumbridge_npc_spawns" packageName = "org.apollo.game.plugin.locations" authors = [ "Gary Tierney", ] dependencies = [ - "spawning", + "entity:spawn", ] } \ No newline at end of file diff --git a/game/plugin/locations/lumbridge/meta.toml b/game/plugin/locations/lumbridge/meta.toml index 17ab1025..098197b3 100644 --- a/game/plugin/locations/lumbridge/meta.toml +++ b/game/plugin/locations/lumbridge/meta.toml @@ -1,7 +1,7 @@ name = "lumbridge npc spawns" package = "org.apollo.game.plugin.locations" authors = [ "Gary Tierney" ] -dependencies = [ "spawning" ] +dependencies = [ "entity:spawn" ] [config] srcDir = "src/" diff --git a/game/plugin/locations/tutorial-island/build.gradle b/game/plugin/locations/tutorial-island/build.gradle index 0b184b50..44c5e1a5 100644 --- a/game/plugin/locations/tutorial-island/build.gradle +++ b/game/plugin/locations/tutorial-island/build.gradle @@ -1,10 +1,10 @@ -apolloPlugin { - name = "tutorial island npc spawns" +plugin { + name = "tutorial_island_npc_spawns" packageName = "org.apollo.game.plugin.locations" authors = [ "Jesse W", ] dependencies = [ - "spawning", + "entity:spawn", ] } \ No newline at end of file diff --git a/game/plugin/locations/tutorial-island/meta.toml b/game/plugin/locations/tutorial-island/meta.toml index 837b3c9a..eff5223f 100644 --- a/game/plugin/locations/tutorial-island/meta.toml +++ b/game/plugin/locations/tutorial-island/meta.toml @@ -1,7 +1,7 @@ name = "tutorial island npc spawns" package = "org.apollo.game.plugin.locations" authors = [ "Jesse W" ] -dependencies = [ "spawning" ] +dependencies = [ "entity:spawn" ] [config] srcDir = "src/" diff --git a/game/plugin/locations/varrock/build.gradle b/game/plugin/locations/varrock/build.gradle index 02061ca6..54a1418c 100644 --- a/game/plugin/locations/varrock/build.gradle +++ b/game/plugin/locations/varrock/build.gradle @@ -1,10 +1,10 @@ -apolloPlugin { - name = "varrock npc spawns" +plugin { + name = "varrock_npc_spawns" packageName = "org.apollo.game.plugin.locations" authors = [ "Jesse W", ] dependencies = [ - "spawning", + "entity:spawn", ] } \ No newline at end of file diff --git a/game/plugin/locations/varrock/meta.toml b/game/plugin/locations/varrock/meta.toml index d56f16d5..1a8b3d57 100644 --- a/game/plugin/locations/varrock/meta.toml +++ b/game/plugin/locations/varrock/meta.toml @@ -1,7 +1,7 @@ name = "varrock npc spawns" package = "org.apollo.game.plugin.locations" authors = [ "Jesse W" ] -dependencies = [ "spawning" ] +dependencies = [ "entity:spawn" ] [config] srcDir = "src/" diff --git a/game/plugin/logout/build.gradle b/game/plugin/logout/build.gradle index 341b83a7..ae0395e6 100644 --- a/game/plugin/logout/build.gradle +++ b/game/plugin/logout/build.gradle @@ -1,3 +1,3 @@ -apolloPlugin { +plugin { name = "logout" } \ No newline at end of file diff --git a/game/plugin/run/build.gradle b/game/plugin/run/build.gradle index cb2a3408..1e335cc4 100644 --- a/game/plugin/run/build.gradle +++ b/game/plugin/run/build.gradle @@ -1,3 +1,3 @@ -apolloPlugin { +plugin { name = "run" } \ No newline at end of file diff --git a/game/plugin/util/command/build.gradle b/game/plugin/util/command/build.gradle index df15b2d0..58e59401 100644 --- a/game/plugin/util/command/build.gradle +++ b/game/plugin/util/command/build.gradle @@ -1,4 +1,4 @@ -apolloPlugin { - name = "command utilities" +plugin { + name = "command_utilities" packageName = "org.apollo.game.plugins.util" } \ No newline at end of file diff --git a/game/plugin/util/lookup/build.gradle b/game/plugin/util/lookup/build.gradle index 61396524..e910e2fa 100644 --- a/game/plugin/util/lookup/build.gradle +++ b/game/plugin/util/lookup/build.gradle @@ -1,4 +1,4 @@ -apolloPlugin { - name = "entity lookup" +plugin { + name = "entity_lookup" packageName = "org.apollo.game.plugins.util" } \ No newline at end of file