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. */
|
/** Returns the source files of this binary. */
|
||||||
val sources: FileCollection
|
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
|
* Konan target the library is built for
|
||||||
*/
|
*/
|
||||||
|
|||||||
+3
@@ -94,6 +94,9 @@ abstract class AbstractKotlinNativeBinary(
|
|||||||
override val sources: FileCollection
|
override val sources: FileCollection
|
||||||
get() = sourceSet.getAllSources(konanTarget)
|
get() = sourceSet.getAllSources(konanTarget)
|
||||||
|
|
||||||
|
override val commonSources: FileCollection
|
||||||
|
get() = sourceSet.getCommonMultiplatformSources() + sourceSet.getCommonNativeSources()
|
||||||
|
|
||||||
private val dependencies = objects.newInstance<DefaultComponentDependencies>(
|
private val dependencies = objects.newInstance<DefaultComponentDependencies>(
|
||||||
DefaultComponentDependencies::class.java,
|
DefaultComponentDependencies::class.java,
|
||||||
name + "Implementation"
|
name + "Implementation"
|
||||||
|
|||||||
+5
@@ -60,6 +60,11 @@ open class KotlinNativeTestExecutableImpl @Inject constructor(
|
|||||||
override val sources: FileCollection
|
override val sources: FileCollection
|
||||||
get() = super.sources + mainSources.getAllSources(konanTarget)
|
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 outputRootName: String = "test-exe"
|
||||||
|
|
||||||
override val additionalCompilerOptions: Collection<String>
|
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
|
override fun getSource(): FileTree = sources.asFileTree
|
||||||
|
|
||||||
private val commonSources: FileCollection
|
private val commonSources: FileCollection
|
||||||
get() = with(binary.sourceSet) {
|
get() = binary.commonSources
|
||||||
getCommonMultiplatformSources() + getCommonNativeSources()
|
|
||||||
}
|
|
||||||
|
|
||||||
val libraries: Configuration
|
val libraries: Configuration
|
||||||
@InputFiles get() = binary.klibs
|
@InputFiles get() = binary.klibs
|
||||||
|
|||||||
@@ -1036,4 +1036,40 @@ class ExperimentalPluginTests {
|
|||||||
"Project property 'konan.home' is deprecated. Use 'org.jetbrains.kotlin.native.home' instead."
|
"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