Update Gradle plugin
This commit is contained in:
+1
-32
@@ -30,6 +30,7 @@ import com.intellij.ide.highlighter.JavaFileType
|
||||
import org.jetbrains.kotlin.idea.JetFileType
|
||||
import org.jetbrains.kotlin.utils.LibraryUtils
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import org.apache.commons.io.FilenameUtils
|
||||
|
||||
val DEFAULT_ANNOTATIONS = "org.jebrains.kotlin.gradle.defaultAnnotations"
|
||||
|
||||
@@ -49,38 +50,6 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractCo
|
||||
var compilerPluginClasspaths: Array<String> = array()
|
||||
var compilerPluginArguments: Array<String> = array()
|
||||
|
||||
// override setSource to track source directory sets
|
||||
override fun setSource(source: Any?) {
|
||||
srcDirsSources.clear()
|
||||
if (source is SourceDirectorySet) {
|
||||
srcDirsSources.add(source)
|
||||
}
|
||||
super.setSource(source)
|
||||
}
|
||||
|
||||
// override source to track source directory sets
|
||||
override fun source(vararg sources: Any?): SourceTask? {
|
||||
for (source in sources) {
|
||||
if (source is SourceDirectorySet) {
|
||||
srcDirsSources.add(source)
|
||||
}
|
||||
}
|
||||
return super.source(sources)
|
||||
}
|
||||
|
||||
fun findSrcDirRoot(file: File): File? {
|
||||
val absPath = file.getAbsolutePath()
|
||||
for (source in srcDirsSources) {
|
||||
for (root in source.getSrcDirs()) {
|
||||
val rootAbsPath = root.getAbsolutePath()
|
||||
if (FilenameUtils.directoryContains(rootAbsPath, absPath)) {
|
||||
return root
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
[TaskAction]
|
||||
override fun compile() {
|
||||
getLogger().debug("Starting ${javaClass} task")
|
||||
|
||||
+10
-6
@@ -37,10 +37,7 @@ import kotlin.properties.Delegates
|
||||
import org.gradle.api.tasks.Delete
|
||||
import groovy.lang.Closure
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinTasksProvider
|
||||
import org.jetbrains.kotlin.compiler.plugin.CliOption
|
||||
import org.jetbrains.kotlin.android.AndroidCommandLineProcessor
|
||||
import java.util.ServiceLoader
|
||||
import org.jetbrains.kotlin.compiler.plugin.getPluginOptionString
|
||||
|
||||
val DEFAULT_ANNOTATIONS = "org.jebrains.kotlin.gradle.defaultAnnotations"
|
||||
|
||||
@@ -454,7 +451,12 @@ private class SubpluginEnvironment(
|
||||
val subplugins: List<KotlinGradleSubplugin>
|
||||
) {
|
||||
|
||||
fun addSubpluginArguments(project: Project, compileTask: KotlinCompile) {
|
||||
private fun AbstractCompile.setKotlinTaskProperty(methodName: String, value: Array<String>) {
|
||||
val function = javaClass.getMethod(methodName, javaClass<Array<String>>())
|
||||
function.invoke(this, value)
|
||||
}
|
||||
|
||||
fun addSubpluginArguments(project: Project, compileTask: AbstractCompile) {
|
||||
val realPluginClasspaths = arrayListOf<String>()
|
||||
val pluginArguments = arrayListOf<String>()
|
||||
|
||||
@@ -463,14 +465,16 @@ private class SubpluginEnvironment(
|
||||
if (args != null) {
|
||||
realPluginClasspaths.addAll(subpluginClasspaths[subplugin])
|
||||
for (arg in args) {
|
||||
//TODO: fix (getPluginOptionString is in plugin-api)
|
||||
fun getPluginOptionString(pluginId: String, key: String, value: String) = "plugin:$pluginId:$key=$value"
|
||||
val option = getPluginOptionString(subplugin.getPluginName(), arg.key, arg.value)
|
||||
pluginArguments.add(option)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
compileTask.compilerPluginClasspaths = realPluginClasspaths.copyToArray()
|
||||
compileTask.compilerPluginArguments = pluginArguments.copyToArray()
|
||||
compileTask.setKotlinTaskProperty("setCompilerPluginClasspaths", realPluginClasspaths.copyToArray())
|
||||
compileTask.setKotlinTaskProperty("setCompilerPluginArguments", pluginArguments.copyToArray())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user