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/ /lib/
*/target/ */target/
*/build/ */build/
**/build/
@@ -7,6 +7,6 @@ class ApolloPlugin implements Plugin<Project> {
@Override @Override
void apply(Project project) { 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.apollo.build.plugin.tasks.ApolloScriptCompileTask
import org.gradle.api.Project import org.gradle.api.Project
import org.gradle.api.file.FileTree import org.gradle.api.file.FileTree
import org.gradle.api.tasks.testing.Test
class ApolloPluginExtension { class ApolloPluginExtension {
private Project project final Project project
/** /**
* The name of this plugin (defaults to the project name). * The name of this plugin (defaults to the project name).
@@ -73,29 +74,49 @@ class ApolloPluginExtension {
} }
} }
project.dependencies.add('compile', gameProject) def mainSources = project.sourceSets.main
project.dependencies.add('testCompile', pluginTestingProject.sourceSets.test.output) def gameCompileConfiguration = gameProject.configurations.getByName("compile")
def gameSources = gameProject.sourceSets.main
def gameDependencies = gameCompileConfiguration.dependencies
dependencies.each { gameDependencies.each {
project.dependencies.add('compile', project.findProject(":game:plugin:$it")) project.dependencies.add('compile', it)
} }
project.tasks.create('compileScripts', ApolloScriptCompileTask) { project.dependencies.add('compile', gameSources.output)
def mainSources = project.sourceSets.main project.dependencies.add('testCompile', pluginTestingProject)
def outputDir = mainSources.output.classesDir project.dependencies.add('testCompile', project.sourceSets.main.output)
def kotlinCompileTask = project.tasks['compileKotlin']
project.tasks.create('compileScripts', ApolloScriptCompileTask) {
FileTree filtered = project.fileTree(srcDir).matching { FileTree filtered = project.fileTree(srcDir).matching {
include '*.kts' include '*.kts'
} }
inputs.files filtered.files inputs.files filtered.files
outputsDir = outputDir outputsDir = new File("${project.buildDir}/classes/main")
compileClasspath = mainSources.compileClasspath + compileClasspath = mainSources.compileClasspath +
mainSources.runtimeClasspath mainSources.runtimeClasspath
scriptDefinitionClass = "org.apollo.game.plugin.kotlin.KotlinPluginScript" 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 import org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector
class ApolloScriptCompileTask extends DefaultTask { class ApolloScriptCompileTask extends DefaultTask {
@Input
File outputsDir File outputsDir
@Input @Input
@@ -47,12 +48,11 @@ class ApolloScriptCompileTask extends DefaultTask {
def normalizedPrefix = normalizedFilename.subSequence(0, normalizedFilename.lastIndexOf('.')) def normalizedPrefix = normalizedFilename.subSequence(0, normalizedFilename.lastIndexOf('.'))
FileFilter filter = { FileFilter filter = {
it.name.startsWith(normalizedPrefix) return it.name.startsWith(normalizedPrefix)
} }
def binaries = outputsDir.listFiles FileFilter { dir, name -> name.startsWith(normalizedPrefix) } def binaries = outputsDir.listFiles(filter)
binaries.each {
binaries.forEach {
it.delete() it.delete()
} }
} }
-1
View File
@@ -32,7 +32,6 @@ dependencies {
compile group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core', version: '0.16' compile group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core', version: '0.16'
project(":game:plugin").subprojects.each { plugin -> project(":game:plugin").subprojects.each { plugin ->
println(plugin)
runtime plugin runtime plugin
} }
+11 -1
View File
@@ -2,5 +2,15 @@ apply plugin: 'kotlin'
dependencies { 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 { plugin {
name = "Banking" name = "banking"
packageName = "org.apollo.game.plugin.banking" packageName = "org.apollo.game.plugin.banking"
authors = [ authors = [
"Major", "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 { subprojects {
if (it.buildFile.exists()) { if (it.buildFile.exists()) {
apply plugin: 'apollo-plugin' 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 { plugin {
name = "private-messaging" name = "private_messaging"
} }
+2 -2
View File
@@ -1,5 +1,5 @@
apolloPlugin { plugin {
name = "Chat commands" name = "chat_commands"
packageName = "org.apollo.game.plugin.cmd" packageName = "org.apollo.game.plugin.cmd"
authors = [ authors = [
"Graham", "Graham",
+1 -1
View File
@@ -1,4 +1,4 @@
apolloPlugin { plugin {
name = "consumables" name = "consumables"
packageName = "org.apollo.game.plugin.consumables" packageName = "org.apollo.game.plugin.consumables"
authors = [ authors = [
@@ -4,7 +4,6 @@ import org.apollo.game.message.impl.ItemOptionMessage
import org.apollo.game.model.entity.Skill import org.apollo.game.model.entity.Skill
import org.apollo.game.plugin.testing.KotlinPluginTest import org.apollo.game.plugin.testing.KotlinPluginTest
import org.apollo.game.plugin.testing.mockito.KotlinMockitoExtensions.matches import org.apollo.game.plugin.testing.mockito.KotlinMockitoExtensions.matches
import org.assertj.core.api.Assertions.assertThat
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.mockito.Mockito.never import org.mockito.Mockito.never
+2 -2
View File
@@ -1,5 +1,5 @@
apolloPlugin { plugin {
name = "training-dummy" name = "training_dummy"
packageName = "org.apollo.game.plugin.entity" packageName = "org.apollo.game.plugin.entity"
authors = [ authors = [
"Gary Tierney", "Gary Tierney",
+2 -2
View File
@@ -1,5 +1,5 @@
apolloPlugin { plugin {
name = "emote-tab" name = "emote_tab"
packageName = "org.apollo.game.plugin.widget" packageName = "org.apollo.game.plugin.widget"
authors = [ authors = [
"Gary Tierney", "Gary Tierney",
+4 -4
View File
@@ -1,12 +1,12 @@
apolloPlugin { plugin {
name = "following" name = "following"
packageName = "org.apollo.game.plugin.entity" packageName = "org.apollo.game.plugin.entity"
authors = [ authors = [
"Gary Tierney", "Gary Tierney",
] ]
dependencies = [ dependencies = [
"walkto", "entity:walk-to",
"command_utilities", "util:command",
"player_action", "entity:player-action",
] ]
} }
@@ -1,4 +1,4 @@
apolloPlugin { plugin {
name = "player_action" name = "player_action"
packageName = "org.apollo.game.plugin.entity" packageName = "org.apollo.game.plugin.entity"
authors = [ authors = [
+2 -2
View File
@@ -1,10 +1,10 @@
apolloPlugin { plugin {
name = "spawning" name = "spawning"
packageName = "org.apollo.game.plugin.entity" packageName = "org.apollo.game.plugin.entity"
authors = [ authors = [
"Gary Tierney", "Gary Tierney",
] ]
dependencies = [ dependencies = [
"entity_lookup", "util:lookup",
] ]
} }
+1 -1
View File
@@ -1,4 +1,4 @@
apolloPlugin { plugin {
name = "walkto" name = "walkto"
packageName = "org.apollo.plugin.entity.walkto" packageName = "org.apollo.plugin.entity.walkto"
authors = [ authors = [
+3 -3
View File
@@ -1,10 +1,10 @@
apolloPlugin { plugin {
name = "al-kharid npc spawns" name = "al_kharid_npc_spawns"
packageName = "org.apollo.game.plugin.locations" packageName = "org.apollo.game.plugin.locations"
authors = [ authors = [
"Jesse W", "Jesse W",
] ]
dependencies = [ dependencies = [
"spawning", "entity:spawn",
] ]
} }
+1 -1
View File
@@ -1,7 +1,7 @@
name = "al-kharid npc spawns" name = "al-kharid npc spawns"
package = "org.apollo.game.plugin.locations" package = "org.apollo.game.plugin.locations"
authors = [ "Jesse W" ] authors = [ "Jesse W" ]
dependencies = [ "spawning" ] dependencies = [ "entity:spawn" ]
[config] [config]
srcDir = "src/" srcDir = "src/"
+3 -3
View File
@@ -1,10 +1,10 @@
apolloPlugin { plugin {
name = "edgeville npc spawns" name = "edgeville_npc_spawns"
packageName = "org.apollo.game.plugin.locations" packageName = "org.apollo.game.plugin.locations"
authors = [ authors = [
"Jesse W", "Jesse W",
] ]
dependencies = [ dependencies = [
"spawning", "entity:spawn",
] ]
} }
+1 -1
View File
@@ -1,7 +1,7 @@
name = "edgeville npc spawns" name = "edgeville npc spawns"
package = "org.apollo.game.plugin.locations" package = "org.apollo.game.plugin.locations"
authors = [ "Jesse W" ] authors = [ "Jesse W" ]
dependencies = [ "spawning" ] dependencies = [ "entity:spawn" ]
[config] [config]
srcDir = "src/" srcDir = "src/"
+3 -3
View File
@@ -1,10 +1,10 @@
apolloPlugin { plugin {
name = "falador npc spawns" name = "falador_npc_spawns"
packageName = "org.apollo.game.plugin.locations" packageName = "org.apollo.game.plugin.locations"
authors = [ authors = [
"Jesse W", "Jesse W",
] ]
dependencies = [ dependencies = [
"spawning", "entity:spawn",
] ]
} }
+1 -1
View File
@@ -1,7 +1,7 @@
name = "falador npc spawns" name = "falador npc spawns"
package = "org.apollo.game.plugin.locations" package = "org.apollo.game.plugin.locations"
authors = [ "Jesse W" ] authors = [ "Jesse W" ]
dependencies = [ "spawning" ] dependencies = [ "entity:spawn" ]
[config] [config]
srcDir = "src/" srcDir = "src/"
+3 -3
View File
@@ -1,10 +1,10 @@
apolloPlugin { plugin {
name = "lumbridge npc spawns" name = "lumbridge_npc_spawns"
packageName = "org.apollo.game.plugin.locations" packageName = "org.apollo.game.plugin.locations"
authors = [ authors = [
"Gary Tierney", "Gary Tierney",
] ]
dependencies = [ dependencies = [
"spawning", "entity:spawn",
] ]
} }
+1 -1
View File
@@ -1,7 +1,7 @@
name = "lumbridge npc spawns" name = "lumbridge npc spawns"
package = "org.apollo.game.plugin.locations" package = "org.apollo.game.plugin.locations"
authors = [ "Gary Tierney" ] authors = [ "Gary Tierney" ]
dependencies = [ "spawning" ] dependencies = [ "entity:spawn" ]
[config] [config]
srcDir = "src/" srcDir = "src/"
@@ -1,10 +1,10 @@
apolloPlugin { plugin {
name = "tutorial island npc spawns" name = "tutorial_island_npc_spawns"
packageName = "org.apollo.game.plugin.locations" packageName = "org.apollo.game.plugin.locations"
authors = [ authors = [
"Jesse W", "Jesse W",
] ]
dependencies = [ dependencies = [
"spawning", "entity:spawn",
] ]
} }
@@ -1,7 +1,7 @@
name = "tutorial island npc spawns" name = "tutorial island npc spawns"
package = "org.apollo.game.plugin.locations" package = "org.apollo.game.plugin.locations"
authors = [ "Jesse W" ] authors = [ "Jesse W" ]
dependencies = [ "spawning" ] dependencies = [ "entity:spawn" ]
[config] [config]
srcDir = "src/" srcDir = "src/"
+3 -3
View File
@@ -1,10 +1,10 @@
apolloPlugin { plugin {
name = "varrock npc spawns" name = "varrock_npc_spawns"
packageName = "org.apollo.game.plugin.locations" packageName = "org.apollo.game.plugin.locations"
authors = [ authors = [
"Jesse W", "Jesse W",
] ]
dependencies = [ dependencies = [
"spawning", "entity:spawn",
] ]
} }
+1 -1
View File
@@ -1,7 +1,7 @@
name = "varrock npc spawns" name = "varrock npc spawns"
package = "org.apollo.game.plugin.locations" package = "org.apollo.game.plugin.locations"
authors = [ "Jesse W" ] authors = [ "Jesse W" ]
dependencies = [ "spawning" ] dependencies = [ "entity:spawn" ]
[config] [config]
srcDir = "src/" srcDir = "src/"
+1 -1
View File
@@ -1,3 +1,3 @@
apolloPlugin { plugin {
name = "logout" name = "logout"
} }
+1 -1
View File
@@ -1,3 +1,3 @@
apolloPlugin { plugin {
name = "run" name = "run"
} }
+2 -2
View File
@@ -1,4 +1,4 @@
apolloPlugin { plugin {
name = "command utilities" name = "command_utilities"
packageName = "org.apollo.game.plugins.util" packageName = "org.apollo.game.plugins.util"
} }
+2 -2
View File
@@ -1,4 +1,4 @@
apolloPlugin { plugin {
name = "entity lookup" name = "entity_lookup"
packageName = "org.apollo.game.plugins.util" packageName = "org.apollo.game.plugins.util"
} }