| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 | 
							- plugins {
 
- 	id 'com.android.application'
 
- }
 
- android {
 
- 	compileSdk 31
 
- 	ndkVersion '25.2.9519653'
 
- 	defaultConfig {
 
- 		applicationId "is.xyz.vcmi"
 
- 		minSdk 19
 
- 		targetSdk 31
 
- 		versionCode 1303
 
- 		versionName "1.3.0"
 
- 		setProperty("archivesBaseName", "vcmi")
 
- 	}
 
- 	signingConfigs {
 
- 		releaseSigning
 
- 		dailySigning
 
- 		LoadSigningConfig("releaseSigning")
 
- 		LoadSigningConfig("dailySigning")
 
- 	}
 
- 	buildTypes {
 
- 		debug {
 
- 			debuggable true
 
- 			applicationIdSuffix '.debug'
 
- 			manifestPlaceholders = [
 
- 				applicationLabel: 'VCMI debug',
 
- 			]
 
- 			ndk {
 
- 				debugSymbolLevel 'full'
 
- 			}
 
- 		}
 
- 		release {
 
- 			minifyEnabled false
 
- 			zipAlignEnabled true
 
- 			signingConfig signingConfigs.releaseSigning
 
- 			proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
 
- 			manifestPlaceholders = [
 
- 				applicationLabel: '@string/app_name',
 
- 			]
 
- 			ndk {
 
- 				debugSymbolLevel 'full'
 
- 			}
 
- 		}
 
- 		daily {
 
- 			initWith release
 
- 			applicationIdSuffix '.daily'
 
- 			signingConfig signingConfigs.dailySigning
 
- 			manifestPlaceholders = [
 
- 				applicationLabel: 'VCMI daily',
 
- 			]
 
- 		}
 
- 	}
 
- 	applicationVariants.all { variant -> RenameOutput(project.archivesBaseName, variant) }
 
- 	tasks.withType(JavaCompile) {
 
- 		options.compilerArgs += ["-Xlint:deprecation"]
 
- 	}
 
- 	compileOptions {
 
- 		sourceCompatibility JavaVersion.VERSION_1_8
 
- 		targetCompatibility JavaVersion.VERSION_1_8
 
- 	}
 
- 	buildFeatures {
 
- 		viewBinding true
 
- 		dataBinding true
 
- 	}
 
- }
 
- def RenameOutput(final baseName, final variant) {
 
- 	final def buildTaskId = System.getenv("GITHUB_RUN_ID")
 
- 	ResolveGitInfo()
 
- 	def name = baseName + "-" + ext.gitInfoVcmi
 
- 	if (buildTaskId != null && !buildTaskId.isEmpty()) {
 
- 		name = buildTaskId + "-" + name
 
- 	}
 
- 	if (!variant.buildType.name != "release") {
 
- 		name += "-" + variant.buildType.name
 
- 	}
 
- 	variant.outputs.each { output ->
 
- 		def oldPath = output.outputFile.getAbsolutePath()
 
- 		output.outputFileName = name + oldPath.substring(oldPath.lastIndexOf("."))
 
- 	}
 
- }
 
- def CommandOutput(final cmd, final arguments, final cwd) {
 
- 	try {
 
- 		new ByteArrayOutputStream().withStream { final os ->
 
- 			exec {
 
- 				executable cmd
 
- 				args arguments
 
- 				workingDir cwd
 
- 				standardOutput os
 
- 			}
 
- 			return os.toString().trim()
 
- 		}
 
- 	}
 
- 	catch (final Exception ex) {
 
- 		print("Broken: " + cmd + " " + arguments + " in " + cwd + " :: " + ex.toString())
 
- 		return ""
 
- 	}
 
- }
 
- def ResolveGitInfo() {
 
- 	if (ext.gitInfoVcmi != "none") {
 
- 		return
 
- 	}
 
- 	ext.gitInfoVcmi =
 
- 		CommandOutput("git", ["log", "-1", "--pretty=%D", "--decorate-refs=refs/remotes/origin/*"], ".").replace("origin/", "").replace(", HEAD", "").replaceAll("[^a-zA-Z0-9\\-_]", "_") +
 
- 		"-" +
 
- 		CommandOutput("git", ["describe", "--match=", "--always", "--abbrev=7"], ".")
 
- }
 
- def SigningPropertiesPath(final basePath, final signingConfigKey) {
 
- 	return file("${basePath}/${signingConfigKey}.properties")
 
- }
 
- def SigningKeystorePath(final basePath, final keystoreFileName) {
 
- 	return file("${basePath}/${keystoreFileName}")
 
- }
 
- def LoadSigningConfig(final signingConfigKey) {
 
- 	final def projectRoot = "${project.projectDir}/../../CI/android"
 
- 	final def props = new Properties()
 
- 	final def propFile = SigningPropertiesPath(projectRoot, signingConfigKey)
 
- 	
 
- 	def signingConfig = android.signingConfigs.getAt(signingConfigKey)
 
- 	
 
- 	if (propFile.canRead()) {
 
- 		props.load(new FileInputStream(propFile))
 
- 		if (props != null
 
- 			&& props.containsKey('STORE_FILE')
 
- 			&& props.containsKey('KEY_ALIAS')) {
 
- 			signingConfig.storeFile = SigningKeystorePath(projectRoot, props['STORE_FILE'])
 
- 			signingConfig.storePassword = props['STORE_PASSWORD']
 
- 			signingConfig.keyAlias = props['KEY_ALIAS']
 
- 			
 
- 			if(props.containsKey('STORE_PASSWORD'))
 
- 				signingConfig.storePassword = props['STORE_PASSWORD']
 
- 			else
 
- 				signingConfig.storePassword = System.getenv("ANDROID_STORE_PASSWORD")
 
- 			
 
- 			if(props.containsKey('KEY_PASSWORD'))
 
- 				signingConfig.keyPassword = props['KEY_PASSWORD']
 
- 			else
 
- 				signingConfig.keyPassword = System.getenv("ANDROID_KEY_PASSWORD")
 
- 		} else {
 
- 			println("Some props from signing file are missing")
 
- 			android.signingConfigs.putAt(signingConfigKey, null)
 
- 		}
 
- 	} else {
 
- 		println("file with signing properties is missing")
 
- 		android.signingConfigs.putAt(signingConfigKey, null)
 
- 	}
 
- }
 
- dependencies {
 
- 	implementation 'androidx.appcompat:appcompat:1.2.0'
 
- 	implementation 'com.google.android.material:material:1.3.0'
 
- 	implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
 
- 	implementation 'com.google.android.gms:play-services-base:18.2.0'
 
- 	implementation 'com.google.android.gms:play-services-basement:18.1.0'
 
- }
 
 
  |