You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

157 lines
4.2 KiB

apply plugin: 'org.greenrobot.greendao'
apply plugin: 'com.android.application'
def getVersionCode = { ->
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-list', '--all', '--count'
standardOutput = stdout
}
return Integer.parseInt(stdout.toString().trim())
}
catch (ignored) {
return -1;
}
}
def getVersionName = { ->
def ver = 'v0.5.2'
return ver;
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags', '--always', '--dirty', '--match', 'hin2n_v*'
standardOutput = stdout
}
return stdout.toString().trim()
}
catch (ignored) {
return null;
}
}
def getEnvOrConsole = { env, prompt ->
def val = null
try {
val = System.getenv(env)
if (val == null || val == "") {
if (System.console() != null) {
val = System.console().readLine("\n" + prompt + ": ")
}
}
} catch (ignored) {
return null
}
return val
}
android {
compileSdkVersion 25
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "wang.switchy.hin2n"
minSdkVersion 14
targetSdkVersion 25
versionCode getVersionCode()
versionName getVersionName()
multiDexEnabled true
manifestPlaceholders = [CHANNEL_VALUE: "normal", ARCH: "all"]
resConfigs "en", "zh-rCN", "zh-rTW"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags ""
}
}
}
signingConfigs {
debug {}
release {
storeFile file("Hin2n.jks")
storePassword "yourpassword"
keyAlias "Hin2nalias"
keyPassword "yourpassword"
}
}
buildTypes {
debug {
buildConfigField("boolean", "API_DEBUG", "true")
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
buildConfigField("boolean", "API_DEBUG", "false")
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
applicationVariants.all { variant ->
variant.outputs.all { output ->
def outputFile = output.outputFile
def fileName = null
if (outputFile != null && outputFile.name.endsWith('.apk')) {
variant.mergedFlavor.versionName = getVersionName()
def channel = variant.mergedFlavor.manifestPlaceholders.CHANNEL_VALUE
def arch = variant.mergedFlavor.manifestPlaceholders.ARCH
fileName = "hin2n_${variant.mergedFlavor.versionName}_${channel}_${arch}_${variant.buildType.name}.apk"
outputFileName = fileName
}
}
}
flavorDimensions "channel", "arch"
productFlavors {
normal {
dimension "channel"
manifestPlaceholders += [CHANNEL_VALUE: "normal"]
}
arm {
dimension "arch"
ndk {
abiFilters "armeabi-v7a", "arm64-v8a"
manifestPlaceholders += [ARCH: "arm"]
}
}
x86 {
dimension "arch"
ndk {
abiFilters "x86", "x86_64"
manifestPlaceholders += [ARCH: "x86"]
}
}
}
}
greendao {
schemaVersion 1
daoPackage 'wang.switchy.hin2n.storage.db.base'
targetGenDir 'src/main/java'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:design:25.4.0'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:25.+'
implementation 'org.greenrobot:eventbus:3.1.1'
implementation 'org.greenrobot:greendao:3.2.0'
}