build.gradle.kts 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. //
  2. // Copyright (c) 2008-2020 the Urho3D project.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. plugins {
  23. id("com.android.application")
  24. kotlin("android")
  25. kotlin("android.extensions")
  26. }
  27. val kotlinVersion: String by ext
  28. val ndkSideBySideVersion: String by ext
  29. val cmakeVersion: String by ext
  30. val buildStagingDir: String by ext
  31. android {
  32. ndkVersion = ndkSideBySideVersion
  33. compileSdkVersion(30)
  34. defaultConfig {
  35. minSdkVersion(18)
  36. targetSdkVersion(30)
  37. applicationId = "io.urho3d.launcher"
  38. versionCode = 1
  39. versionName = project.version.toString()
  40. testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
  41. externalNativeBuild {
  42. cmake {
  43. arguments.apply {
  44. System.getenv("ANDROID_CCACHE")?.let { add("-D ANDROID_CCACHE=$it") }
  45. add("-D BUILD_STAGING_DIR=${findProject(":android:urho3d-lib")!!.projectDir}/$buildStagingDir")
  46. add("-D URHO3D_PLAYER=1")
  47. // Skip building samples for 'STATIC' lib type to reduce the spacetime requirement
  48. add("-D URHO3D_SAMPLES=${if (System.getenv("URHO3D_LIB_TYPE") == "SHARED") "1" else "0"}")
  49. // Pass along matching env-vars as CMake build options
  50. addAll(project.file("../../script/.build-options")
  51. .readLines()
  52. .filterNot { listOf("URHO3D_PLAYER", "URHO3D_SAMPLES").contains(it) }
  53. .mapNotNull { variable -> System.getenv(variable)?.let { "-D $variable=$it" } }
  54. )
  55. }
  56. }
  57. }
  58. splits {
  59. abi {
  60. isEnable = project.hasProperty("ANDROID_ABI")
  61. reset()
  62. include(
  63. *(project.findProperty("ANDROID_ABI") as String? ?: "")
  64. .split(',')
  65. .toTypedArray()
  66. )
  67. }
  68. }
  69. }
  70. buildTypes {
  71. named("release") {
  72. isMinifyEnabled = false
  73. proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
  74. }
  75. }
  76. lintOptions {
  77. isAbortOnError = false
  78. }
  79. externalNativeBuild {
  80. cmake {
  81. version = cmakeVersion
  82. path = project.file("CMakeLists.txt")
  83. setBuildStagingDirectory(buildStagingDir)
  84. }
  85. }
  86. }
  87. dependencies {
  88. implementation(project(":android:urho3d-lib"))
  89. implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar", "*.aar"))))
  90. implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion")
  91. implementation("androidx.core:core-ktx:1.3.2")
  92. implementation("androidx.appcompat:appcompat:1.2.0")
  93. implementation("androidx.constraintlayout:constraintlayout:2.0.2")
  94. testImplementation("junit:junit:4.13.1")
  95. androidTestImplementation("androidx.test:runner:1.3.0")
  96. androidTestImplementation("androidx.test.espresso:espresso-core:3.3.0")
  97. }
  98. afterEvaluate {
  99. android.buildTypes.forEach {
  100. val config = it.name.capitalize()
  101. tasks {
  102. "externalNativeBuild$config" {
  103. mustRunAfter(":android:urho3d-lib:externalNativeBuild$config")
  104. }
  105. }
  106. }
  107. }
  108. tasks {
  109. register<Delete>("cleanAll") {
  110. dependsOn("clean")
  111. delete = setOf(android.externalNativeBuild.cmake.buildStagingDirectory)
  112. }
  113. }