fix access to internal from tests for android projects which compiled via gradle

This commit is contained in:
Michael Nedzelsky
2015-11-18 19:56:48 +03:00
parent 084727c991
commit e92ac6cba3
@@ -135,20 +135,27 @@ public open class KotlinCompile() : AbstractKotlinCompile<K2JVMCompilerArguments
args.noParamAssertions = kotlinOptions.noParamAssertions
args.moduleName = kotlinOptions.moduleName ?: extraProperties.getOrNull<String>("defaultModuleName")
if (this.name == "compileTestKotlin") {
getLogger().kotlinDebug("try to determine the output directory of corresponding compileKotlin task")
val tasks = project.getTasksByName("compileKotlin", false)
getLogger().kotlinDebug("tasks for compileKotlin: ${tasks}")
fun addFriendPathForTestTask(taskName: String) {
logger.kotlinDebug("try to determine the output directory of corresponding $taskName task")
val tasks = project.getTasksByName("$taskName", false)
logger.kotlinDebug("tasks for $taskName: ${tasks}")
if (tasks.size == 1) {
val task = tasks.firstOrNull() as? KotlinCompile
if (task != null) {
getLogger().kotlinDebug("destinantion directory for production = ${task.destinationDir}")
logger.kotlinDebug("destinantion directory for production = ${task.destinationDir}")
args.friendPaths = arrayOf(task.destinationDir.absolutePath)
args.moduleName = task.kotlinOptions.moduleName ?: task.extensions.extraProperties.getOrNull<String>("defaultModuleName")
}
}
}
if (this.name == "compileTestKotlin") {
addFriendPathForTestTask("compileKotlin")
}
if (this.name == "compileDebugUnitTestKotlin") {
addFriendPathForTestTask("compileDebugKotlin")
}
getLogger().kotlinDebug("args.moduleName = ${args.moduleName}")
}