forked from AltBeacon/android-beacon-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
190 lines (155 loc) · 5.39 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
ext {
isSnapshot = !project.hasProperty('release')
isSnapCi = System.getenv('SNAP_CI') != null
isSnapPullRequest = System.getenv('SNAP_PULL_REQUEST_NUMBER') != null
}
/*
* Gets the version name from the latest Git tag
*/
def getVersionName = {
def stdout = new ByteArrayOutputStream()
try {
exec {
commandLine 'git', 'describe', '--tags'
standardOutput = stdout
}
return stdout.toString().trim()
}
catch (e) {
println("Can't get version from git: " + e);
return "adhoc"
}
}
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
//noinspection GradleDependency
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
//noinspection GradleDependency
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:3.0.3'
}
}
apply plugin: 'com.android.library'
apply from: 'gradle/eclipse.gradle'
allprojects {
version = "${getVersionName()}${isSnapshot ? "-SNAPSHOT" : ""}"
group = "org.altbeacon"
repositories {
google()
jcenter()
}
}
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
// Unfortunately 'com.android.support:appcompat-v7:26.0.0'
// requires minSdkVersion 14, forcing a bump verson minSdkVersion 7
// But since only 0.8% of Android devices have < SDK 14 as of Une 2017, this will become
// the new min version for this library in order to target Android O
minSdkVersion 14
targetSdkVersion 28
versionCode 1
versionName version
consumerProguardFiles 'proguard-rules.pro'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
compileOptions {
encoding "UTF-8"
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
lintOptions {
abortOnError false
}
packagingOptions {
exclude 'LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE'
}
testOptions {
execution 'ANDROID_TEST_ORCHESTRATOR'
animationsDisabled true
unitTests {
includeAndroidResources = true
}
}
}
configurations {
doclava
}
dependencies {
implementation fileTree ( dir: 'libs', include: ['*.jar'] )
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:support-annotations:28.0.0'
testImplementation 'junit:junit:4.12'
testImplementation 'org.robolectric:robolectric:4.1'
testImplementation 'com.google.android:android-test:4.1.1.4'
testImplementation 'com.squareup:fest-android:1.0.8@aar'
testImplementation 'org.mockito:mockito-core:2.23.4'
androidTestUtil 'com.android.support.test:orchestrator:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'org.apache.commons:commons-math3:3.6.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
doclava 'com.google.doclava:doclava:1.0.6'
}
apply plugin: 'idea'
idea {
module {
testOutputDir = file('build/test-classes/debug')
}
}
task renameAarForRelease(type: Copy, dependsOn: build) {
description = "Rename the aar for easy release publishing"
from "$buildDir/outputs/aar/" //${project.name}-release.aar
into "$buildDir/outputs/aar/" //${project.name}-${project.version}.aar"
include "${project.name}-release.aar"
rename { String fileName ->
fileName = "${project.name}-${project.version}.aar"
}
}
task distribution(dependsOn: [bundleEclipse, build, clean, renameAarForRelease]) << {
println "Building with version=$version"
}
task release(dependsOn: 'distribution') << {
println('Doing release build')
}
android.libraryVariants.all { variant ->
task("generate${variant.name}Javadoc", type: Javadoc) {
title = "Android Beacon Library $version API"
description "Generates Javadoc for $variant.name."
source = variant.javaCompile.source
ext.androidJar =
"${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
//Refer to https://stackoverflow.com/a/50833438/4068957
doFirst { classpath = files(variant.javaCompile.classpath.files, ext.androidJar)}
options.linksOffline "http://d.android.com/reference/", "${android.sdkDirectory}/docs/reference"
exclude '**/BuildConfig.java'
exclude '**/R.java'
}
}
task generateJavadoc(type: Javadoc, dependsOn: project.configurations.doclava) {
failOnError = true
title = null
source = android.sourceSets.main.java.srcDirs
options.doclet = "com.google.doclava.Doclava"
options.docletpath = configurations.doclava.files.asType(List)
classpath +=
project.files(android.getBootClasspath().join(File.pathSeparator)) + configurations.compile
destinationDir = file("../javadocs/")
}
build.mustRunAfter clean
apply from: 'gradle/credentials.gradle'
apply from: 'gradle/compile.gradle'
apply from: 'gradle/publishing.gradle'
apply from: 'gradle/bintray.gradle'
apply from: 'gradle/artifactory.gradle'
artifactoryPublish {
// Skip deploying to artifactory if building a pull request
onlyIf { !isSnapPullRequest }
}