/
build.gradle
302 lines (271 loc) · 10.6 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
import org.gradle.internal.os.OperatingSystem
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
version = mdcLibraryVersion
dependencies {
api compatibility("activity")
api compatibility("annotation")
api compatibility("appcompat")
api compatibility("cardview")
api compatibility("coordinatorlayout")
api compatibility("constraintlayout")
api compatibility("core")
api compatibility("drawerlayout")
api compatibility("dynamicanimation")
api compatibility("experimental")
api compatibility("fragment")
api compatibility("lifecycleRuntime")
api compatibility("recyclerview")
api compatibility("resourceInspectionAnnotation")
api compatibility("transition")
api compatibility("vectordrawable")
api compatibility("viewpager2")
annotationProcessor compatibility("resourceInspectionProcessor")
implementation "com.google.errorprone:error_prone_annotations:${errorproneVersion}"
testImplementation "androidx.test:core:${testRunnerVersion}"
testImplementation "androidx.test:runner:${testRunnerVersion}"
testImplementation "junit:junit:4.13.2"
testImplementation "com.google.truth:truth:${truthVersion}"
testImplementation "org.mockito:mockito-core:${mockitoCoreVersion}"
testImplementation "org.robolectric:robolectric:${robolectricVersion}"
}
def srcDirs = [
'com/google/android/material/animation',
'com/google/android/material/appbar',
'com/google/android/material/badge',
'com/google/android/material/behavior',
'com/google/android/material/bottomappbar',
'com/google/android/material/bottomnavigation',
'com/google/android/material/bottomsheet',
'com/google/android/material/button',
'com/google/android/material/canvas',
'com/google/android/material/card',
'com/google/android/material/carousel',
'com/google/android/material/checkbox',
'com/google/android/material/chip',
'com/google/android/material/circularreveal',
'com/google/android/material/circularreveal/cardview',
'com/google/android/material/circularreveal/coordinatorlayout',
'com/google/android/material/color',
'com/google/android/material/datepicker',
'com/google/android/material/dialog',
'com/google/android/material/divider',
'com/google/android/material/drawable',
'com/google/android/material/elevation',
'com/google/android/material/expandable',
'com/google/android/material/floatingactionbutton',
'com/google/android/material/imageview',
'com/google/android/material/internal',
'com/google/android/material/materialswitch',
'com/google/android/material/math',
'com/google/android/material/menu',
'com/google/android/material/motion',
'com/google/android/material/navigation',
'com/google/android/material/navigationrail',
'com/google/android/material/progressindicator',
'com/google/android/material/radiobutton',
'com/google/android/material/resources',
'com/google/android/material/ripple',
'com/google/android/material/search',
'com/google/android/material/shape',
'com/google/android/material/shadow',
'com/google/android/material/sidesheet',
'com/google/android/material/slider',
'com/google/android/material/snackbar',
'com/google/android/material/stateful',
'com/google/android/material/switchmaterial',
'com/google/android/material/tabs',
'com/google/android/material/textfield',
'com/google/android/material/textview',
'com/google/android/material/theme',
'com/google/android/material/theme/overlay',
'com/google/android/material/timepicker',
'com/google/android/material/tooltip',
'com/google/android/material/transition',
'com/google/android/material/transformation',
'com/google/android/material/typography',
]
android {
sourceSets {
main.manifest.srcFile 'java/com/google/android/material/AndroidManifest.xml'
main.java.srcDir 'java'
main.java.includes = srcDirs.collect { it + '/**/*.java' }
main.java.excludes = [
'**/build/**',
]
srcDirs.forEach {
main.res.srcDirs += 'java/' + it + '/res'
main.res.srcDirs += 'java/' + it + '/res-public'
test.res.srcDirs += 'javatests/' + it + '/res'
}
test.java.srcDir 'javatests'
}
testOptions.unitTests.includeAndroidResources = true
buildTypes.all {
consumerProguardFiles 'proguard-behaviors.pro', 'proguard-inflater.pro'
}
defaultConfig {
minSdkVersion 14
}
}
task generateJavadocs(type: Javadoc) {
if (project.hasProperty("online")) {
options.addStringOption("toroot", "/")
options.addStringOption("hdf", "android.whichdoc online")
options.addStringOption("hdf", "dac")
options.addBooleanOption("devsite", true)
options.addBooleanOption("yamlV2", true)
options.addStringOption("dac_libraryroot", "com/google/android/material")
options.addStringOption("dac_dataname", "MATERIAL_DATA")
}
if (project.hasProperty("docletPathRoot")) {
def docletPathRoot = project.property("docletPathRoot")
def outputPath = project.hasProperty("outputPath") ? project.property("outputPath") : "doclava-out"
def doclavaJar = project.getProperty("doclavaJar")
source = android.sourceSets.main.java.source
source = source.findAll { it.name.endsWith(".java") }
title = null
destinationDir = new File(outputPath)
classpath = files("${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar")
options.addStringOption("federate Android", "https://developer.android.com")
options.encoding = "UTF-8"
options.doclet = "com.google.doclava.Doclava"
options.docletpath = [
file(doclavaJar),
file(docletPathRoot + "/jsilver/v1_0_0/jsilver.jar")
]
}
}
task getVersion {
doLast {
println version
}
}
task generateApiXml(type: Javadoc) {
if (project.hasProperty("apiName")) {
def jdiff = project.property("jdiffJar")
def apiName = project.property("apiName")
source = android.sourceSets.main.java.source
source = source.findAll { it.name.endsWith(".java") }
classpath = files("${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar")
options.doclet = "jdiff.JDiff"
options.addStringOption("subpackages", ".")
options.addStringOption("apiname", apiName)
options.docletpath = [
file(jdiff),
]
// Doclava does not understand -notimestamp option that is default since Gradle 6.0
options.setNoTimestamp(false)
}
doLast {
// Escape incorrect ampersands in API XML file
if (OperatingSystem.current().isLinux()) {
["sed", "-i", "s/ & / \\& /g", "lib/${apiName}.xml"].execute()
} else {
["sed", "-i", "''", "s/ & / \\& /g", "lib/${apiName}.xml"].execute()
}
}
}
task generateJdiffReport(type: Javadoc) {
if (project.hasProperty('oldApi')) {
def outputPath = project.hasProperty('outputPath') ? project.property('outputPath') : 'diffs-out'
def jdiff = project.property('jdiffjar')
def xerces = project.property('xercesjar')
def oldApi = project.property('oldApi')
def newApi = project.property('newApi')
def newApiDir = project.property('newApiDir')
def oldApiDir = project.property('oldApiDir')
destinationDir = new File(outputPath)
source = android.sourceSets.main.java.source
source = source.findAll { it.name.endsWith('.java') }
classpath = files('${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar')
options.doclet = 'jdiff.JDiff'
options.addStringOption('subpackages', '.')
options.addStringOption('newapidir', newApiDir)
options.addStringOption('oldapidir', oldApiDir)
options.addStringOption('oldapi', oldApi)
options.addBooleanOption('verbose', true)
options.addStringOption('newapi', newApi)
// Doclava does not understand -notimestamp option that is default since Gradle 6.0
options.setNoTimestamp(false)
options.docletpath = [
file(jdiff),
file(xerces),
]
}
}
def R_CLASS_PATH = "build/generated/not_namespaced_r_class_sources/releaseUnitTest/processReleaseUnitTestResources/r/com/google/android/material/R.java"
Attribute<String> ARTIFACT_TYPE = Attribute.of("artifactType", String.class)
afterEvaluate {
[generateJavadocs, generateApiXml].forEach { task ->
task.dependsOn(':lib:processReleaseUnitTestResources')
task.source += R_CLASS_PATH
def releaseVariant = android.libraryVariants.find { it.name == 'release' }
if (releaseVariant == null) {
return
}
// Add transitive runtime dependencies to classpath
task.classpath += releaseVariant.runtimeConfiguration.incoming.artifactView { aView ->
aView.attributes.attribute(ARTIFACT_TYPE, "android-classes")
}.files
// Add project and compile dependencies to classpath
releaseVariant.javaCompileProvider.configure { javaCompileProvider ->
task.classpath += releaseVariant.getCompileClasspath(null)
task.classpath += task.project.files(javaCompileProvider.destinationDir)
task.source += javaCompileProvider.source
}
// Doclava does not understand -notimestamp option that is default since Gradle 6.0
task.options.setNoTimestamp(false)
}
}
task androidSourcesJar(type: Jar) {
archiveClassifier.set('sources')
from(android.sourceSets.main.java.srcDirs) {
// Needed because we have Java sources and resources in same directory
include '**/*.java'
includeEmptyDirs = false
}
}
afterEvaluate {
publishing {
repositories {
maven {
url = "$mavenRepoUrl"
}
}
publications {
release(MavenPublication) {
from components.release
artifact androidSourcesJar
groupId = 'com.google.android.material'
artifactId = 'material'
version project.version
pom {
name = 'Material Components for Android'
description = 'Material Components for Android is a static library ' +
'that you can add to your Android application in order to use ' +
'APIs that provide implementations of the Material Design specification. ' +
'Compatible on devices running API 14 or later.'
url = 'https://github.com/material-components/material-components-android'
inceptionYear = '2015'
licenses {
license {
name = 'The Apache Software License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution = 'repo'
}
}
developers {
developer {
name = 'The Android Open Source Project'
}
}
scm {
connection = 'scm:git:https://github.com/material-components/material-components-android.git'
url = 'https://github.com/material-components/material-components-android'
}
}
}
}
}
}