Fix plugin test running with new gradle modules

This commit is contained in:
Gary Tierney
2017-09-16 20:40:17 +01:00
parent 36282cf81e
commit edcb72b474
39 changed files with 97 additions and 129 deletions
+1
View File
@@ -14,3 +14,4 @@
/lib/
*/target/
*/build/
**/build/
@@ -7,6 +7,6 @@ class ApolloPlugin implements Plugin<Project> {
@Override
void apply(Project project) {
project.extensions.create('apolloPlugin', ApolloPluginExtension, project)
project.extensions.create('plugin', ApolloPluginExtension, project)
}
}
@@ -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<String> dependencies) {
dependencies.each {
project.dependencies.add('compile', project.findProject(":game:plugin:$it"))
}
this.dependencies = dependencies
}
}
@@ -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()
}
}
-1
View File
@@ -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
}
+11 -1
View File
@@ -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
}
}
+2 -2
View File
@@ -1,5 +1,5 @@
apolloPlugin {
name = "Banking"
plugin {
name = "banking"
packageName = "org.apollo.game.plugin.banking"
authors = [
"Major",
-62
View File
@@ -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("}")
}
}
}
@@ -1,3 +1,3 @@
apolloPlugin {
name = "private-messaging"
plugin {
name = "private_messaging"
}
+2 -2
View File
@@ -1,5 +1,5 @@
apolloPlugin {
name = "Chat commands"
plugin {
name = "chat_commands"
packageName = "org.apollo.game.plugin.cmd"
authors = [
"Graham",
+1 -1
View File
@@ -1,4 +1,4 @@
apolloPlugin {
plugin {
name = "consumables"
packageName = "org.apollo.game.plugin.consumables"
authors = [
@@ -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
+2 -2
View File
@@ -1,5 +1,5 @@
apolloPlugin {
name = "training-dummy"
plugin {
name = "training_dummy"
packageName = "org.apollo.game.plugin.entity"
authors = [
"Gary Tierney",
+2 -2
View File
@@ -1,5 +1,5 @@
apolloPlugin {
name = "emote-tab"
plugin {
name = "emote_tab"
packageName = "org.apollo.game.plugin.widget"
authors = [
"Gary Tierney",
+4 -4
View File
@@ -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",
]
}
@@ -1,4 +1,4 @@
apolloPlugin {
plugin {
name = "player_action"
packageName = "org.apollo.game.plugin.entity"
authors = [
+2 -2
View File
@@ -1,10 +1,10 @@
apolloPlugin {
plugin {
name = "spawning"
packageName = "org.apollo.game.plugin.entity"
authors = [
"Gary Tierney",
]
dependencies = [
"entity_lookup",
"util:lookup",
]
}
+1 -1
View File
@@ -1,4 +1,4 @@
apolloPlugin {
plugin {
name = "walkto"
packageName = "org.apollo.plugin.entity.walkto"
authors = [
+3 -3
View File
@@ -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",
]
}
+1 -1
View File
@@ -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/"
+3 -3
View File
@@ -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",
]
}
+1 -1
View File
@@ -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/"
+3 -3
View File
@@ -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",
]
}
+1 -1
View File
@@ -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/"
+3 -3
View File
@@ -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",
]
}
+1 -1
View File
@@ -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/"
@@ -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",
]
}
@@ -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/"
+3 -3
View File
@@ -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",
]
}
+1 -1
View File
@@ -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/"
+1 -1
View File
@@ -1,3 +1,3 @@
apolloPlugin {
plugin {
name = "logout"
}
+1 -1
View File
@@ -1,3 +1,3 @@
apolloPlugin {
plugin {
name = "run"
}
+2 -2
View File
@@ -1,4 +1,4 @@
apolloPlugin {
name = "command utilities"
plugin {
name = "command_utilities"
packageName = "org.apollo.game.plugins.util"
}
+2 -2
View File
@@ -1,4 +1,4 @@
apolloPlugin {
name = "entity lookup"
plugin {
name = "entity_lookup"
packageName = "org.apollo.game.plugins.util"
}