mirror of
https://github.com/ihhub/fheroes2.git
synced 2026-10-11 21:59:51 +00:00
158 lines
3.9 KiB
Groovy
158 lines
3.9 KiB
Groovy
import java.nio.file.Files
|
|
import java.security.MessageDigest
|
|
|
|
plugins {
|
|
id 'com.android.application'
|
|
}
|
|
|
|
android {
|
|
namespace 'org.fheroes2'
|
|
|
|
compileSdk 35
|
|
|
|
defaultConfig {
|
|
applicationId 'org.fheroes2'
|
|
|
|
minSdk 22
|
|
targetSdk 35
|
|
|
|
// These paths are set relative to the android project directory
|
|
versionCode((new File('../version_code.txt')).getText('UTF-8').trim().toInteger())
|
|
versionName((new File('../version.txt')).getText('UTF-8').trim())
|
|
|
|
externalNativeBuild {
|
|
ndkBuild {
|
|
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
|
|
arguments '-j4'
|
|
}
|
|
}
|
|
}
|
|
|
|
compileOptions {
|
|
coreLibraryDesugaringEnabled true
|
|
|
|
sourceCompatibility JavaVersion.VERSION_1_8
|
|
targetCompatibility JavaVersion.VERSION_1_8
|
|
}
|
|
|
|
externalNativeBuild {
|
|
ndkBuild {
|
|
path 'jni/Android.mk'
|
|
}
|
|
}
|
|
|
|
signingConfigs {
|
|
release {
|
|
storeFile({
|
|
def keystorePath = System.getenv('FHEROES2_KEYSTORE')
|
|
|
|
return keystorePath ? file(keystorePath) : null
|
|
}.call())
|
|
|
|
storePassword({
|
|
def keystorePass = System.getenv('FHEROES2_KEYSTORE_PASSWORD')
|
|
|
|
return keystorePass ? keystorePass : ''
|
|
}.call())
|
|
|
|
keyAlias({
|
|
def keyAlias = System.getenv('FHEROES2_KEY_ALIAS')
|
|
|
|
return keyAlias ? keyAlias : ''
|
|
}.call())
|
|
|
|
keyPassword({
|
|
def keyPass = System.getenv('FHEROES2_KEY_PASSWORD')
|
|
|
|
return keyPass ? keyPass : ''
|
|
}.call())
|
|
}
|
|
}
|
|
|
|
buildTypes {
|
|
debug {
|
|
externalNativeBuild {
|
|
ndkBuild {
|
|
cFlags '-DWITH_DEBUG', '-Werror'
|
|
}
|
|
}
|
|
}
|
|
|
|
release {
|
|
signingConfig signingConfigs.release
|
|
}
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs_nio:2.1.5'
|
|
|
|
implementation project(':isotools')
|
|
implementation project(':sdl2')
|
|
|
|
implementation group: 'commons-io', name: 'commons-io', version: '2.19.0'
|
|
|
|
implementation 'com.google.android.material:material:1.12.0'
|
|
}
|
|
|
|
tasks.register('copyFH2M', Copy) {
|
|
from('../../maps') {
|
|
include '*.fh2m'
|
|
}
|
|
into 'src/main/assets/maps'
|
|
}
|
|
|
|
tasks.register('copyH2D', Copy) {
|
|
from('../../files/data') {
|
|
include '*.h2d'
|
|
}
|
|
into 'src/main/assets/files/data'
|
|
}
|
|
|
|
tasks.register('copyTimidity', Copy) {
|
|
from('../../files/timidity') {
|
|
include 'instruments/*.pat'
|
|
include 'timidity.cfg'
|
|
}
|
|
into 'src/main/assets/files/timidity'
|
|
}
|
|
|
|
tasks.register('copyTranslations', Copy) {
|
|
from('../../files/lang') {
|
|
include '*.mo'
|
|
}
|
|
into 'src/main/assets/files/lang'
|
|
}
|
|
|
|
tasks.register('generateAssetsDigest') {
|
|
dependsOn copyFH2M, copyH2D, copyTimidity, copyTranslations
|
|
|
|
doLast {
|
|
final java.nio.file.Path assetsDirPath = layout.projectDirectory.getAsFile()
|
|
.toPath().resolve('src/main/assets')
|
|
final java.nio.file.Path digestPath = assetsDirPath.resolve('assets.digest')
|
|
final boolean isDigestExists = Files.exists(digestPath)
|
|
|
|
final StringBuilder sb = new StringBuilder()
|
|
|
|
fileTree(dir: assetsDirPath).each {
|
|
final java.nio.file.Path itPath = it.toPath()
|
|
if (isDigestExists && Files.isSameFile(itPath, digestPath)) {
|
|
return
|
|
}
|
|
|
|
final byte[] itBuf = Files.readAllBytes(itPath)
|
|
|
|
sb.append(String.format('%032x % 12d %s\n',
|
|
new BigInteger(1, MessageDigest.getInstance('MD5').digest(itBuf)),
|
|
itBuf.length, assetsDirPath.relativize(itPath)))
|
|
}
|
|
|
|
Files.write(digestPath, sb.toString().getBytes('UTF-8'))
|
|
}
|
|
}
|
|
|
|
preBuild {
|
|
dependsOn generateAssetsDigest
|
|
}
|