-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathbuild.gradle
162 lines (145 loc) · 6.23 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 31
buildToolsVersion "26.0.3"
defaultConfig {
minSdkVersion 15
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
kotlinOptions {
jvmTarget = '1.8'
}
}
task androidJavadocs(type: Javadoc) {
failOnError false
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
android.libraryVariants.all { variant ->
if (variant.name == 'release') {
owner.classpath += variant.javaCompile.classpath
}
}
exclude '**/R.html', '**/R.*.html', '**/index.html'
}
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
classifier = 'javadoc'
from androidJavadocs.destinationDir
}
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
def libVersion = rootProject.ext.sdk.version
ext.isReleaseVersion = !libVersion.endsWith("SNAPSHOT")
publishing {
publications {
aar(MavenPublication) {
groupId 'com.tencent.iot.explorer'
artifactId 'explorer-device-android'
version libVersion
artifact(androidSourcesJar)
artifact(androidJavadocsJar)
artifact file('build/outputs/aar/explorer-device-android-release.aar')
pom {
name = 'explorer device android'
description = 'Explorer Device Android library'
url = 'https://github.com/tencentyun/iot-device-java/tree/master/explorer/explorer-device-android'
licenses {
license {
name = 'Tencent Binary License'
url = 'https://github.com/tencentyun/iot-device-java/blob/master/explorer/explorer-device-android/LICENSE'
}
}
developers {
developer {
id = 'tencent_archurtan'
name = 'Tencent archurtan'
email = '[email protected]'
}
}
scm {
url = 'scm:[email protected]:tencentyun/iot-device-java.git'
connection = 'scm:[email protected]:tencentyun/iot-device-java.git'
developerConnection = 'scm:[email protected]:tencentyun/iot-device-java.git'
}
}
pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')
configurations.implementation.allDependencies.withType(ModuleDependency) { ModuleDependency dp ->
if (dp.version != "unspecified") {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', dp.group)
dependencyNode.appendNode('artifactId', dp.name)
dependencyNode.appendNode('version', dp.version)
// for exclusions
if (dp.excludeRules.size() > 0) {
def exclusions = dependencyNode.appendNode('exclusions')
dp.excludeRules.each { ExcludeRule ex ->
def exclusion = exclusions.appendNode('exclusion')
exclusion.appendNode('groupId', ex.group)
exclusion.appendNode('artifactId', ex.module)
}
}
}
}
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', "com.tencent.iot.explorer")
dependencyNode.appendNode('artifactId', "explorer-device-java")
dependencyNode.appendNode('version', "${rootProject.ext.sdk.version}")
def dependencyNodehub = dependenciesNode.appendNode('dependency')
dependencyNodehub.appendNode('groupId', "com.tencent.iot.hub")
dependencyNodehub.appendNode('artifactId', "hub-device-android")
dependencyNodehub.appendNode('version', "${rootProject.ext.sdk.version}")
}
}
}
repositories {
maven {
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
url = libVersion.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = System.getenv("IOT_SONATYPE_USERNAME")
password = System.getenv("IOT_SONATYPE_PASSWORD")
}
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.13'
// Optional -- Mockito framework(可选,用于模拟一些依赖对象,以达到隔离依赖的效果)
testImplementation 'org.mockito:mockito-core:2.19.0'
testImplementation "androidx.test.ext:junit:1.1.3"
testImplementation "org.robolectric:robolectric:4.5.1"
if (findProject(':explorer:explorer-device-java') != null) {
api project(path: ':explorer:explorer-device-java')
}
if (findProject(':hub:hub-device-android') != null) {
api project(path: ':hub:hub-device-android')
}
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.alibaba:fastjson:2.0.31'
}
signing {
if (isReleaseVersion) {
sign publishing.publications.aar
}
}