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.
298 lines
10 KiB
298 lines
10 KiB
/*
|
|
* Copyright (c) 2020 Cobo
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* in the file COPYING. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
import groovy.xml.XmlUtil
|
|
|
|
import java.security.MessageDigest
|
|
|
|
apply plugin: 'com.android.application'
|
|
apply plugin: 'com.google.protobuf'
|
|
|
|
/**
|
|
* Set this to true to create two separate APKs instead of one:
|
|
* - An APK that only works on ARM devices
|
|
* - An APK that only works on x86 devices
|
|
* The advantage is the size of the APK is reduced by about 4MB.
|
|
* Upload all the APKs to the Play Store and people will download
|
|
* the correct one based on the CPU architecture of their device.
|
|
*/
|
|
def enableSeparateBuildPerCPUArchitecture = false
|
|
|
|
/**
|
|
* Run Proguard to shrink the Java bytecode in release builds.
|
|
*/
|
|
def enableProguardInReleaseBuilds = true
|
|
android {
|
|
compileSdkVersion rootProject.compileSdkVersion
|
|
buildToolsVersion rootProject.buildToolsVersion
|
|
|
|
def (mIsVaultRelease, mVersionNumber, mVersionName) = getVersionProperties()
|
|
println("start to build ${mVersionName}")
|
|
println("start to build ${getGitHash()}")
|
|
|
|
defaultConfig {
|
|
applicationId "com.cobo.cold"
|
|
minSdkVersion rootProject.minSdkVersion
|
|
targetSdkVersion rootProject.targetSdkVersion
|
|
versionCode mVersionNumber
|
|
versionName mVersionName
|
|
ndk {
|
|
abiFilters "armeabi-v7a"
|
|
}
|
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
javaCompileOptions {
|
|
annotationProcessorOptions {
|
|
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
splits {
|
|
abi {
|
|
reset()
|
|
enable enableSeparateBuildPerCPUArchitecture
|
|
universalApk false // If true, also generate a universal APK
|
|
include "armeabi-v7a", "x86"
|
|
}
|
|
}
|
|
|
|
dataBinding {
|
|
enabled = true
|
|
}
|
|
|
|
signingConfigs {
|
|
vault_v2 {
|
|
def key = getReleaseKeystore()
|
|
storeFile key.store
|
|
storePassword key.storePassword
|
|
keyAlias key.alias
|
|
keyPassword key.keyPassword
|
|
}
|
|
}
|
|
|
|
buildTypes {
|
|
release {
|
|
debuggable false
|
|
minifyEnabled enableProguardInReleaseBuilds
|
|
shrinkResources enableProguardInReleaseBuilds
|
|
proguardFiles getDefaultProguardFile('proguard-android.txt')
|
|
proguardFiles 'proguard-rules.pro'
|
|
}
|
|
}
|
|
compileOptions {
|
|
sourceCompatibility = '1.8'
|
|
targetCompatibility = '1.8'
|
|
}
|
|
|
|
flavorDimensions 'machine'
|
|
|
|
productFlavors {
|
|
vault_v2 {
|
|
dimension 'machine'
|
|
ndk {
|
|
abiFilters "armeabi-v7a"
|
|
}
|
|
manifestPlaceholders = ["sharedUserId": 'android.uid.system']
|
|
buildConfigField "String", "GIT_HASH", "\"${getGitHash()}\""
|
|
buildConfigField "String", "UPDATE_PUBLIC_KEY", "\"308201a2300d06092a864886f70d01010105000382018f003082018a0282018100df75e9c2f82e9113e93cf5cf1739436694f12b9009c6bc37156f3cc30f259f3a0661bdd223a833d39a468161751c58a870f25022c619a4010b49058ae23c2b67dab4d6e3cb92a119a0de326303dbad67b33c79a8a1643db6f1a5e955bc7d4de6e9080780df37ac0bc8ad32e9b013e467f04bf0ab158059f5bd728b822456b728b7ec0ba894433f309a7f17fda5df463b09ecc8af5dfbb1159127aaee393696bfb5291353522a5428897824904f25f0b61453d295fd920303e2f72928e17212cbb11d0c701e13029761c570cc46c6fa1ddbbc973864595d860ebbca03bdb9e70136f09210e94e614df988a2dac7bfcc9acb997ed01ab4f75cbf02336c6a753a4ec6b517e0ec84f260d61a4e00ee56d9e152bd8b9a2f0a48846993bd95e2db308c23aedc2e527b532228661c6fb63e2b0dd0900b2a1a36a6d046d64a3a59fef9c566771fd541b5cdb074effd02574a6b5eaa1194e8fc1f2f835657ac9a72a20412e446b3a47105ee65745e6b816b906ef34545fe6fb4aaadc37703e6f599dc6d370203010001\""
|
|
signingConfig signingConfigs.vault_v2
|
|
}
|
|
}
|
|
if (mIsVaultRelease) {
|
|
afterEvaluate {
|
|
task copyRelease(type: Copy) {
|
|
from "${buildDir}/outputs/apk/vault_v2/release"
|
|
into "${rootDir}/releases/${mVersionNumber}"
|
|
include '*.apk'
|
|
}
|
|
|
|
task archiveMapping(type: Zip) {
|
|
from "${buildDir}/outputs/mapping/vault_v2/release"
|
|
destinationDir file("${rootDir}/releases/${mVersionNumber}")
|
|
include '*'
|
|
archiveName "mapping_${mVersionNumber}.zip"
|
|
}
|
|
|
|
assembleVault_v2Release.finalizedBy(copyRelease, archiveMapping)
|
|
}
|
|
|
|
this.gradle.buildFinished {
|
|
def apkPath = "${rootDir}/releases/${mVersionNumber}/app-vault_v2-release.apk"
|
|
def apk = file(apkPath)
|
|
exec {
|
|
commandLine 'mv', apkPath,
|
|
"${rootDir}/releases/${mVersionNumber}/app_${mVersionNumber}_V${mVersionName}_${getGitHash()}_${calcSha1(apk)}.apk"
|
|
}
|
|
}
|
|
}
|
|
sourceSets {
|
|
main {
|
|
proto {
|
|
srcDir 'src/main/protos'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
compileOnly files('libs/cvos.jar')
|
|
implementation 'androidx.appcompat:appcompat:1.1.0'
|
|
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
|
implementation 'androidx.navigation:navigation-fragment:2.2.0-rc04'
|
|
implementation 'androidx.navigation:navigation-ui:2.2.0-rc04'
|
|
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
|
|
implementation 'androidx.room:room-runtime:2.1.0'
|
|
implementation "androidx.preference:preference:1.1.0"
|
|
implementation 'com.google.android.material:material:1.0.0'
|
|
implementation 'com.google.protobuf:protobuf-java:3.7.1'
|
|
implementation 'com.google.zxing:core:3.3.3'
|
|
implementation 'com.googlecode.protobuf-java-format:protobuf-java-format:1.4'
|
|
implementation 'com.madgag.spongycastle:core:1.58.0.0@jar'
|
|
implementation 'com.yanzhenjie:permission:2.0.0-rc4'
|
|
implementation 'cn.carbswang.android:NumberPickerView:1.2.0'
|
|
implementation 'com.andrognito.patternlockview:patternlockview:1.0.0'
|
|
implementation 'com.allenliu.badgeview:library:1.1.1'
|
|
implementation 'net.lingala.zip4j:zip4j:1.3.2@jar'
|
|
implementation 'com.wei.android.lib:fingerprintidentify:1.2.6'
|
|
implementation 'com.github.donkingliang:ConsecutiveScroller:2.5.0'
|
|
annotationProcessor 'androidx.room:room-compiler:2.1.0'
|
|
|
|
implementation project(':encryption-core')
|
|
implementation project(path: ':coinlib')
|
|
testImplementation 'junit:junit:4.12'
|
|
testImplementation 'org.json:json:20140107'
|
|
androidTestImplementation 'androidx.test:runner:1.2.0'
|
|
androidTestImplementation 'junit:junit:4.12'
|
|
|
|
}
|
|
|
|
preBuild {
|
|
doLast {
|
|
def imlFile = file(project.name + ".iml")
|
|
println 'Change ' + project.name + '.iml order'
|
|
try {
|
|
def parsedXml = (new XmlParser()).parse(imlFile)
|
|
def jdkNode = parsedXml.component[1].orderEntry.find { it.'@type' == 'jdk' }
|
|
parsedXml.component[1].remove(jdkNode)
|
|
def sdkString = "Android API " + android.compileSdkVersion.substring("android-".length()) + " Platform"
|
|
//noinspection GroovyResultOfObjectAllocationIgnored
|
|
new Node(parsedXml.component[1], 'orderEntry', ['type': 'jdk', 'jdkName': sdkString, 'jdkType': 'Android SDK'])
|
|
XmlUtil.serialize(parsedXml, new FileOutputStream(imlFile))
|
|
} catch (FileNotFoundException ignored) {
|
|
// nop, iml not found
|
|
}
|
|
}
|
|
}
|
|
|
|
task copyDownloadableDepsToLibs(type: Copy) {
|
|
from configurations.compile
|
|
into 'libs'
|
|
}
|
|
|
|
def getVersionProperties() {
|
|
def versionPropsFile = file('version.properties')
|
|
def versionProps = new Properties()
|
|
|
|
if (versionPropsFile.exists()) {
|
|
if (versionPropsFile.canRead()) {
|
|
versionProps.load(new FileInputStream(versionPropsFile))
|
|
} else {
|
|
throw new GradleException("could not read version.properties!")
|
|
}
|
|
}
|
|
|
|
def versionMajor = 1
|
|
def versionMinor = 2
|
|
def versionPatch = versionProps.getProperty('patch', '0').toInteger()
|
|
def isVaultRelease = false
|
|
|
|
gradle.startParameter.taskNames.each {
|
|
if (it.contains("assembleVaultRelease") || it.contains("assembleVault_v2Release")) {
|
|
isVaultRelease = true
|
|
return
|
|
}
|
|
}
|
|
|
|
def versionNumber = versionMajor * 10000 + versionMinor * 100 + versionPatch
|
|
def versionName = "${versionMajor}.${versionMinor}.${versionPatch}"
|
|
|
|
return [isVaultRelease, versionNumber, versionName]
|
|
}
|
|
|
|
def getReleaseKeystore() {
|
|
|
|
def keystoreDir = new File(rootDir, "keystores")
|
|
if (!keystoreDir.exists()) {
|
|
throw new FileNotFoundException("could not find ${keystoreDir}")
|
|
}
|
|
|
|
def keystorePropsFile = new File(keystoreDir, "test.properties")
|
|
if (!keystorePropsFile.exists()) {
|
|
throw new FileNotFoundException("could not find ${keystorePropsFile}")
|
|
}
|
|
|
|
def keystoreProps = new Properties()
|
|
keystoreProps.load(new FileInputStream(keystorePropsFile))
|
|
|
|
def keystoreFile = new File(keystoreDir, keystoreProps['key.store'])
|
|
if (!keystoreFile.exists()) {
|
|
throw new FileNotFoundException("could not find ${keystoreFile}")
|
|
}
|
|
|
|
return [
|
|
store : keystoreFile,
|
|
alias : keystoreProps['key.alias'],
|
|
storePassword: keystoreProps['key.store.password'],
|
|
keyPassword : keystoreProps['key.alias.password']
|
|
].asImmutable()
|
|
}
|
|
|
|
def getGitHash() {
|
|
def stdout = new ByteArrayOutputStream()
|
|
exec {
|
|
commandLine 'git', 'rev-parse', '--short=40', 'HEAD'
|
|
standardOutput = stdout
|
|
}
|
|
return stdout.toString().trim()
|
|
}
|
|
|
|
static def calcSha1(file) {
|
|
MessageDigest md = MessageDigest.getInstance("SHA-1")
|
|
file.eachByte 4096, { bytes, size ->
|
|
md.update(bytes, 0, size)
|
|
}
|
|
return md.digest().collect { String.format "%02x", it }.join()
|
|
}
|
|
|
|
protobuf {
|
|
|
|
protoc {
|
|
artifact = 'com.google.protobuf:protoc:3.7.1'
|
|
}
|
|
|
|
generateProtoTasks {
|
|
all().each { task ->
|
|
task.builtins {
|
|
remove java
|
|
}
|
|
task.builtins {
|
|
java {}
|
|
}
|
|
}
|
|
}
|
|
}
|