Mindustry/android/build.gradle

146 lines
4.1 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
jcenter()
}
2019-04-08 20:03:18 +07:00
dependencies{
2020-06-03 09:09:41 +07:00
//IMPORTANT NOTICE: any version of the plugin after 3.4.1 will break builds for every API level < 24, perhaps even higher.
//it appears abstract methods don't get desugared properly (if at all)
2019-08-23 08:51:56 +07:00
classpath 'com.android.tools.build:gradle:3.4.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()
2017-12-12 11:48:37 +07:00
jcenter()
2020-04-30 05:29:19 +07:00
maven{ url "https://maven.google.com" }
2017-12-12 11:48:37 +07:00
}
2019-04-08 20:03:18 +07:00
dependencies{
implementation project(":core")
2018-12-29 23:59:43 +07:00
implementation arcModule("backends:backend-android")
implementation 'com.jakewharton.android.repackaged:dalvik-dx:9.0.0_r3'
2020-04-30 05:29:19 +07:00
natives "com.github.Anuken.Arc:natives-android:${getArcHash()}"
natives "com.github.Anuken.Arc:natives-freetype-android:${getArcHash()}"
2020-05-01 09:56:43 +07:00
natives "com.github.Anuken.Arc:natives-box2d-android:${getArcHash()}"
2017-12-12 11:48:37 +07:00
}
task deploy(type: Copy){
dependsOn "assembleRelease"
from "build/outputs/apk/release/android-release.apk"
2018-10-06 22:56:39 +07:00
into "../deploy/"
2019-08-16 22:00:15 +07:00
rename("android-release.apk", "${generateDeployName('android')}.apk")
}
2019-04-08 20:03:18 +07:00
android{
2020-05-27 06:39:50 +07:00
buildToolsVersion '29.0.3'
2019-08-29 03:18:53 +07:00
compileSdkVersion 29
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
}
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
2019-08-29 03:18:53 +07:00
targetSdkVersion 29
2019-08-26 09:02:00 +07:00
2018-04-26 07:53:32 +07:00
versionName versionNameResult
2019-08-26 09:02:00 +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
}else{
2018-10-06 22:56:39 +07:00
println("No keystore info property found!")
2018-02-09 22:14:29 +07:00
}
}
}
if(project.hasProperty("RELEASE_STORE_FILE")) {
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
2017-06-29 11:54:10 +07:00
}
// called every time gradle gets executed, takes the native dependencies of
// the natives configuration, and extracts them to the proper libs/ folders
// so they get packed with the APK.
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){
2017-06-29 11:54:10 +07:00
def path
def localProperties = project.file("../local.properties")
2019-04-08 20:03:18 +07:00
if(localProperties.exists()){
2017-06-29 11:54:10 +07:00
Properties properties = new Properties()
2019-04-08 20:03:18 +07:00
localProperties.withInputStream{ instr ->
2017-06-29 11:54:10 +07:00
properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
2019-04-08 20:03:18 +07:00
if(sdkDir){
2017-06-29 11:54:10 +07:00
path = sdkDir
2019-04-08 20:03:18 +07:00
}else{
2017-06-29 11:54:10 +07:00
path = "$System.env.ANDROID_HOME"
}
2019-04-08 20:03:18 +07:00
}else{
2017-06-29 11:54:10 +07:00
path = "$System.env.ANDROID_HOME"
}
def adb = path + "/platform-tools/adb"
2019-12-26 00:06:19 +07:00
commandLine "$adb", 'shell', 'am', 'start', '-n', 'io.anuke.mindustry/mindustry.android.AndroidLauncher'
}