Mindustry/android/build.gradle

157 lines
4.7 KiB
Groovy
Raw Normal View History

2019-04-08 20:03:18 +07:00
buildscript{
repositories{
2018-10-30 03:02:09 +07:00
mavenLocal()
mavenCentral()
google()
2019-04-08 20:03:18 +07:00
maven{ url "https://oss.sonatype.org/content/repositories/snapshots/" }
2018-10-30 03:02:09 +07:00
}
2019-04-08 20:03:18 +07:00
dependencies{
2022-06-06 22:31:38 +07:00
classpath 'com.android.tools.build:gradle:7.2.1'
2018-10-30 03:02:09 +07:00
}
}
2017-12-12 11:48:37 +07:00
apply plugin: "com.android.application"
2019-04-08 20:03:18 +07:00
configurations{ natives }
2019-04-08 20:03:18 +07:00
repositories{
mavenCentral()
2020-04-30 05:29:19 +07:00
maven{ url "https://maven.google.com" }
2017-12-12 11:48:37 +07:00
}
task deploy(type: Copy){
dependsOn "assembleRelease"
2022-07-16 23:29:27 +07:00
from "build/outputs/apk/release/android-release.apk"
2018-10-06 22:56:39 +07:00
into "../deploy/"
2022-07-16 23:29:27 +07:00
rename("android-release.apk", "${generateDeployName('android')}.apk")
}
2019-04-08 20:03:18 +07:00
android{
2022-06-06 22:31:38 +07:00
buildToolsVersion '31.0.0'
compileSdkVersion 31
2019-04-08 20:03:18 +07:00
sourceSets{
main{
2017-06-29 11:54:10 +07:00
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets', 'src/main/assets', '../core/assets/']
2017-06-29 11:54:10 +07:00
jniLibs.srcDirs = ['libs']
}
androidTest.setRoot('tests')
2017-06-29 11:54:10 +07:00
}
2021-06-02 22:08:08 +07:00
2019-04-08 20:03:18 +07:00
packagingOptions{
2017-06-29 11:54:10 +07:00
exclude 'META-INF/robovm/ios/robovm.xml'
}
2019-04-08 20:03:18 +07:00
defaultConfig{
2019-11-20 07:08:41 +07:00
Properties props = loadVersionProps()
2019-09-16 19:24:10 +07:00
Integer vcode = props['androidBuildCode']?.toInteger() ?: 1
2019-08-26 09:02:00 +07:00
def versionNameResult = "$versionNumber-$versionType-${getBuildVersion().replace(" ", "-")}"
2017-06-29 11:54:10 +07:00
applicationId "io.anuke.mindustry"
minSdkVersion 14
2022-06-06 22:31:38 +07:00
targetSdkVersion 31
2019-08-26 09:02:00 +07:00
2018-04-26 07:53:32 +07:00
versionName versionNameResult
2021-12-16 02:51:42 +07:00
versionCode = vcode
2019-09-16 19:24:10 +07:00
2019-09-21 22:03:09 +07:00
if(project.hasProperty("release")){
props['androidBuildCode'] = (vcode + 1).toString()
}
2019-09-16 19:24:10 +07:00
props.store(file('../core/assets/version.properties').newWriter(), null)
2017-06-29 11:54:10 +07:00
}
2019-04-08 20:03:18 +07:00
compileOptions{
2017-06-29 11:54:10 +07:00
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
2017-12-12 11:48:37 +07:00
2017-12-20 07:17:17 +07:00
flavorDimensions "google"
2019-04-08 20:03:18 +07:00
signingConfigs{
release{
if(project.hasProperty("RELEASE_STORE_FILE")){
2018-02-09 22:14:29 +07:00
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD
2020-10-10 04:08:15 +07:00
}else if(System.getenv("CI") == "true"){
2020-10-10 05:35:54 +07:00
storeFile = file("../../bekeystore.jks")
2020-10-10 04:08:15 +07:00
storePassword = System.getenv("keystore_password")
keyAlias = System.getenv("keystore_alias")
keyPassword = System.getenv("keystore_alias_password")
2018-02-09 22:14:29 +07:00
}else{
2020-09-23 08:58:59 +07:00
println("No keystore property found. Releases will be unsigned.")
2018-02-09 22:14:29 +07:00
}
}
}
2022-02-01 12:07:00 +07:00
buildTypes{
all{
2022-02-13 23:09:27 +07:00
//TODO without these lines (r8 enabled), Mindustry crashes with missing default interface method errors.
//WHY THE HELL ARE DEFAULT INTERFACES NOT BEING DESUGARED? WHY DID UPDATING AGP MAKE THIS HAPPEN?
//When I ENABLE shrinking, r8 goes and REMOVES ALL DEFAULT INTERFACE CLASSES, which breaks mods. Why?
//-keep class mindustry.** { *; } should *keep the classes* - WHY IS R8 REMOVING THEM?
2022-02-01 12:07:00 +07:00
minifyEnabled = true
shrinkResources = true
proguardFiles("proguard-rules.pro")
}
}
2020-10-10 05:49:46 +07:00
if(project.hasProperty("RELEASE_STORE_FILE") || System.getenv("CI") == "true"){
2020-10-10 06:10:16 +07:00
buildTypes{
release{
signingConfig signingConfigs.release
}
}
}
2021-06-02 22:08:08 +07:00
}
dependencies{
implementation project(":core")
implementation arcModule("backends:backend-android")
implementation 'com.jakewharton.android.repackaged:dalvik-dx:9.0.0_r3'
natives "com.github.Anuken.Arc:natives-android:${getArcHash()}"
natives "com.github.Anuken.Arc:natives-freetype-android:${getArcHash()}"
def version;
def highestVersion;
new File((String)findSdkDir(), "/platforms").eachFileMatch ~/android-\d+/, {
version = it.name.find(/\d+/).toInteger();
highestVersion = version > highestVersion ? version : highestVersion;
}
def sdkFile = new File((String)findSdkDir(), "/platforms/android-${highestVersion}/android.jar")
if(sdkFile.exists()) compileOnly files(sdkFile.absolutePath)
2017-06-29 11:54:10 +07:00
}
2021-06-02 22:08:08 +07:00
2019-04-08 20:03:18 +07:00
task copyAndroidNatives(){
configurations.natives.files.each{ jar ->
2020-04-30 05:36:20 +07:00
copy{
from zipTree(jar)
into file("libs/")
include "**"
2017-06-29 11:54:10 +07:00
}
}
}
2018-10-07 22:14:54 +07:00
2019-04-08 20:03:18 +07:00
task run(type: Exec){
2021-06-02 22:08:08 +07:00
commandLine "${findSdkDir()}/platform-tools/adb", 'shell', 'am', 'start', '-n', 'io.anuke.mindustry/mindustry.android.AndroidLauncher'
}
2021-04-21 08:07:46 +07:00
if(!project.ext.hasSprites()){
tasks.whenTaskAdded{ task ->
if(task.name == 'assembleDebug' || task.name == 'assembleRelease'){
task.dependsOn ":tools:pack"
}
}
}