Mindustry/android/build.gradle

193 lines
6.0 KiB
Groovy
Raw Normal View History

2018-10-30 03:02:09 +07:00
buildscript {
repositories {
mavenLocal()
mavenCentral()
google()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
}
dependencies {
2019-03-10 11:55:01 +07:00
classpath 'com.android.tools.build:gradle:3.3.2'
2018-10-30 03:02:09 +07:00
}
}
2017-12-12 11:48:37 +07:00
apply plugin: "com.android.application"
configurations { natives }
2017-12-12 11:48:37 +07:00
repositories {
mavenCentral()
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
implementation project(":core")
2018-12-27 05:38:40 +07:00
implementation project(":net")
2018-12-29 23:59:43 +07:00
implementation arcModule("backends:backend-android")
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
2018-11-07 00:55:13 +07:00
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
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-04-05 07:39:04 +07:00
rename ("android-release.apk", appName + "-android-" + getVersionString() + ".apk")
}
2017-06-29 11:54:10 +07:00
android {
2018-10-16 03:31:01 +07:00
buildToolsVersion '28.0.3'
2018-10-07 22:14:54 +07:00
compileSdkVersion 28
2017-06-29 11:54:10 +07:00
sourceSets {
main {
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
}
packagingOptions {
exclude 'META-INF/robovm/ios/robovm.xml'
}
2017-06-29 11:54:10 +07:00
defaultConfig {
def vfile = file('../core/assets/version.properties')
2018-04-26 07:53:32 +07:00
def code = 0
def versionNameResult = "unknown"
if(vfile.exists()){
def props = new Properties()
props.load(new FileInputStream(vfile))
code = (props['androidBuildCode'] == null ? 0 : props['androidBuildCode']).toInteger() + 1
props['androidBuildCode'] = code.toString()
props.store(vfile.newWriter(), "Autogenerated file. Do not modify.")
versionNameResult = "$versionNumber-$versionType-${props['build'].replace(" ", "-")}"
}
2017-06-29 11:54:10 +07:00
applicationId "io.anuke.mindustry"
minSdkVersion 14
2018-11-25 07:39:35 +07:00
targetSdkVersion 28
versionCode code
2018-04-26 07:53:32 +07:00
versionName versionNameResult
2017-06-29 11:54:10 +07:00
}
compileOptions {
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"
signingConfigs {
release {
2018-02-09 22:14:29 +07:00
if(project.hasProperty("RELEASE_STORE_FILE")) {
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
}
}
}
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.
task copyAndroidNatives() {
2018-10-06 22:56:39 +07:00
file("libs/armeabi/").mkdirs()
file("libs/armeabi-v7a/").mkdirs()
file("libs/arm64-v8a/").mkdirs()
file("libs/x86_64/").mkdirs()
file("libs/x86/").mkdirs()
2017-06-29 11:54:10 +07:00
configurations.natives.files.each { jar ->
def outputDir = null
if (jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
if (jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
if (jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
if (jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
if (outputDir != null) {
copy {
from zipTree(jar)
into outputDir
include "*.so"
}
}
}
}
2018-10-07 22:14:54 +07:00
2017-06-29 11:54:10 +07:00
task run(type: Exec) {
def path
def localProperties = project.file("../local.properties")
if (localProperties.exists()) {
Properties properties = new Properties()
localProperties.withInputStream { instr ->
properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
if (sdkDir) {
path = sdkDir
} else {
path = "$System.env.ANDROID_HOME"
}
} else {
path = "$System.env.ANDROID_HOME"
}
def adb = path + "/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', 'io.anuke.mindustry/io.anuke.mindustry.AndroidLauncher'
}
// sets up the Android Idea project, using the old Ant based build.
idea {
module {
2018-10-06 22:56:39 +07:00
sourceDirs += file("src")
2017-06-29 11:54:10 +07:00
scopes = [COMPILE: [plus: [project.configurations.compile]]]
iml {
withXml {
def node = it.asNode()
2018-10-06 22:56:39 +07:00
def builder = NodeBuilder.newInstance()
builder.current = node
2017-06-29 11:54:10 +07:00
builder.component(name: "FacetManager") {
facet(type: "android", name: "Android") {
configuration {
option(name: "UPDATE_PROPERTY_FILES", value: "true")
}
}
}
}
}
}
2017-12-21 11:03:23 +07:00
}