Fix OptionalExpectation in Gradle plugin (#2259)
This commit is contained in:
+6
@@ -40,6 +40,12 @@ interface KotlinNativeBinary : ComponentWithDependencies, BuildableComponent, Co
|
||||
/** Returns the source files of this binary. */
|
||||
val sources: FileCollection
|
||||
|
||||
/**
|
||||
* Returns common sources used to build this binary
|
||||
* (both common for all native targets and avalable via expectedBy relation).
|
||||
*/
|
||||
val commonSources: FileCollection
|
||||
|
||||
/**
|
||||
* Konan target the library is built for
|
||||
*/
|
||||
|
||||
+3
@@ -94,6 +94,9 @@ abstract class AbstractKotlinNativeBinary(
|
||||
override val sources: FileCollection
|
||||
get() = sourceSet.getAllSources(konanTarget)
|
||||
|
||||
override val commonSources: FileCollection
|
||||
get() = sourceSet.getCommonMultiplatformSources() + sourceSet.getCommonNativeSources()
|
||||
|
||||
private val dependencies = objects.newInstance<DefaultComponentDependencies>(
|
||||
DefaultComponentDependencies::class.java,
|
||||
name + "Implementation"
|
||||
|
||||
+5
@@ -60,6 +60,11 @@ open class KotlinNativeTestExecutableImpl @Inject constructor(
|
||||
override val sources: FileCollection
|
||||
get() = super.sources + mainSources.getAllSources(konanTarget)
|
||||
|
||||
override val commonSources: FileCollection
|
||||
get() = super.commonSources +
|
||||
mainSources.getCommonNativeSources() +
|
||||
mainSources.getCommonMultiplatformSources()
|
||||
|
||||
override val outputRootName: String = "test-exe"
|
||||
|
||||
override val additionalCompilerOptions: Collection<String>
|
||||
|
||||
+1
-3
@@ -49,9 +49,7 @@ open class KotlinNativeCompile @Inject constructor(internal val binary: Abstract
|
||||
override fun getSource(): FileTree = sources.asFileTree
|
||||
|
||||
private val commonSources: FileCollection
|
||||
get() = with(binary.sourceSet) {
|
||||
getCommonMultiplatformSources() + getCommonNativeSources()
|
||||
}
|
||||
get() = binary.commonSources
|
||||
|
||||
val libraries: Configuration
|
||||
@InputFiles get() = binary.klibs
|
||||
|
||||
@@ -1036,4 +1036,40 @@ class ExperimentalPluginTests {
|
||||
"Project property 'konan.home' is deprecated. Use 'org.jetbrains.kotlin.native.home' instead."
|
||||
))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Plugin should support OptionalExpectation`() {
|
||||
val project = KonanProject.createEmpty(projectDirectory).apply {
|
||||
buildFile.writeText("""
|
||||
plugins {
|
||||
id 'kotlin-native'
|
||||
}
|
||||
|
||||
components.main.targets = ['host']
|
||||
components.test.targets = ['host']
|
||||
""".trimIndent())
|
||||
generateSrcFile("main.kt", """
|
||||
import kotlin.jvm.*
|
||||
|
||||
class A {
|
||||
@JvmField
|
||||
val a = "A.a"
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
println(A().a)
|
||||
}
|
||||
""".trimIndent())
|
||||
generateSrcFile(listOf("src", "test", "kotlin"), "test.kt", """
|
||||
import kotlin.test.*
|
||||
|
||||
@Test
|
||||
fun test() {
|
||||
foo()
|
||||
}
|
||||
""".trimIndent())
|
||||
}
|
||||
val result = project.createRunner().withArguments("build").build()
|
||||
assertTrue(result.output.contains("A.a"))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user