plugins { alias(libs.plugins.android.library) } 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") } } } } } dependencies { implementation(project(":libs:io")) } listOf("Debug", "Release").forEach { buildType -> val buildDir = project.layout.buildDirectory.dir("test/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) } }