Skip to content

Commit 8f305dd

Browse files
authored
Fix common publishing (#944)
1 parent 68de484 commit 8f305dd

File tree

2 files changed

+36
-83
lines changed

2 files changed

+36
-83
lines changed

build.gradle

+35-82
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ allprojects { project ->
4444
def isLibrary = 'library'.equals(project.name)
4545
def isSubmodule = submodules.contains(project.name)
4646

47-
if (isSubmodule || isLibrary) {
47+
if (isLibrary || isSubmodule) {
4848

4949
// So that we can resolve 'android' variable
5050
project.apply plugin: 'com.android.library'
@@ -103,16 +103,44 @@ allprojects { project ->
103103
}
104104
}
105105
}
106-
}
107106

108-
// POM to meet maven specs
109-
if (isLibrary || isSubmodule) {
110-
def targetName = isLibrary ? 'monolithLibrary' : "${project.name}Library"
107+
// POM to meet maven specs
108+
def publicationName = isLibrary ? 'monolithLibrary' : "${project.name}Library"
109+
def archivesBaseName = isLibrary ? 'firebase-ui' : "firebase-ui-${project.name}"
111110

112111
publishing {
113112
publications {
114-
"${targetName}"(MavenPublication) {
113+
"${publicationName}"(MavenPublication) {
114+
115+
groupId group
116+
artifactId archivesBaseName
117+
version version
118+
119+
artifact "$buildDir/outputs/aar/$archivesBaseName-release.aar"
120+
artifact javadocJar
121+
artifact sourcesJar
122+
115123
pom.withXml {
124+
// Dependencies
125+
def dependenciesNode = asNode().getAt("dependencies")[0]
126+
if (dependenciesNode == null) {
127+
dependenciesNode = asNode().appendNode("dependencies")
128+
}
129+
130+
// Add all that are 'compile'
131+
configurations.compile.allDependencies.each {
132+
def dependencyNode = dependenciesNode.appendNode('dependency')
133+
dependencyNode.appendNode('groupId', it.group)
134+
135+
if (submodules.contains(it.name)) {
136+
dependencyNode.appendNode('artifactId', "firebase-ui-${it.name}")
137+
} else {
138+
dependencyNode.appendNode('artifactId', it.name)
139+
}
140+
141+
dependencyNode.appendNode('version', it.version)
142+
}
143+
116144
// Common values
117145
def repoUrl = 'https://github.com/firebase/FirebaseUI-Android'
118146
def scmUrl = 'scm:git:[email protected]/firebase/firebaseui-android.git'
@@ -157,85 +185,10 @@ allprojects { project ->
157185
}
158186
}
159187
}
160-
}
161-
162-
if (isSubmodule) {
163-
publishing {
164-
165-
// Define a publication for each submodule
166-
publications {
167188

168-
// Ex: authLibrary(MavenPublication)
169-
"${project.name}Library"(MavenPublication) {
170-
groupId group
171-
artifactId archivesBaseName
172-
version version
173-
174-
// Release AAR, Sources, and JavaDoc
175-
artifact "$buildDir/outputs/aar/$archivesBaseName-release.aar"
176-
artifact javadocJar
177-
artifact sourcesJar
178-
179-
pom.withXml {
180-
def dependenciesNode = asNode().getAt("dependencies")[0]
181-
if (dependenciesNode == null) {
182-
dependenciesNode = asNode().appendNode("dependencies")
183-
}
184-
185-
// Add all that are 'compile'
186-
configurations.compile.allDependencies.each {
187-
def dependencyNode = dependenciesNode.appendNode('dependency')
188-
dependencyNode.appendNode('groupId', it.group)
189-
dependencyNode.appendNode('artifactId', it.name)
190-
dependencyNode.appendNode('version', it.version)
191-
}
192-
}
193-
}
194-
}
195-
}
196-
}
197-
198-
if (isLibrary) {
199-
200-
// Define the monolith publication
201-
publishing {
202-
203-
publications {
204-
monolithLibrary(MavenPublication) {
205-
groupId group
206-
artifactId archivesBaseName
207-
version version
208-
209-
artifact "$buildDir/outputs/aar/$archivesBaseName-release.aar"
210-
artifact javadocJar
211-
artifact sourcesJar
212-
213-
// Monolith is just a POM that depends on the others
214-
pom.withXml {
215-
def dependenciesNode = asNode().getAt("dependencies")[0]
216-
if (dependenciesNode == null) {
217-
dependenciesNode = asNode().appendNode("dependencies")
218-
}
219-
220-
// Add a maven dependency on each submodule
221-
submodules.each { module ->
222-
def dependencyNode = dependenciesNode.appendNode('dependency')
223-
dependencyNode.appendNode('groupId', group)
224-
dependencyNode.appendNode('artifactId', "firebase-ui-${module}")
225-
dependencyNode.appendNode('version', version)
226-
}
227-
}
228-
}
229-
}
230-
}
231-
}
232-
233-
// Bintray Configuration (applies to submodule and the monolith)
234-
if (isSubmodule || isLibrary) {
189+
// Bintray Configuration (applies to submodule and the monolith)
235190
project.apply plugin: 'com.jfrog.bintray'
236191

237-
def archivesBaseName = isLibrary ? 'firebase-ui' : "firebase-ui-${project.name}"
238-
def publicationName = isLibrary ? 'monolithLibrary' : "${project.name}Library"
239192
def pomLoc = isLibrary ? "$buildDir/publications/monolithLibrary/pom-default.xml" : "$buildDir/publications/${project.name}Library/pom-default.xml"
240193

241194
group = project.ext.group

constants.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
project.ext {
2-
submodules = ['database', 'auth', 'storage', 'firestore']
2+
submodules = ['database', 'auth', 'storage', 'firestore', 'common']
33
group = 'com.firebaseui'
44
version = '3.0.0'
55
pomdesc = 'Firebase UI Android'

0 commit comments

Comments
 (0)