1
+ import java.security.MessageDigest
2
+
3
+ apply plugin : ' com.android.application'
4
+
5
+ android {
6
+ compileSdk 28
7
+
8
+ defaultConfig {
9
+ applicationId " com.baidu.paddle.fastdeploy"
10
+ minSdkVersion 15
11
+ // noinspection ExpiredTargetSdkVersion
12
+ targetSdkVersion 28
13
+ versionCode 1
14
+ versionName " 1.0"
15
+ testInstrumentationRunner " android.support.test.runner.AndroidJUnitRunner"
16
+
17
+ externalNativeBuild {
18
+ cmake {
19
+ arguments ' -DANDROID_PLATFORM=android-21' , ' -DANDROID_STL=c++_shared' , " -DANDROID_TOOLCHAIN=clang"
20
+ abiFilters ' armeabi-v7a' , ' arm64-v8a'
21
+ cppFlags " -std=c++11"
22
+ }
23
+ }
24
+ }
25
+
26
+ buildTypes {
27
+ release {
28
+ minifyEnabled false
29
+ proguardFiles getDefaultProguardFile(' proguard-android-optimize.txt' ), ' proguard-rules.pro'
30
+ }
31
+ }
32
+
33
+ externalNativeBuild {
34
+ cmake {
35
+ path file(' src/main/cpp/CMakeLists.txt' )
36
+ version ' 3.10.2'
37
+ }
38
+ }
39
+ ndkVersion ' 20.1.5948944'
40
+ }
41
+
42
+ dependencies {
43
+ implementation fileTree(include : [' *.jar' ], dir : ' libs' )
44
+ implementation ' com.android.support:appcompat-v7:28.0.0'
45
+ // noinspection GradleDependency
46
+ implementation ' com.android.support.constraint:constraint-layout:1.1.3'
47
+ implementation ' com.android.support:design:28.0.0'
48
+ implementation ' org.jetbrains:annotations:15.0'
49
+ // noinspection GradleDependency
50
+ testImplementation ' junit:junit:4.12'
51
+ androidTestImplementation ' com.android.support.test:runner:1.0.2'
52
+ androidTestImplementation ' com.android.support.test.espresso:espresso-core:3.0.2'
53
+ }
54
+
55
+ def archives = [
56
+ [
57
+ ' src' : ' https://bj.bcebos.com/fastdeploy/release/android/fastdeploy-android-0.4.0-shared.tgz' ,
58
+ ' dest' : ' libs'
59
+ ],
60
+ [
61
+ ' src' : ' https://bj.bcebos.com/paddlehub/fastdeploy/MobileNetV1_x0_25_infer.tgz' ,
62
+ ' dest' : ' src/main/assets/models'
63
+ ]
64
+ ]
65
+
66
+ task downloadAndExtractArchives (type : DefaultTask ) {
67
+ doFirst {
68
+ println " Downloading and extracting archives including libs and models"
69
+ }
70
+ doLast {
71
+ // Prepare cache folder for archives
72
+ String cachePath = " cache"
73
+ if (! file(" ${ cachePath} " ). exists()) {
74
+ mkdir " ${ cachePath} "
75
+ }
76
+ archives. eachWithIndex { archive , index ->
77
+ MessageDigest messageDigest = MessageDigest . getInstance(' MD5' )
78
+ messageDigest. update(archive. src. bytes)
79
+ String cacheName = new BigInteger (1 , messageDigest. digest()). toString(32 )
80
+ // Download the target archive if not exists
81
+ boolean copyFiles = ! file(" ${ archive.dest} " ). exists()
82
+ if (! file(" ${ cachePath} /${ cacheName} .tgz" ). exists()) {
83
+ ant. get(src : archive. src, dest : file(" ${ cachePath} /${ cacheName} .tgz" ))
84
+ copyFiles = true // force to copy files from the latest archive files
85
+ }
86
+ // Extract the target archive if its dest path does not exists
87
+ if (copyFiles) {
88
+ copy {
89
+ from tarTree(" ${ cachePath} /${ cacheName} .tgz" )
90
+ into " ${ archive.dest} "
91
+ }
92
+ }
93
+ }
94
+ }
95
+ }
96
+ preBuild. dependsOn downloadAndExtractArchives
0 commit comments