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.noParamAssertions = kotlinOptions.noParamAssertions
args.moduleName = kotlinOptions.moduleName ?: extraProperties.getOrNull<String>("defaultModuleName") args.moduleName = kotlinOptions.moduleName ?: extraProperties.getOrNull<String>("defaultModuleName")
if (this.name == "compileTestKotlin") { fun addFriendPathForTestTask(taskName: String) {
getLogger().kotlinDebug("try to determine the output directory of corresponding compileKotlin task") logger.kotlinDebug("try to determine the output directory of corresponding $taskName task")
val tasks = project.getTasksByName("compileKotlin", false) val tasks = project.getTasksByName("$taskName", false)
getLogger().kotlinDebug("tasks for compileKotlin: ${tasks}") logger.kotlinDebug("tasks for $taskName: ${tasks}")
if (tasks.size == 1) { if (tasks.size == 1) {
val task = tasks.firstOrNull() as? KotlinCompile val task = tasks.firstOrNull() as? KotlinCompile
if (task != null) { 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.friendPaths = arrayOf(task.destinationDir.absolutePath)
args.moduleName = task.kotlinOptions.moduleName ?: task.extensions.extraProperties.getOrNull<String>("defaultModuleName") 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}") getLogger().kotlinDebug("args.moduleName = ${args.moduleName}")
} }