-
Notifications
You must be signed in to change notification settings - Fork 224
/
Copy pathbuild.gradle
executable file
·107 lines (88 loc) · 3.27 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import java.util.regex.Matcher
apply plugin: 'com.android.library'
def versionName() {
String config = getProjectDir().getPath() + '/src/main/java/com/qiniu/android/common/Constants.java'
String fileContents = new File(config).text
Matcher myMatcher = fileContents =~ /VERSION = "(.+)";/
String version = myMatcher[0][1]
println(version)
return version
}
def versionNameToCode(String version) {
String v = version.replaceAll(/\./, '')
return v.toLong()
}
String version = versionName()
int code = versionNameToCode(version)
android {
compileSdkVersion 33
// buildToolsVersion '29.0.3'
defaultConfig {
//applicationId "com.qiniu.android"
minSdkVersion 14
targetSdkVersion 33
versionCode code
versionName version
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
testCoverageEnabled = true
}
}
lintOptions {
warning 'InvalidPackage'
}
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
ndkVersion '20.0.5594570'
// useLibrary 'android.test.runner'
// useLibrary 'android.test.base'
// useLibrary 'android.test.mock'
}
dependencies {
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
implementation 'com.qiniu:happy-dns:2.0.1'
// for javax.annotation.Nullable use in custom MultipartBody and Headers implements.
// implementation 'com.google.code.findbugs:jsr305:3.0.2'
implementation 'org.conscrypt:conscrypt-android:2.2.1'
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
// androidTestImplementation "androidx.test:runner:1.4.0"
// androidTestImplementation "androidx.test:core:1.4.0"
// androidTestImplementation "androidx.test:rules:1.4.0"
// androidTestImplementation 'org.testng:testng:6.9.6'
androidTestCompileOnly project(path: ':library')
// androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
task releaseJar(type: Jar, dependsOn: 'build') {
//指定生成的jar名
baseName('qiniu-android-sdk-' + version)
//从哪里打包class文件
// from('build/intermediates/classes/release/com/qiniu/android/dns/')
//打包到jar后的目录结构
// into('com/qiniu/android/dns/')
//去掉不需要打包的目录和文件
exclude('test/', 'BuildConfig.class', 'R.class')
//去掉R$开头的文件
exclude { it.name.startsWith('R$') }
}
android.libraryVariants.all { variant ->
def name = variant.buildType.name
def task = project.tasks.create "jar${name.capitalize()}", Jar
task.dependsOn variant.javaCompileProvider
task.from variant.javaCompileProvider.get().destinationDir
task.exclude '**/R.*', '**/R$*.*', '**/BuildConfig.class'
artifacts.add('archives', task)
}
setProperty('VERSION_NAME', version)
setProperty('VERSION_CODE', code)
apply from: '../mvn_push.gradle'