com.bugsnag.android.gradle.internal.ExternalNativeBuildTaskUtil.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bugsnag-android-gradle-plugin Show documentation
Show all versions of bugsnag-android-gradle-plugin Show documentation
Gradle plugin to automatically upload ProGuard mapping files to Bugsnag.
package com.bugsnag.android.gradle.internal
import com.android.build.gradle.tasks.ExternalNativeBuildTask
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.provider.Provider
import org.gradle.api.provider.ProviderFactory
import java.io.File
import kotlin.reflect.full.memberProperties
class ExternalNativeBuildTaskUtil(private val providerFactory: ProviderFactory) {
private fun getSearchDir(buildTask: Provider, propName: String): Provider =
buildTask.flatMap { task ->
val soFolder = ExternalNativeBuildTask::class.memberProperties.find { it.name == propName }?.get(task)!!
when (soFolder) {
is File -> providerFactory.provider { fixNativeOutputPath(soFolder) }
is DirectoryProperty -> soFolder.map { fixNativeOutputPath(it.asFile) }
else -> throw IllegalArgumentException("Unknown type of $propName: $soFolder")
}
}
private fun fixNativeOutputPath(taskFolder: File): File {
return taskFolder.parentFile.parentFile.takeIf { it.parentFile.name == "cxx" }
?: taskFolder.parentFile.parentFile.parentFile.takeIf { it.parentFile.name == "cxx" }
?: taskFolder
}
fun findSearchPaths(buildTask: Provider) = arrayOf(
getSearchDir(buildTask, "objFolder"),
getSearchDir(buildTask, "soFolder")
)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy