adaway/webserver/build.gradle

68 lines
1.7 KiB
Groovy
Raw Permalink Normal View History

2025-11-20 14:05:12 +01:00
import com.android.build.gradle.internal.tasks.LibraryJniLibsTask
apply plugin: 'com.android.library'
android {
compileSdk 33
ndkVersion '25.2.9519653'
namespace 'org.adaway.webserver'
defaultConfig {
minSdk 26
targetSdk 33
}
buildFeatures {
prefab = true
}
externalNativeBuild {
ndkBuild {
path 'jni/Android.mk'
}
}
sonarqube {
skipProject = true
}
}
dependencies {
implementation 'com.android.ndk.thirdparty:openssl:1.1.1q-beta-1'
}
/**
* Task to rename executables from hello_world to libhello_world_exec.so
* If they look like libraries, they are packaged in the apk and deployed on the device in the lib folder!
*
* Help with files: https://docs.gradle.org/current/userguide/working_with_files.html
*/
def renameJniLibAsExecutable = tasks.register('renameJniLibAsExecutable', Copy) {
def flavor = gradle.startParameter.taskRequests.toString().containsIgnoreCase("debug") ? "debug" : "release"
def buildFolder = file("${buildDir}/intermediates/ndkBuild/${flavor}/obj/local/")
dependsOn ":${project.name}:externalNativeBuild${flavor.substring(0, 1).toUpperCase()}${flavor.substring(1)}"
from(buildFolder) {
exclude "**/objs"
exclude "**/objs-debug"
exclude "**/*.a"
exclude "**/*.d"
exclude "**/*.o"
exclude "**/*.so"
exclude "**/*.txt"
}
into buildFolder
rename '(.+)', 'lib$1_exec.so'
eachFile {
println "Replacing ${it.getPath()} from ${flavor} ndkBuild directory"
}
}
tasks.withType(LibraryJniLibsTask).configureEach {
dependsOn renameJniLibAsExecutable
}