nonameolsson

build.gradle

Apr 10th, 2017
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.27 KB | None | 0 0
  1. // Top-level build file where you can add configuration options common to all sub-projects/modules.
  2. import groovy.json.JsonSlurper
  3.  
  4. buildscript {
  5.     repositories {
  6.         jcenter()
  7.     }
  8.     dependencies {
  9.         classpath 'com.android.tools.build:gradle:2.2.3'
  10.  
  11.         // NOTE: Do not place your application dependencies here; they belong
  12.         // in the individual module build.gradle files
  13.     }
  14. }
  15.  
  16. allprojects {
  17.     repositories {
  18.         mavenLocal()
  19.         jcenter()
  20.         maven {
  21.             // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
  22.             url "$rootDir/../node_modules/react-native/android"
  23.         }
  24.     }
  25. }
  26.  
  27. subprojects {
  28.     ext {
  29.         def npmVersion = getNpmVersionArray()
  30.         versionMajor = npmVersion[0]
  31.         versionMinor = npmVersion[1]
  32.         versionPatch = npmVersion[2]
  33.     }
  34. }
  35.  
  36. def getNpmVersion() {
  37.     def inputFile = new File("../package.json")
  38.     def packageJson = new JsonSlurper().parseText(inputFile.text)
  39.     return packageJson["version"]
  40. }
  41.  
  42. def getNpmVersionArray() { // major [0], minor [1], patch [2]
  43.     def (major, minor, patch) = getNpmVersion().tokenize('.')
  44.     return [Integer.parseInt(major), Integer.parseInt(minor), Integer.parseInt(patch)] as int[]
  45. }
Add Comment
Please, Sign In to add comment