plugins { alias(libs.plugins.android.library) } val shareDir = layout.buildDirectory.dir("test-share") val dockerDir = layout.projectDirectory.dir("src/test/docker") android { namespace = "org.the_jk.cleversync.samba" externalNativeBuild { cmake { path("CMakeLists.txt") } } buildTypes { debug { externalNativeBuild { cmake { cFlags += listOf("-g") } } } release { externalNativeBuild { cmake { cFlags += listOf("-O3") } } } } testOptions { unitTests { all { test -> test.doFirst { shareDir.get().asFile.mkdirs() } test.systemProperty("dockerDir", dockerDir.toString()) test.systemProperty("shareDir", shareDir.get().toString()) } } } } dependencies { implementation(project(":libs:io")) testImplementation(project(":libs:utils")) testImplementation(project(":libs:test-utils")) } listOf("Debug", "Release").forEach { buildType -> val buildDir = project.layout.buildDirectory.dir("test-cpp/debug/build") val configure by tasks.register( "configureLibsFor${buildType}UnitTest", Exec::class ) { args( "-S", project.layout.projectDirectory.dir("."), "-B", buildDir.get() ) executable = "cmake" } val compile by tasks.register( "compileLibsFor${buildType}UnitTest", Exec::class ) { dependsOn(configure) args("--build", buildDir.get()) executable = "cmake" } val copy by tasks.register( "copyLibsFor${buildType}UnitTest", Copy::class ) { dependsOn(compile) from(buildDir.map { it.file("libsamba.so") }) into(project.layout.projectDirectory.dir("src/test${buildType}/jniLibs")) } tasks.matching { it.name == "test${buildType}UnitTest" }.all { dependsOn(copy) } }