mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-06 16:51:37 +00:00
Fix incremental script compilation
This commit is contained in:
@@ -2,6 +2,7 @@ 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.Task
|
||||||
import org.gradle.api.file.FileTree
|
import org.gradle.api.file.FileTree
|
||||||
import org.gradle.api.tasks.testing.Test
|
import org.gradle.api.tasks.testing.Test
|
||||||
|
|
||||||
@@ -50,6 +51,21 @@ class ApolloPluginExtension {
|
|||||||
init()
|
init()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private def addDependencyOn(Project other, String configuration, boolean includeProject) {
|
||||||
|
def compileConfiguration = other.configurations.getByName("compile")
|
||||||
|
def sources = other.sourceSets.main
|
||||||
|
def deps = compileConfiguration.dependencies
|
||||||
|
|
||||||
|
deps.each {
|
||||||
|
project.dependencies.add(configuration, it)
|
||||||
|
}
|
||||||
|
|
||||||
|
project.dependencies.add(configuration, sources.output)
|
||||||
|
if (includeProject) {
|
||||||
|
project.dependencies.add(configuration, other)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup the {@link Project} with the correct dependencies and tasks required to build the plugin
|
* Setup the {@link Project} with the correct dependencies and tasks required to build the plugin
|
||||||
* and its scripts.
|
* and its scripts.
|
||||||
@@ -75,36 +91,29 @@ class ApolloPluginExtension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def mainSources = project.sourceSets.main
|
def mainSources = project.sourceSets.main
|
||||||
def gameCompileConfiguration = gameProject.configurations.getByName("compile")
|
|
||||||
def gameSources = gameProject.sourceSets.main
|
|
||||||
def gameDependencies = gameCompileConfiguration.dependencies
|
|
||||||
|
|
||||||
gameDependencies.each {
|
addDependencyOn(gameProject, "compile", false)
|
||||||
project.dependencies.add('compile', it)
|
addDependencyOn(pluginTestingProject, "testCompile", true)
|
||||||
|
|
||||||
|
def buildTask = project.tasks['classes']
|
||||||
|
|
||||||
|
FileTree scripts = project.fileTree(srcDir).matching {
|
||||||
|
include '*.kts'
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
project.tasks.create('compileScripts', ApolloScriptCompileTask) {
|
||||||
FileTree filtered = project.fileTree(srcDir).matching {
|
def outputDir = new File("${project.buildDir}/classes/main")
|
||||||
include '*.kts'
|
|
||||||
}
|
|
||||||
|
|
||||||
inputs.files filtered.files
|
inputs.files scripts.files
|
||||||
outputsDir = new File("${project.buildDir}/classes/main")
|
outputsDir = outputDir
|
||||||
|
|
||||||
compileClasspath = mainSources.compileClasspath +
|
|
||||||
mainSources.runtimeClasspath
|
|
||||||
|
|
||||||
|
compileClasspath = mainSources.compileClasspath + mainSources.runtimeClasspath + mainSources.output
|
||||||
scriptDefinitionClass = "org.apollo.game.plugin.kotlin.KotlinPluginScript"
|
scriptDefinitionClass = "org.apollo.game.plugin.kotlin.KotlinPluginScript"
|
||||||
mustRunAfter kotlinCompileTask
|
|
||||||
|
mustRunAfter buildTask
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlinCompileTask.finalizedBy project.tasks['compileScripts']
|
buildTask.finalizedBy(project.tasks['compileScripts'])
|
||||||
}
|
}
|
||||||
|
|
||||||
def getDependencies() {
|
def getDependencies() {
|
||||||
|
|||||||
+2
-1
@@ -4,13 +4,14 @@ import org.apollo.build.plugin.compiler.KotlinScriptCompiler
|
|||||||
import org.gradle.api.DefaultTask
|
import org.gradle.api.DefaultTask
|
||||||
import org.gradle.api.file.FileCollection
|
import org.gradle.api.file.FileCollection
|
||||||
import org.gradle.api.tasks.Input
|
import org.gradle.api.tasks.Input
|
||||||
|
import org.gradle.api.tasks.OutputDirectory
|
||||||
import org.gradle.api.tasks.TaskAction
|
import org.gradle.api.tasks.TaskAction
|
||||||
import org.gradle.api.tasks.incremental.IncrementalTaskInputs
|
import org.gradle.api.tasks.incremental.IncrementalTaskInputs
|
||||||
import org.jetbrains.kotlin.cli.common.messages.MessageRenderer
|
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
|
@OutputDirectory
|
||||||
File outputsDir
|
File outputsDir
|
||||||
|
|
||||||
@Input
|
@Input
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
apply plugin: 'kotlin'
|
apply plugin: 'kotlin'
|
||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
def gameProject = project(':game')
|
compileOnly project(':game')
|
||||||
|
|
||||||
compile gameProject.sourceSets.main.output
|
|
||||||
compile group: 'org.assertj', name: 'assertj-core', version: '3.8.0'
|
compile group: 'org.assertj', name: 'assertj-core', version: '3.8.0'
|
||||||
|
|
||||||
def gameTestConfiguration = gameProject.configurations.testCompileOnly
|
def gameTestConfiguration = project(':game').configurations.testCompile
|
||||||
def gameTestDependencies = gameTestConfiguration.dependencies
|
def gameTestDependencies = gameTestConfiguration.dependencies
|
||||||
|
|
||||||
gameTestDependencies.each {
|
gameTestDependencies.each {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ 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
|
||||||
|
|||||||
Reference in New Issue
Block a user