build.gradle
1.46 KB
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
import java.util.regex.Matcher
apply plugin: 'com.android.library'
def versionName() {
return "0.1.1"
}
def versionNameToCode(String version) {
String v = version.replaceAll(/\./, '')
return v.toLong()
}
String version = versionName()
int code = versionNameToCode(version)
android {
compileSdkVersion 26
buildToolsVersion '27.0.0'
defaultConfig {
//applicationId "com.qiniu.android"
minSdkVersion 9
targetSdkVersion 24
versionCode code
versionName version
}
lintOptions {
warning 'InvalidPackage'
}
}
dependencies {
// compile 'com.android.support:appcompat-v7:21.0.3'
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
}
task releaseJar(type: Jar, dependsOn: 'build') {
//指定生成的jar名
baseName 'android-netdiag-' + version
//去掉不需要打包的目录和文件
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.javaCompile
task.from variant.javaCompile.destinationDir
task.exclude '**/R.*', '**/R$*.*', '**/BuildConfig.class'
artifacts.add('archives', task);
}
//setProperty('VERSION_NAME', version)
//setProperty('VERSION_CODE', code)
//apply from: '../mvn_push.gradle'