@@ -6,7 +6,7 @@ buildscript {
66 mavenLocal()
77 }
88 dependencies {
9- classpath ' com.android.tools.build:gradle:1.5 .0'
9+ classpath ' com.android.tools.build:gradle:2.0 .0'
1010 classpath ' com.google.gms:google-services:3.0.0'
1111
1212 classpath ' com.neenbedankt.gradle.plugins:android-apt:1.8'
@@ -29,16 +29,18 @@ allprojects { project ->
2929
3030 // Get constants, this is where we store things
3131 // like the list of submodules or the version
32- apply from : " $rootDir /common/constants.gradle"
32+ project . apply from : " $rootDir /common/constants.gradle"
3333
3434 def isLibrary = ' library' . equals(project. name)
3535 def isSubmodule = project. ext. submodules. contains(project. name)
36- def pomTask = " generatePomFileFor${ project.name.capitalize()} LibraryPublication"
3736
38- if (isSubmodule) {
37+ // Only applies to submodules, not the library module
38+ def pomTask = " generatePomFileFor${ project.name.capitalize()} LibraryPublication" ;
39+
40+ if (isSubmodule || isLibrary) {
3941
4042 // So that we can resolve 'android' variable
41- apply plugin : ' com.android.library'
43+ project . apply plugin : ' com.android.library'
4244 android {
4345 compileSdkVersion 23
4446 buildToolsVersion " ${ project.ext.buildtools} "
@@ -65,10 +67,7 @@ allprojects { project ->
6567
6668 // Define base name for archives
6769 // Ex: firebase-ui-auth
68- archivesBaseName = " firebase-ui-${ project.name} "
69-
70- // Convenience tasks that depends on the above
71- task prepareArtifacts(dependsOn : [javadocJar, sourcesJar, assembleRelease, pomTask]) {}
70+ archivesBaseName = isSubmodule ? " firebase-ui-${ project.name} " : " firebase-ui"
7271
7372 // Use tasks above to define artifacts
7473 artifacts {
@@ -77,7 +76,31 @@ allprojects { project ->
7776 }
7877
7978 // So that we can define publication
80- apply plugin : ' maven-publish'
79+ project. apply plugin : ' maven-publish'
80+
81+ publishing {
82+ // By passing -Pcustom_local=/some/path and running the
83+ // publishLibraryPublicationToCustomLocalRepository task you can publish this library to a
84+ // custom maven repository location on your machine.
85+ repositories {
86+ maven {
87+ name ' CustomLocal'
88+ url uri(project. hasProperty(' custom_local' ) ? project. getProperty(' custom_local' ) : ' /tmp/' )
89+ }
90+ }
91+
92+ repositories {
93+ maven {
94+ name ' BuildLocal'
95+ url " $buildDir /repo"
96+ }
97+ }
98+ }
99+ }
100+
101+ if (isSubmodule) {
102+ // Convenience task to prepare everything we need for releases
103+ task prepareArtifacts(dependsOn : [javadocJar, sourcesJar, assembleRelease, pomTask]) {}
81104
82105 publishing {
83106
@@ -110,32 +133,48 @@ allprojects { project ->
110133 }
111134 }
112135 }
113-
114136 }
137+ }
138+ }
115139
116- // By passing -Pcustom_local=/some/path and running the
117- // publishLibraryPublicationToCustomLocalRepository task you can publish this library to a
118- // custom maven repository location on your machine.
119- repositories {
120- maven {
121- name ' CustomLocal'
122- url uri(project. hasProperty(' custom_local' ) ? project. getProperty(' custom_local' ) : ' /tmp/' )
123- }
124- }
140+ if (isLibrary) {
125141
126- repositories {
127- maven {
128- name ' BuildLocal'
129- url " $buildDir /repo"
142+ // Define the monolith publication
143+ publishing {
144+
145+ publications {
146+ monolithLibrary(MavenPublication ) {
147+ groupId project. ext. group
148+ artifactId archivesBaseName
149+ version project. ext. version
150+
151+ artifact " $buildDir /outputs/aar/$archivesBaseName -release.aar"
152+ artifact javadocJar
153+ artifact sourcesJar
154+
155+ // Monolith is just a POM that depends on the others
156+ pom. withXml {
157+ def dependenciesNode = asNode(). getAt(" dependencies" )[0 ]
158+ if (dependenciesNode == null ) {
159+ dependenciesNode = asNode(). appendNode(" dependencies" );
160+ }
161+
162+ // Add a maven dependency on each submodule
163+ project. ext. submodules. each { module ->
164+ def dependencyNode = dependenciesNode. appendNode(' dependency' )
165+ dependencyNode. appendNode(' groupId' , project. ext. group)
166+ dependencyNode. appendNode(' artifactId' , " firebase-ui-${ module} " )
167+ dependencyNode. appendNode(' version' , project. ext. version)
168+ }
169+ }
130170 }
131171 }
132-
133172 }
134173 }
135174
136175 // Bintray Configuration (applies to submodule and the monolith)
137176 if (isSubmodule || isLibrary) {
138- apply plugin : ' com.jfrog.bintray'
177+ project . apply plugin : ' com.jfrog.bintray'
139178
140179 def archivesBaseName = isLibrary ? ' firebase-ui' : " firebase-ui-${ project.name} "
141180 def pomLoc = isLibrary ? " $buildDir /publications/monolithLibrary/pom-default.xml" : " $buildDir /publications/${ project.name} Library/pom-default.xml"
0 commit comments