Repositorio del curso CCOM4030 el semestre B91 del proyecto Paz para la Mujer

build.gradle 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. /*
  2. Licensed to the Apache Software Foundation (ASF) under one
  3. or more contributor license agreements. See the NOTICE file
  4. distributed with this work for additional information
  5. regarding copyright ownership. The ASF licenses this file
  6. to you under the Apache License, Version 2.0 (the
  7. "License"); you may not use this file except in compliance
  8. with the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing,
  11. software distributed under the License is distributed on an
  12. "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  13. KIND, either express or implied. See the License for the
  14. specific language governing permissions and limitations
  15. under the License.
  16. */
  17. apply plugin: 'com.android.application'
  18. buildscript {
  19. repositories {
  20. mavenCentral()
  21. google()
  22. jcenter()
  23. }
  24. dependencies {
  25. classpath 'com.android.tools.build:gradle:3.3.0'
  26. }
  27. }
  28. // Allow plugins to declare Maven dependencies via build-extras.gradle.
  29. allprojects {
  30. repositories {
  31. mavenCentral()
  32. jcenter()
  33. }
  34. }
  35. task wrapper(type: Wrapper) {
  36. gradleVersion = '4.10.3'
  37. }
  38. // Configuration properties. Set these via environment variables, build-extras.gradle, or gradle.properties.
  39. // Refer to: http://www.gradle.org/docs/current/userguide/tutorial_this_and_that.html
  40. ext {
  41. apply from: '../CordovaLib/cordova.gradle'
  42. // The value for android.compileSdkVersion.
  43. if (!project.hasProperty('cdvCompileSdkVersion')) {
  44. cdvCompileSdkVersion = null;
  45. }
  46. // The value for android.buildToolsVersion.
  47. if (!project.hasProperty('cdvBuildToolsVersion')) {
  48. cdvBuildToolsVersion = null;
  49. }
  50. // Sets the versionCode to the given value.
  51. if (!project.hasProperty('cdvVersionCode')) {
  52. cdvVersionCode = null
  53. }
  54. // Sets the minSdkVersion to the given value.
  55. if (!project.hasProperty('cdvMinSdkVersion')) {
  56. cdvMinSdkVersion = null
  57. }
  58. // Sets the maxSdkVersion to the given value.
  59. if (!project.hasProperty('cdvMaxSdkVersion')) {
  60. cdvMaxSdkVersion = null
  61. }
  62. // The value for android.targetSdkVersion.
  63. if (!project.hasProperty('cdvTargetSdkVersion')) {
  64. cdvTargetSdkVersion = null;
  65. }
  66. // Whether to build architecture-specific APKs.
  67. if (!project.hasProperty('cdvBuildMultipleApks')) {
  68. cdvBuildMultipleApks = null
  69. }
  70. // Whether to append a 0 "abi digit" to versionCode when only a single APK is build
  71. if (!project.hasProperty('cdvVersionCodeForceAbiDigit')) {
  72. cdvVersionCodeForceAbiDigit = null
  73. }
  74. // .properties files to use for release signing.
  75. if (!project.hasProperty('cdvReleaseSigningPropertiesFile')) {
  76. cdvReleaseSigningPropertiesFile = null
  77. }
  78. // .properties files to use for debug signing.
  79. if (!project.hasProperty('cdvDebugSigningPropertiesFile')) {
  80. cdvDebugSigningPropertiesFile = null
  81. }
  82. // Set by build.js script.
  83. if (!project.hasProperty('cdvBuildArch')) {
  84. cdvBuildArch = null
  85. }
  86. // Plugin gradle extensions can append to this to have code run at the end.
  87. cdvPluginPostBuildExtras = []
  88. }
  89. // PLUGIN GRADLE EXTENSIONS START
  90. // PLUGIN GRADLE EXTENSIONS END
  91. def hasBuildExtras1 = file('build-extras.gradle').exists()
  92. if (hasBuildExtras1) {
  93. apply from: 'build-extras.gradle'
  94. }
  95. def hasBuildExtras2 = file('../build-extras.gradle').exists()
  96. if (hasBuildExtras2) {
  97. apply from: '../build-extras.gradle'
  98. }
  99. // Set property defaults after extension .gradle files.
  100. ext.cdvCompileSdkVersion = cdvCompileSdkVersion == null ? (
  101. defaultCompileSdkVersion == null
  102. ? privateHelpers.getProjectTarget()
  103. : defaultCompileSdkVersion
  104. ) : Integer.parseInt('' + cdvCompileSdkVersion);
  105. if (ext.cdvBuildToolsVersion == null) {
  106. ext.cdvBuildToolsVersion = privateHelpers.findLatestInstalledBuildTools()
  107. //ext.cdvBuildToolsVersion = project.ext.defaultBuildToolsVersion
  108. }
  109. if (ext.cdvDebugSigningPropertiesFile == null && file('../debug-signing.properties').exists()) {
  110. ext.cdvDebugSigningPropertiesFile = '../debug-signing.properties'
  111. }
  112. if (ext.cdvReleaseSigningPropertiesFile == null && file('../release-signing.properties').exists()) {
  113. ext.cdvReleaseSigningPropertiesFile = '../release-signing.properties'
  114. }
  115. // Cast to appropriate types.
  116. ext.cdvBuildMultipleApks = cdvBuildMultipleApks == null ? false : cdvBuildMultipleApks.toBoolean();
  117. ext.cdvVersionCodeForceAbiDigit = cdvVersionCodeForceAbiDigit == null ? false : cdvVersionCodeForceAbiDigit.toBoolean();
  118. // minSdkVersion, maxSdkVersion and targetSdkVersion
  119. ext.cdvMinSdkVersion = cdvMinSdkVersion == null ? defaultMinSdkVersion : Integer.parseInt('' + cdvMinSdkVersion)
  120. if (cdvMaxSdkVersion != null) {
  121. ext.cdvMaxSdkVersion = Integer.parseInt('' + cdvMaxSdkVersion)
  122. }
  123. ext.cdvTargetSdkVersion = cdvTargetSdkVersion == null ? defaultTargetSdkVersion : Integer.parseInt('' + cdvTargetSdkVersion)
  124. ext.cdvVersionCode = cdvVersionCode == null ? null : Integer.parseInt('' + cdvVersionCode)
  125. def computeBuildTargetName(debugBuild) {
  126. def ret = 'assemble'
  127. if (cdvBuildMultipleApks && cdvBuildArch) {
  128. def arch = cdvBuildArch == 'arm' ? 'armv7' : cdvBuildArch
  129. ret += '' + arch.toUpperCase().charAt(0) + arch.substring(1);
  130. }
  131. return ret + (debugBuild ? 'Debug' : 'Release')
  132. }
  133. // Make cdvBuild a task that depends on the debug/arch-sepecific task.
  134. task cdvBuildDebug
  135. cdvBuildDebug.dependsOn {
  136. return computeBuildTargetName(true)
  137. }
  138. task cdvBuildRelease
  139. cdvBuildRelease.dependsOn {
  140. return computeBuildTargetName(false)
  141. }
  142. task cdvPrintProps {
  143. doLast {
  144. println('cdvCompileSdkVersion=' + cdvCompileSdkVersion)
  145. println('cdvBuildToolsVersion=' + cdvBuildToolsVersion)
  146. println('cdvVersionCode=' + cdvVersionCode)
  147. println('cdvVersionCodeForceAbiDigit=' + cdvVersionCodeForceAbiDigit)
  148. println('cdvMinSdkVersion=' + cdvMinSdkVersion)
  149. println('cdvMaxSdkVersion=' + cdvMaxSdkVersion)
  150. println('cdvTargetSdkVersion=' + cdvTargetSdkVersion)
  151. println('cdvBuildMultipleApks=' + cdvBuildMultipleApks)
  152. println('cdvReleaseSigningPropertiesFile=' + cdvReleaseSigningPropertiesFile)
  153. println('cdvDebugSigningPropertiesFile=' + cdvDebugSigningPropertiesFile)
  154. println('cdvBuildArch=' + cdvBuildArch)
  155. println('computedVersionCode=' + android.defaultConfig.versionCode)
  156. android.productFlavors.each { flavor ->
  157. println('computed' + flavor.name.capitalize() + 'VersionCode=' + flavor.versionCode)
  158. }
  159. }
  160. }
  161. android {
  162. defaultConfig {
  163. versionCode cdvVersionCode ?: new BigInteger("" + privateHelpers.extractIntFromManifest("versionCode"))
  164. applicationId privateHelpers.extractStringFromManifest("package")
  165. if (cdvMinSdkVersion != null) {
  166. minSdkVersion cdvMinSdkVersion
  167. }
  168. if (cdvMaxSdkVersion != null) {
  169. maxSdkVersion cdvMaxSdkVersion
  170. }
  171. if(cdvTargetSdkVersion != null) {
  172. targetSdkVersion cdvTargetSdkVersion
  173. }
  174. }
  175. lintOptions {
  176. abortOnError false;
  177. }
  178. compileSdkVersion cdvCompileSdkVersion
  179. buildToolsVersion cdvBuildToolsVersion
  180. // This code exists for Crosswalk and other Native APIs.
  181. // By default, we multiply the existing version code in the
  182. // Android Manifest by 10 and add a number for each architecture.
  183. // If you are not using Crosswalk or SQLite, you can
  184. // ignore this chunk of code, and your version codes will be respected.
  185. if (Boolean.valueOf(cdvBuildMultipleApks)) {
  186. flavorDimensions "default"
  187. productFlavors {
  188. armeabi {
  189. versionCode defaultConfig.versionCode*10 + 1
  190. ndk {
  191. abiFilters = ["armeabi"]
  192. }
  193. }
  194. armv7 {
  195. versionCode defaultConfig.versionCode*10 + 2
  196. ndk {
  197. abiFilters = ["armeabi-v7a"]
  198. }
  199. }
  200. arm64 {
  201. versionCode defaultConfig.versionCode*10 + 3
  202. ndk {
  203. abiFilters = ["arm64-v8a"]
  204. }
  205. }
  206. x86 {
  207. versionCode defaultConfig.versionCode*10 + 4
  208. ndk {
  209. abiFilters = ["x86"]
  210. }
  211. }
  212. x86_64 {
  213. versionCode defaultConfig.versionCode*10 + 5
  214. ndk {
  215. abiFilters = ["x86_64"]
  216. }
  217. }
  218. }
  219. } else if (Boolean.valueOf(cdvVersionCodeForceAbiDigit)) {
  220. // This provides compatibility to the default logic for versionCode before cordova-android 5.2.0
  221. defaultConfig {
  222. versionCode defaultConfig.versionCode*10
  223. }
  224. }
  225. compileOptions {
  226. sourceCompatibility JavaVersion.VERSION_1_8
  227. targetCompatibility JavaVersion.VERSION_1_8
  228. }
  229. if (cdvReleaseSigningPropertiesFile) {
  230. signingConfigs {
  231. release {
  232. // These must be set or Gradle will complain (even if they are overridden).
  233. keyAlias = ""
  234. keyPassword = "__unset" // And these must be set to non-empty in order to have the signing step added to the task graph.
  235. storeFile = null
  236. storePassword = "__unset"
  237. }
  238. }
  239. buildTypes {
  240. release {
  241. signingConfig signingConfigs.release
  242. }
  243. }
  244. addSigningProps(cdvReleaseSigningPropertiesFile, signingConfigs.release)
  245. }
  246. if (cdvDebugSigningPropertiesFile) {
  247. addSigningProps(cdvDebugSigningPropertiesFile, signingConfigs.debug)
  248. }
  249. }
  250. /*
  251. * WARNING: Cordova Lib and platform scripts do management inside of this code here,
  252. * if you are adding the dependencies manually, do so outside the comments, otherwise
  253. * the Cordova tools will overwrite them
  254. */
  255. dependencies {
  256. implementation fileTree(dir: 'libs', include: '*.jar')
  257. // SUB-PROJECT DEPENDENCIES START
  258. implementation(project(path: ":CordovaLib"))
  259. // SUB-PROJECT DEPENDENCIES END
  260. }
  261. def promptForReleaseKeyPassword() {
  262. if (!cdvReleaseSigningPropertiesFile) {
  263. return;
  264. }
  265. if ('__unset'.equals(android.signingConfigs.release.storePassword)) {
  266. android.signingConfigs.release.storePassword = privateHelpers.promptForPassword('Enter key store password: ')
  267. }
  268. if ('__unset'.equals(android.signingConfigs.release.keyPassword)) {
  269. android.signingConfigs.release.keyPassword = privateHelpers.promptForPassword('Enter key password: ');
  270. }
  271. }
  272. gradle.taskGraph.whenReady { taskGraph ->
  273. taskGraph.getAllTasks().each() { task ->
  274. if(['validateReleaseSigning', 'validateSigningRelease', 'validateSigningArmv7Release', 'validateSigningX76Release'].contains(task.name)) {
  275. promptForReleaseKeyPassword()
  276. }
  277. }
  278. }
  279. def addSigningProps(propsFilePath, signingConfig) {
  280. def propsFile = file(propsFilePath)
  281. def props = new Properties()
  282. propsFile.withReader { reader ->
  283. props.load(reader)
  284. }
  285. def storeFile = new File(props.get('key.store') ?: privateHelpers.ensureValueExists(propsFilePath, props, 'storeFile'))
  286. if (!storeFile.isAbsolute()) {
  287. storeFile = RelativePath.parse(true, storeFile.toString()).getFile(propsFile.getParentFile())
  288. }
  289. if (!storeFile.exists()) {
  290. throw new FileNotFoundException('Keystore file does not exist: ' + storeFile.getAbsolutePath())
  291. }
  292. signingConfig.keyAlias = props.get('key.alias') ?: privateHelpers.ensureValueExists(propsFilePath, props, 'keyAlias')
  293. signingConfig.keyPassword = props.get('keyPassword', props.get('key.alias.password', signingConfig.keyPassword))
  294. signingConfig.storeFile = storeFile
  295. signingConfig.storePassword = props.get('storePassword', props.get('key.store.password', signingConfig.storePassword))
  296. def storeType = props.get('storeType', props.get('key.store.type', ''))
  297. if (!storeType) {
  298. def filename = storeFile.getName().toLowerCase();
  299. if (filename.endsWith('.p12') || filename.endsWith('.pfx')) {
  300. storeType = 'pkcs12'
  301. } else {
  302. storeType = signingConfig.storeType // "jks"
  303. }
  304. }
  305. signingConfig.storeType = storeType
  306. }
  307. for (def func : cdvPluginPostBuildExtras) {
  308. func()
  309. }
  310. // This can be defined within build-extras.gradle as:
  311. // ext.postBuildExtras = { ... code here ... }
  312. if (hasProperty('postBuildExtras')) {
  313. postBuildExtras()
  314. }