Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

build.gradle 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  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. jcenter()
  22. }
  23. // Switch the Android Gradle plugin version requirement depending on the
  24. // installed version of Gradle. This dependency is documented at
  25. // http://tools.android.com/tech-docs/new-build-system/version-compatibility
  26. // and https://issues.apache.org/jira/browse/CB-8143
  27. dependencies {
  28. classpath 'com.android.tools.build:gradle:2.2.3'
  29. }
  30. }
  31. // Allow plugins to declare Maven dependencies via build-extras.gradle.
  32. allprojects {
  33. repositories {
  34. mavenCentral();
  35. jcenter()
  36. }
  37. }
  38. task wrapper(type: Wrapper) {
  39. gradleVersion = '2.14.1'
  40. }
  41. // Configuration properties. Set these via environment variables, build-extras.gradle, or gradle.properties.
  42. // Refer to: http://www.gradle.org/docs/current/userguide/tutorial_this_and_that.html
  43. ext {
  44. apply from: 'CordovaLib/cordova.gradle'
  45. // The value for android.compileSdkVersion.
  46. if (!project.hasProperty('cdvCompileSdkVersion')) {
  47. cdvCompileSdkVersion = null;
  48. }
  49. // The value for android.buildToolsVersion.
  50. if (!project.hasProperty('cdvBuildToolsVersion')) {
  51. cdvBuildToolsVersion = null;
  52. }
  53. // Sets the versionCode to the given value.
  54. if (!project.hasProperty('cdvVersionCode')) {
  55. cdvVersionCode = null
  56. }
  57. // Sets the minSdkVersion to the given value.
  58. if (!project.hasProperty('cdvMinSdkVersion')) {
  59. cdvMinSdkVersion = null
  60. }
  61. // Sets the maxSdkVersion to the given value.
  62. if (!project.hasProperty('cdvMaxSdkVersion')) {
  63. cdvMaxSdkVersion = null
  64. }
  65. // The value for android.targetSdkVersion.
  66. if (!project.hasProperty('cdvTargetSdkVersion')) {
  67. cdvTargetSdkVersion = null;
  68. }
  69. // Whether to build architecture-specific APKs.
  70. if (!project.hasProperty('cdvBuildMultipleApks')) {
  71. cdvBuildMultipleApks = null
  72. }
  73. // .properties files to use for release signing.
  74. if (!project.hasProperty('cdvReleaseSigningPropertiesFile')) {
  75. cdvReleaseSigningPropertiesFile = null
  76. }
  77. // .properties files to use for debug signing.
  78. if (!project.hasProperty('cdvDebugSigningPropertiesFile')) {
  79. cdvDebugSigningPropertiesFile = null
  80. }
  81. // Set by build.js script.
  82. if (!project.hasProperty('cdvBuildArch')) {
  83. cdvBuildArch = null
  84. }
  85. // Plugin gradle extensions can append to this to have code run at the end.
  86. cdvPluginPostBuildExtras = []
  87. }
  88. // PLUGIN GRADLE EXTENSIONS START
  89. // PLUGIN GRADLE EXTENSIONS END
  90. def hasBuildExtras = file('build-extras.gradle').exists()
  91. if (hasBuildExtras) {
  92. apply from: 'build-extras.gradle'
  93. }
  94. // Set property defaults after extension .gradle files.
  95. if (ext.cdvCompileSdkVersion == null) {
  96. ext.cdvCompileSdkVersion = privateHelpers.getProjectTarget()
  97. }
  98. if (ext.cdvBuildToolsVersion == null) {
  99. ext.cdvBuildToolsVersion = privateHelpers.findLatestInstalledBuildTools()
  100. }
  101. if (ext.cdvDebugSigningPropertiesFile == null && file('debug-signing.properties').exists()) {
  102. ext.cdvDebugSigningPropertiesFile = 'debug-signing.properties'
  103. }
  104. if (ext.cdvReleaseSigningPropertiesFile == null && file('release-signing.properties').exists()) {
  105. ext.cdvReleaseSigningPropertiesFile = 'release-signing.properties'
  106. }
  107. // Cast to appropriate types.
  108. ext.cdvBuildMultipleApks = cdvBuildMultipleApks == null ? false : cdvBuildMultipleApks.toBoolean();
  109. ext.cdvMinSdkVersion = cdvMinSdkVersion == null ? null : Integer.parseInt('' + cdvMinSdkVersion)
  110. if(cdvMaxSdkVersion != null) {
  111. ext.cdvMaxSdkVersion = Integer.parseInt('' + cdvMaxSdkVersion)
  112. }
  113. ext.cdvVersionCode = cdvVersionCode == null ? null : Integer.parseInt('' + cdvVersionCode)
  114. def computeBuildTargetName(debugBuild) {
  115. def ret = 'assemble'
  116. if (cdvBuildMultipleApks && cdvBuildArch) {
  117. def arch = cdvBuildArch == 'arm' ? 'armv7' : cdvBuildArch
  118. ret += '' + arch.toUpperCase().charAt(0) + arch.substring(1);
  119. }
  120. return ret + (debugBuild ? 'Debug' : 'Release')
  121. }
  122. // Make cdvBuild a task that depends on the debug/arch-sepecific task.
  123. task cdvBuildDebug
  124. cdvBuildDebug.dependsOn {
  125. return computeBuildTargetName(true)
  126. }
  127. task cdvBuildRelease
  128. cdvBuildRelease.dependsOn {
  129. return computeBuildTargetName(false)
  130. }
  131. task cdvPrintProps << {
  132. println('cdvCompileSdkVersion=' + cdvCompileSdkVersion)
  133. println('cdvBuildToolsVersion=' + cdvBuildToolsVersion)
  134. println('cdvVersionCode=' + cdvVersionCode)
  135. println('cdvMinSdkVersion=' + cdvMinSdkVersion)
  136. println('cdvMaxSdkVersion=' + cdvMaxSdkVersion)
  137. println('cdvTargetSdkVersion=' + cdvTargetSdkVersion)
  138. println('cdvBuildMultipleApks=' + cdvBuildMultipleApks)
  139. println('cdvReleaseSigningPropertiesFile=' + cdvReleaseSigningPropertiesFile)
  140. println('cdvDebugSigningPropertiesFile=' + cdvDebugSigningPropertiesFile)
  141. println('cdvBuildArch=' + cdvBuildArch)
  142. println('computedVersionCode=' + android.defaultConfig.versionCode)
  143. android.productFlavors.each { flavor ->
  144. println('computed' + flavor.name.capitalize() + 'VersionCode=' + flavor.versionCode)
  145. }
  146. }
  147. android {
  148. sourceSets {
  149. main {
  150. manifest.srcFile 'AndroidManifest.xml'
  151. java.srcDirs = ['src']
  152. resources.srcDirs = ['src']
  153. aidl.srcDirs = ['src']
  154. renderscript.srcDirs = ['src']
  155. res.srcDirs = ['res']
  156. assets.srcDirs = ['assets']
  157. jniLibs.srcDirs = ['libs']
  158. }
  159. }
  160. defaultConfig {
  161. versionCode cdvVersionCode ?: new BigInteger("" + privateHelpers.extractIntFromManifest("versionCode"))
  162. applicationId privateHelpers.extractStringFromManifest("package")
  163. if (cdvMinSdkVersion != null) {
  164. minSdkVersion cdvMinSdkVersion
  165. }
  166. if (cdvMaxSdkVersion != null) {
  167. maxSdkVersion cdvMaxSdkVersion
  168. }
  169. if(cdvTargetSdkVersion != null) {
  170. targetSdkVersion cdvTargetSdkVersion
  171. }
  172. }
  173. lintOptions {
  174. abortOnError false;
  175. }
  176. compileSdkVersion cdvCompileSdkVersion
  177. buildToolsVersion cdvBuildToolsVersion
  178. if (Boolean.valueOf(cdvBuildMultipleApks)) {
  179. productFlavors {
  180. armv7 {
  181. versionCode defaultConfig.versionCode*10 + 2
  182. ndk {
  183. abiFilters "armeabi-v7a", ""
  184. }
  185. }
  186. x86 {
  187. versionCode defaultConfig.versionCode*10 + 4
  188. ndk {
  189. abiFilters "x86", ""
  190. }
  191. }
  192. all {
  193. ndk {
  194. abiFilters "all", ""
  195. }
  196. }
  197. }
  198. }
  199. /*
  200. ELSE NOTHING! DON'T MESS WITH THE VERSION CODE IF YOU DON'T HAVE TO!
  201. else if (!cdvVersionCode) {
  202. def minSdkVersion = cdvMinSdkVersion ?: privateHelpers.extractIntFromManifest("minSdkVersion")
  203. // Vary versionCode by the two most common API levels:
  204. // 14 is ICS, which is the lowest API level for many apps.
  205. // 20 is Lollipop, which is the lowest API level for the updatable system webview.
  206. if (minSdkVersion >= 20) {
  207. defaultConfig.versionCode += 9
  208. } else if (minSdkVersion >= 14) {
  209. defaultConfig.versionCode += 8
  210. }
  211. }
  212. */
  213. compileOptions {
  214. sourceCompatibility JavaVersion.VERSION_1_6
  215. targetCompatibility JavaVersion.VERSION_1_6
  216. }
  217. if (cdvReleaseSigningPropertiesFile) {
  218. signingConfigs {
  219. release {
  220. // These must be set or Gradle will complain (even if they are overridden).
  221. keyAlias = ""
  222. keyPassword = "__unset" // And these must be set to non-empty in order to have the signing step added to the task graph.
  223. storeFile = null
  224. storePassword = "__unset"
  225. }
  226. }
  227. buildTypes {
  228. release {
  229. signingConfig signingConfigs.release
  230. }
  231. }
  232. addSigningProps(cdvReleaseSigningPropertiesFile, signingConfigs.release)
  233. }
  234. if (cdvDebugSigningPropertiesFile) {
  235. addSigningProps(cdvDebugSigningPropertiesFile, signingConfigs.debug)
  236. }
  237. }
  238. dependencies {
  239. implementation fileTree(dir: 'libs', include: '*.jar')
  240. // SUB-PROJECT DEPENDENCIES START
  241. // SUB-PROJECT DEPENDENCIES END
  242. }
  243. def promptForReleaseKeyPassword() {
  244. if (!cdvReleaseSigningPropertiesFile) {
  245. return;
  246. }
  247. if ('__unset'.equals(android.signingConfigs.release.storePassword)) {
  248. android.signingConfigs.release.storePassword = privateHelpers.promptForPassword('Enter key store password: ')
  249. }
  250. if ('__unset'.equals(android.signingConfigs.release.keyPassword)) {
  251. android.signingConfigs.release.keyPassword = privateHelpers.promptForPassword('Enter key password: ');
  252. }
  253. }
  254. gradle.taskGraph.whenReady { taskGraph ->
  255. taskGraph.getAllTasks().each() { task ->
  256. if (task.name == 'validateReleaseSigning' || task.name == 'validateSigningRelease') {
  257. promptForReleaseKeyPassword()
  258. }
  259. }
  260. }
  261. def addSigningProps(propsFilePath, signingConfig) {
  262. def propsFile = file(propsFilePath)
  263. def props = new Properties()
  264. propsFile.withReader { reader ->
  265. props.load(reader)
  266. }
  267. def storeFile = new File(props.get('key.store') ?: privateHelpers.ensureValueExists(propsFilePath, props, 'storeFile'))
  268. if (!storeFile.isAbsolute()) {
  269. storeFile = RelativePath.parse(true, storeFile.toString()).getFile(propsFile.getParentFile())
  270. }
  271. if (!storeFile.exists()) {
  272. throw new FileNotFoundException('Keystore file does not exist: ' + storeFile.getAbsolutePath())
  273. }
  274. signingConfig.keyAlias = props.get('key.alias') ?: privateHelpers.ensureValueExists(propsFilePath, props, 'keyAlias')
  275. signingConfig.keyPassword = props.get('keyPassword', props.get('key.alias.password', signingConfig.keyPassword))
  276. signingConfig.storeFile = storeFile
  277. signingConfig.storePassword = props.get('storePassword', props.get('key.store.password', signingConfig.storePassword))
  278. def storeType = props.get('storeType', props.get('key.store.type', ''))
  279. if (!storeType) {
  280. def filename = storeFile.getName().toLowerCase();
  281. if (filename.endsWith('.p12') || filename.endsWith('.pfx')) {
  282. storeType = 'pkcs12'
  283. } else {
  284. storeType = signingConfig.storeType // "jks"
  285. }
  286. }
  287. signingConfig.storeType = storeType
  288. }
  289. for (def func : cdvPluginPostBuildExtras) {
  290. func()
  291. }
  292. // This can be defined within build-extras.gradle as:
  293. // ext.postBuildExtras = { ... code here ... }
  294. if (hasProperty('postBuildExtras')) {
  295. postBuildExtras()
  296. }