Added configuring <SingleNativeTarget> for subprojects nativeProject form testDsl
#KT-51553 In Progress
This commit is contained in:
committed by
Space Team
parent
b98dbf7b56
commit
04dce8a3f0
+19
-2
@@ -108,6 +108,7 @@ fun KGPBaseTest.nativeProject(
|
|||||||
buildJdk: File? = null,
|
buildJdk: File? = null,
|
||||||
localRepoDir: Path? = null,
|
localRepoDir: Path? = null,
|
||||||
environmentVariables: EnvironmentalVariables = EnvironmentalVariables(),
|
environmentVariables: EnvironmentalVariables = EnvironmentalVariables(),
|
||||||
|
configureSubProjects: Boolean = false,
|
||||||
test: TestProject.() -> Unit = {},
|
test: TestProject.() -> Unit = {},
|
||||||
): TestProject {
|
): TestProject {
|
||||||
val project = project(
|
val project = project(
|
||||||
@@ -123,7 +124,7 @@ fun KGPBaseTest.nativeProject(
|
|||||||
localRepoDir = localRepoDir,
|
localRepoDir = localRepoDir,
|
||||||
environmentVariables = environmentVariables,
|
environmentVariables = environmentVariables,
|
||||||
)
|
)
|
||||||
project.configureSingleNativeTarget()
|
project.configureSingleNativeTarget(configureSubProjects)
|
||||||
project.test()
|
project.test()
|
||||||
return project
|
return project
|
||||||
}
|
}
|
||||||
@@ -645,11 +646,27 @@ private fun GradleProject.addHeapDumpOptions() {
|
|||||||
private const val SINGLE_NATIVE_TARGET_PLACEHOLDER = "<SingleNativeTarget>"
|
private const val SINGLE_NATIVE_TARGET_PLACEHOLDER = "<SingleNativeTarget>"
|
||||||
private const val LOCAL_REPOSITORY_PLACEHOLDER = "<localRepo>"
|
private const val LOCAL_REPOSITORY_PLACEHOLDER = "<localRepo>"
|
||||||
|
|
||||||
private fun TestProject.configureSingleNativeTarget(preset: String = HostManager.host.presetName) {
|
private fun TestProject.configureSingleNativeTarget(
|
||||||
|
configureSubProjects: Boolean = false,
|
||||||
|
preset: String = HostManager.host.presetName,
|
||||||
|
) {
|
||||||
val buildScript = if (buildGradle.exists()) buildGradle else buildGradleKts
|
val buildScript = if (buildGradle.exists()) buildGradle else buildGradleKts
|
||||||
buildScript.modify {
|
buildScript.modify {
|
||||||
it.replace(SINGLE_NATIVE_TARGET_PLACEHOLDER, preset)
|
it.replace(SINGLE_NATIVE_TARGET_PLACEHOLDER, preset)
|
||||||
}
|
}
|
||||||
|
if (configureSubProjects) {
|
||||||
|
configureSingleNativeTargetInSubFolders(preset)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun TestProject.configureSingleNativeTargetInSubFolders(preset: String = HostManager.host.presetName) {
|
||||||
|
projectPath.toFile().walk()
|
||||||
|
.filter { it.isFile && (it.name == "build.gradle.kts" || it.name == "build.gradle") }
|
||||||
|
.forEach { file ->
|
||||||
|
file.modify {
|
||||||
|
it.replace(SINGLE_NATIVE_TARGET_PLACEHOLDER, preset)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun TestProject.configureLocalRepository(localRepoDir: Path) {
|
private fun TestProject.configureLocalRepository(localRepoDir: Path) {
|
||||||
|
|||||||
Reference in New Issue
Block a user