Advertisement
Guest User

Untitled

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