forked from firebase/FirebaseUI-Android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
224 lines (183 loc) · 7.49 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
apply from: 'common/constants.gradle'
buildscript {
repositories {
jcenter()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.gms:google-services:3.0.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
}
}
allprojects {
repositories {
jcenter()
mavenLocal()
mavenCentral()
}
}
//Skip Javadoc generation for Java 1.8 as it breaks build
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
/**
* Configure common tasks on all the submodules
*/
allprojects { project ->
// Get constants, this is where we store things
// like the list of submodules or the version
project.apply from: "$rootDir/common/constants.gradle"
def isLibrary = 'library'.equals(project.name)
def isSubmodule = project.ext.submodules.contains(project.name)
// Only applies to submodules, not the library module
def pomTask = "generatePomFileFor${project.name.capitalize()}LibraryPublication";
if (isSubmodule || isLibrary) {
// So that we can resolve 'android' variable
project.apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "${project.ext.buildtools}"
}
// Task to generate sources JAR
task sourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
// Task to generate javadoc
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += configurations.compile
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
// Task to generate javadoc JAR
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
// Define base name for archives
// Ex: firebase-ui-auth
archivesBaseName = isSubmodule ? "firebase-ui-${project.name}" : "firebase-ui"
// Use tasks above to define artifacts
artifacts {
archives javadocJar
archives sourcesJar
}
// So that we can define publication
project.apply plugin: 'maven-publish'
publishing {
// By passing -Pcustom_local=/some/path and running the
// publishLibraryPublicationToCustomLocalRepository task you can publish this library to a
// custom maven repository location on your machine.
repositories {
maven {
name 'CustomLocal'
url uri(project.hasProperty('custom_local') ? project.getProperty('custom_local') : '/tmp/')
}
}
repositories {
maven {
name 'BuildLocal'
url "$buildDir/repo"
}
}
}
}
if (isSubmodule) {
// Convenience task to prepare everything we need for releases
task prepareArtifacts(dependsOn: [javadocJar, sourcesJar, assembleRelease, pomTask]) {}
publishing {
// Define a publication for each submodule
publications {
// Ex: authLibrary(MavenPublication)
"${project.name}Library"(MavenPublication) {
groupId project.ext.group
artifactId archivesBaseName
version project.ext.version
// Release AAR, Sources, and JavaDoc
artifact "$buildDir/outputs/aar/$archivesBaseName-release.aar"
artifact javadocJar
artifact sourcesJar
pom.withXml {
def dependenciesNode = asNode().getAt("dependencies")[0]
if (dependenciesNode == null) {
dependenciesNode = asNode().appendNode("dependencies");
}
// Add all that are 'compile'
configurations.compile.allDependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
}
}
}
if (isLibrary) {
// Define the monolith publication
publishing {
publications {
monolithLibrary(MavenPublication) {
groupId project.ext.group
artifactId archivesBaseName
version project.ext.version
artifact "$buildDir/outputs/aar/$archivesBaseName-release.aar"
artifact javadocJar
artifact sourcesJar
// Monolith is just a POM that depends on the others
pom.withXml {
def dependenciesNode = asNode().getAt("dependencies")[0]
if (dependenciesNode == null) {
dependenciesNode = asNode().appendNode("dependencies");
}
// Add a maven dependency on each submodule
project.ext.submodules.each { module ->
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', project.ext.group)
dependencyNode.appendNode('artifactId', "firebase-ui-${module}")
dependencyNode.appendNode('version', project.ext.version)
}
}
}
}
}
}
// Bintray Configuration (applies to submodule and the monolith)
if (isSubmodule || isLibrary) {
project.apply plugin: 'com.jfrog.bintray'
def archivesBaseName = isLibrary ? 'firebase-ui' : "firebase-ui-${project.name}"
def pomLoc = isLibrary ? "$buildDir/publications/monolithLibrary/pom-default.xml" : "$buildDir/publications/${project.name}Library/pom-default.xml"
group = project.ext.group
version = project.ext.version
def versionName = project.ext.version
bintray {
user = hasProperty('BINTRAY_USER') ? getProperty('BINTRAY_USER') : System.getenv('BINTRAY_USER')
key = hasProperty('BINTRAY_KEY') ? getProperty('BINTRAY_KEY') : System.getenv('BINTRAY_KEY')
filesSpec {
from pomLoc
into "com/firebaseui/$archivesBaseName/$versionName/"
rename { String fileName ->
"${archivesBaseName}-${project.ext.version}.pom"
}
}
configurations = [ 'archives' ]
pkg {
repo = 'firebase-ui'
name = archivesBaseName
userOrg = 'firebaseui'
licenses = [ 'Apache-2.0' ]
vcsUrl = 'https://github.com/firebase/FirebaseUI-Android.git'
version {
name = versionName
}
}
}
}
}