Skip to content

Commit

Permalink
Fix common publishing (#944)
Browse files Browse the repository at this point in the history
  • Loading branch information
samtstern committed Oct 3, 2017
1 parent 68de484 commit 8f305dd
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 83 deletions.
117 changes: 35 additions & 82 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ allprojects { project ->
def isLibrary = 'library'.equals(project.name)
def isSubmodule = submodules.contains(project.name)

if (isSubmodule || isLibrary) {
if (isLibrary || isSubmodule) {

// So that we can resolve 'android' variable
project.apply plugin: 'com.android.library'
Expand Down Expand Up @@ -103,16 +103,44 @@ allprojects { project ->
}
}
}
}

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

publishing {
publications {
"${targetName}"(MavenPublication) {
"${publicationName}"(MavenPublication) {

groupId group
artifactId archivesBaseName
version version

artifact "$buildDir/outputs/aar/$archivesBaseName-release.aar"
artifact javadocJar
artifact sourcesJar

pom.withXml {
// Dependencies
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)

if (submodules.contains(it.name)) {
dependencyNode.appendNode('artifactId', "firebase-ui-${it.name}")
} else {
dependencyNode.appendNode('artifactId', it.name)
}

dependencyNode.appendNode('version', it.version)
}

// Common values
def repoUrl = 'https://github.com/firebase/FirebaseUI-Android'
def scmUrl = 'scm:git:[email protected]/firebase/firebaseui-android.git'
Expand Down Expand Up @@ -157,85 +185,10 @@ allprojects { project ->
}
}
}
}

if (isSubmodule) {
publishing {

// Define a publication for each submodule
publications {

// Ex: authLibrary(MavenPublication)
"${project.name}Library"(MavenPublication) {
groupId group
artifactId archivesBaseName
version 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 group
artifactId archivesBaseName
version 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
submodules.each { module ->
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', group)
dependencyNode.appendNode('artifactId', "firebase-ui-${module}")
dependencyNode.appendNode('version', version)
}
}
}
}
}
}

// Bintray Configuration (applies to submodule and the monolith)
if (isSubmodule || isLibrary) {
// Bintray Configuration (applies to submodule and the monolith)
project.apply plugin: 'com.jfrog.bintray'

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

group = project.ext.group
Expand Down
2 changes: 1 addition & 1 deletion constants.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project.ext {
submodules = ['database', 'auth', 'storage', 'firestore']
submodules = ['database', 'auth', 'storage', 'firestore', 'common']
group = 'com.firebaseui'
version = '3.0.0'
pomdesc = 'Firebase UI Android'
Expand Down

0 comments on commit 8f305dd

Please sign in to comment.