/ build.gradle
build.gradle
  1  /*
  2   * SPDX-FileCopyrightText: 2013 microG Project Team
  3   * SPDX-License-Identifier: Apache-2.0
  4   */
  5  
  6  buildscript {
  7      ext.cronetVersion = '102.5005.125'
  8      ext.wearableVersion = '0.1.1'
  9  
 10      ext.kotlinVersion = '1.9.22'
 11      ext.coroutineVersion = '1.7.3'
 12  
 13      ext.annotationVersion = '1.7.1'
 14      ext.appcompatVersion = '1.6.1'
 15      ext.biometricVersion = '1.1.0'
 16      ext.coreVersion = '1.12.0'
 17      ext.fragmentVersion = '1.6.2'
 18      ext.lifecycleVersion = '2.7.0'
 19      ext.loaderVersion = '1.1.0'
 20      ext.materialVersion = '1.11.0'
 21      ext.mediarouterVersion = '1.6.0'
 22      ext.multidexVersion = '2.0.1'
 23      ext.navigationVersion = '2.7.7'
 24      ext.preferenceVersion = '1.2.0'
 25      ext.recyclerviewVersion = '1.3.2'
 26      ext.webkitVersion = '1.10.0'
 27  
 28      ext.slf4jVersion = '1.7.36'
 29      ext.volleyVersion = '1.2.1'
 30      ext.okHttpVersion = '4.12.0'
 31      ext.ktorVersion = '2.3.12'
 32      ext.wireVersion = '4.9.9'
 33      ext.tinkVersion = '1.13.0'
 34  
 35      ext.androidBuildGradleVersion = '8.2.2'
 36  
 37      ext.androidBuildVersionTools = '34.0.0'
 38  
 39      ext.androidMinSdk = 19
 40      ext.androidTargetSdk = 29
 41      ext.androidCompileSdk = 35
 42  
 43      ext.localProperties = new Properties()
 44  
 45      try {
 46          var stream = rootProject.file('local.properties').newDataInputStream()
 47          ext.localProperties.load(stream)
 48          stream.close()
 49      } catch (ignored) {
 50          // Ignore
 51      }
 52  
 53      ext.hasModule = (String name, boolean enabledByDefault) -> {
 54          return ext.localProperties.getProperty("modules." + name, enabledByDefault.toString()).toBoolean()
 55      }
 56  
 57      repositories {
 58          mavenCentral()
 59          google()
 60      }
 61  
 62      dependencies {
 63          classpath "com.android.tools.build:gradle:$androidBuildGradleVersion"
 64          classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
 65          classpath "com.squareup.wire:wire-gradle-plugin:$wireVersion"
 66      }
 67  }
 68  
 69  def execResult(... args) {
 70      providers.exec { commandLine args }.standardOutput.asText.get()
 71  }
 72  
 73  def ignoreGit = providers.environmentVariable('GRADLE_MICROG_VERSION_WITHOUT_GIT').getOrElse('0') == '1'
 74  def gmsVersion = "25.09.32"
 75  def gmsVersionCode = Integer.parseInt(gmsVersion.replaceAll('\\.', ''))
 76  def vendingVersion = "40.2.26"
 77  def vendingVersionCode = Integer.parseInt(vendingVersion.replaceAll('\\.', ''))
 78  def gitVersionBase = !ignoreGit ? execResult('git', 'describe', '--tags', '--abbrev=0', '--match=v[0-9]*').trim().substring(1) : "v0.0.0.$gmsVersionCode"
 79  def gitCommitCount = !ignoreGit ? Integer.parseInt(execResult('git', 'rev-list', '--count', "v$gitVersionBase..HEAD").trim()) : 0
 80  def gitCommitId = !ignoreGit ? execResult('git', 'show-ref', '--abbrev=7', '--head', 'HEAD').trim().split(' ')[0] : '0000000'
 81  def gitDirty = false
 82  if (!ignoreGit) {
 83    execResult('git', 'status', '--porcelain').lines().each { stat ->
 84      def status = stat.substring(0,2)
 85      def file = stat.substring(3)
 86      if (status == '??') {
 87        if (subprojects.any { p -> file.startsWith(p.name + '/') }) {
 88          logger.lifecycle('Dirty file: {} (untracked)', file)
 89          gitDirty = true
 90        } else {
 91          logger.info('New file outside module: {} (ignored for dirty check)', file)
 92        }
 93      } else {
 94        logger.lifecycle('Dirty file: {} (changed)', file)
 95        gitDirty = true
 96      }
 97    }
 98  }
 99  def ourVersionBase = gitVersionBase.substring(0, gitVersionBase.lastIndexOf('.'))
100  def ourVersionMinor = Integer.parseInt(ourVersionBase.substring(ourVersionBase.lastIndexOf('.') + 1))
101  def ourGmsVersionCode = gmsVersionCode * 1000 + ourVersionMinor * 2  + (gitCommitCount > 0 || gitDirty ? 1 : 0)
102  def ourGmsVersionName = "$ourVersionBase.$gmsVersionCode" + (gitCommitCount > 0 && !gitDirty ? "-$gitCommitCount" : "") + (gitDirty ? "-dirty" : "") + (gitCommitCount > 0 && !gitDirty ? " ($gitCommitId)" : "")
103  def ourVendingVersionCode = 80000000 + vendingVersionCode * 100 + ourVersionMinor * 2  + (gitCommitCount > 0 || gitDirty ? 1 : 0)
104  def ourVendingVersionName = "$ourVersionBase.$vendingVersionCode" + (gitCommitCount > 0 && !gitDirty ? "-$gitCommitCount" : "") + (gitDirty ? "-dirty" : "") + (gitCommitCount > 0 && !gitDirty ? " ($gitCommitId)" : "")
105  logger.lifecycle('Starting build for GMS version {} ({})...', ourGmsVersionName, ourGmsVersionCode)
106  
107  allprojects {
108      apply plugin: 'idea'
109  
110      group = 'org.microg.gms'
111      version = ourGmsVersionName
112      ext.vendingAppVersionName = ourVendingVersionName
113      ext.vendingAppVersionCode = ourVendingVersionCode
114      ext.appVersionCode = ourGmsVersionCode
115      ext.isReleaseVersion = false
116  }
117  
118  subprojects {
119      repositories {
120          mavenCentral()
121          google()
122          if (hasModule("hms", false)) maven {url 'https://developer.huawei.com/repo/'}
123      }
124  }
125