Skip to content

Commit 47787cb

Browse files
authored
Attempt temporary fix (#1332)
1 parent 1bc5cbe commit 47787cb

File tree

3 files changed

+288
-32
lines changed

3 files changed

+288
-32
lines changed

build.gradle.kts

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ allprojects {
4747
configureQuality()
4848

4949
if (Config.submodules.contains(name) || isLibrary) {
50-
setupPublishing()
50+
// TODO: Re-enable this in the future
51+
// setupPublishing()
52+
setupTasks()
5153
}
5254
}
5355
}
@@ -127,35 +129,7 @@ fun Project.configureQuality() {
127129
}
128130
}
129131

130-
fun Project.setupPublishing() {
131-
println("Configuring publishing for ${this}")
132-
133-
val sourcesJar = task<Jar>("sourcesJar") {
134-
classifier = "sources"
135-
from(project.the<BaseExtension>().sourceSets["main"].java.srcDirs)
136-
}
137-
138-
val javadoc = task<Javadoc>("javadoc") {
139-
setSource(project.the<BaseExtension>().sourceSets["main"].java.srcDirs)
140-
classpath += configurations["compile"]
141-
classpath += project.files(project.the<BaseExtension>().bootClasspath)
142-
}
143-
144-
val javadocJar = task<Jar>("javadocJar") {
145-
dependsOn(javadoc)
146-
classifier = "javadoc"
147-
from(javadoc.destinationDir)
148-
}
149-
150-
artifacts.add("archives", javadocJar)
151-
artifacts.add("archives", sourcesJar)
152-
153-
tasks.whenTaskAdded {
154-
if (name.toLowerCase().contains("publish") && name.contains("publication", true)) {
155-
dependsOn("assembleRelease")
156-
}
157-
}
158-
132+
fun Project.setupTasks() {
159133
afterEvaluate {
160134
if (isLibrary) {
161135
task("testAll") {
@@ -165,7 +139,7 @@ fun Project.setupPublishing() {
165139
}
166140

167141
task("prepareArtifacts") {
168-
dependsOn(javadocJar, sourcesJar, "assembleRelease")
142+
dependsOn("javadocJar", "sourcesJar", "assembleRelease")
169143
dependsOn("generatePomFileForMonolithLibraryPublication")
170144
dependsOn(*Config.submodules.map {
171145
":$it:prepareArtifacts"
@@ -195,10 +169,40 @@ fun Project.setupPublishing() {
195169
} else {
196170
val pomTask = "generatePomFileFor${project.name.capitalize()}LibraryPublication"
197171
task("prepareArtifacts") {
198-
dependsOn(javadocJar, sourcesJar, "assembleRelease", pomTask)
172+
dependsOn("javadocJar", "sourcesJar", "assembleRelease", pomTask)
199173
}
200174
}
201175
}
176+
}
177+
178+
fun Project.setupPublishing() {
179+
println("Configuring publishing for ${this}")
180+
181+
val sourcesJar = task<Jar>("sourcesJar") {
182+
classifier = "sources"
183+
from(project.the<BaseExtension>().sourceSets["main"].java.srcDirs)
184+
}
185+
186+
val javadoc = task<Javadoc>("javadoc") {
187+
setSource(project.the<BaseExtension>().sourceSets["main"].java.srcDirs)
188+
classpath += configurations["compile"]
189+
classpath += project.files(project.the<BaseExtension>().bootClasspath)
190+
}
191+
192+
val javadocJar = task<Jar>("javadocJar") {
193+
dependsOn(javadoc)
194+
classifier = "javadoc"
195+
from(javadoc.destinationDir)
196+
}
197+
198+
artifacts.add("archives", javadocJar)
199+
artifacts.add("archives", sourcesJar)
200+
201+
tasks.whenTaskAdded {
202+
if (name.toLowerCase().contains("publish") && name.contains("publication", true)) {
203+
dependsOn("assembleRelease")
204+
}
205+
}
202206

203207
apply(plugin = "maven-publish")
204208
apply(plugin = "com.jfrog.artifactory")
@@ -394,3 +398,6 @@ fun Project.setupPublishing() {
394398
})
395399
}
396400
}
401+
402+
// TODO: Remove this
403+
apply(from = "publishing.gradle")

constants.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
project.ext {
2+
submodules = ['database', 'auth', 'storage', 'firestore', 'common']
3+
group = 'com.firebaseui'
4+
version = '4.0.1'
5+
pomdesc = 'Firebase UI Android'
6+
7+
compileSdk = 27
8+
targetSdk = 27
9+
minSdk = 14
10+
}

publishing.gradle

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
/**
2+
* Configure common tasks on all the submodules
3+
*/
4+
allprojects { project ->
5+
6+
// Get constants, this is where we store things
7+
// like the list of submodules or the version
8+
project.apply from: "$rootDir/constants.gradle"
9+
10+
def isLibrary = 'library'.equals(project.name)
11+
def isSubmodule = submodules.contains(project.name)
12+
13+
if (isLibrary || isSubmodule) {
14+
tasks.whenTaskAdded { task ->
15+
if (task.name.contains("publish") && task.name.toLowerCase().contains("publication")) {
16+
task.dependsOn 'assemble'
17+
}
18+
}
19+
20+
// So that we can resolve 'android' variable
21+
project.apply plugin: 'com.android.library'
22+
android {
23+
compileSdkVersion compileSdk
24+
}
25+
26+
// Task to generate sources JAR
27+
task sourcesJar(type: Jar) {
28+
classifier = 'sources'
29+
from android.sourceSets.main.java.srcDirs
30+
}
31+
32+
// Task to generate javadoc
33+
task javadoc(type: Javadoc) {
34+
source = android.sourceSets.main.java.srcDirs
35+
classpath += configurations.compile
36+
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
37+
}
38+
39+
// Task to generate javadoc JAR
40+
task javadocJar(type: Jar, dependsOn: javadoc) {
41+
classifier = 'javadoc'
42+
from javadoc.destinationDir
43+
}
44+
45+
// Define base name for archives
46+
// Ex: firebase-ui-auth
47+
archivesBaseName = isSubmodule ? "firebase-ui-${project.name}" : "firebase-ui"
48+
49+
// Use tasks above to define artifacts
50+
artifacts {
51+
archives javadocJar
52+
archives sourcesJar
53+
}
54+
55+
// JFrog Artifactory integration
56+
project.apply plugin: 'com.jfrog.artifactory'
57+
58+
// So that we can define publication
59+
project.apply plugin: 'maven-publish'
60+
61+
publishing {
62+
// By passing -Pcustom_local=/some/path and running the
63+
// publishLibraryPublicationToCustomLocalRepository task you can publish this library to a
64+
// custom maven repository location on your machine.
65+
repositories {
66+
maven {
67+
name 'CustomLocal'
68+
url uri(project.hasProperty('custom_local') ? project.getProperty('custom_local') : '/tmp/')
69+
}
70+
}
71+
72+
repositories {
73+
maven {
74+
name 'BuildLocal'
75+
url "$buildDir/repo"
76+
}
77+
}
78+
}
79+
80+
// POM to meet maven specs
81+
def publicationName = isLibrary ? 'monolithLibrary' : "${project.name}Library"
82+
def archivesBaseName = isLibrary ? 'firebase-ui' : "firebase-ui-${project.name}"
83+
84+
// We need to override the variables 'group' and 'version' on the 'Project' object in order
85+
// to prevent the bintray plugin from creating 'unspecified' artifacts.
86+
group = project.ext.group
87+
version = project.ext.version
88+
89+
def groupName = project.ext.group
90+
def versionName = project.ext.version
91+
92+
publishing {
93+
publications {
94+
"${publicationName}"(MavenPublication) {
95+
96+
groupId groupName
97+
artifactId archivesBaseName
98+
version versionName
99+
100+
artifact "$buildDir/outputs/aar/${archivesBaseName}-release.aar"
101+
artifact javadocJar
102+
artifact sourcesJar
103+
104+
pom.withXml {
105+
// Dependencies
106+
def dependenciesNode = asNode().getAt("dependencies")[0]
107+
if (dependenciesNode == null) {
108+
dependenciesNode = asNode().appendNode("dependencies")
109+
}
110+
111+
configurations.api.dependencies.each {
112+
def dependencyNode = dependenciesNode.appendNode('dependency')
113+
114+
if (submodules.contains(it.name)) {
115+
dependencyNode.appendNode('groupId', groupName)
116+
dependencyNode.appendNode('artifactId', "firebase-ui-${it.name}")
117+
dependencyNode.appendNode('version', versionName)
118+
} else {
119+
dependencyNode.appendNode('groupId', it.group)
120+
dependencyNode.appendNode('artifactId', it.name)
121+
dependencyNode.appendNode('version', it.version)
122+
}
123+
124+
dependencyNode.appendNode('scope', 'compile')
125+
}
126+
configurations.implementation.dependencies.each {
127+
def dependencyNode = dependenciesNode.appendNode('dependency')
128+
129+
if (submodules.contains(it.name)) {
130+
dependencyNode.appendNode('groupId', groupName)
131+
dependencyNode.appendNode('artifactId', "firebase-ui-${it.name}")
132+
dependencyNode.appendNode('version', versionName)
133+
} else {
134+
dependencyNode.appendNode('groupId', it.group)
135+
dependencyNode.appendNode('artifactId', it.name)
136+
dependencyNode.appendNode('version', it.version)
137+
}
138+
139+
dependencyNode.appendNode('scope', 'runtime')
140+
}
141+
142+
// Common values
143+
def repoUrl = 'https://github.com/firebase/FirebaseUI-Android'
144+
def scmUrl = 'scm:git:[email protected]/firebase/firebaseui-android.git'
145+
146+
// Name
147+
asNode().appendNode('name', artifactId)
148+
149+
// Description
150+
asNode().appendNode('description', 'Firebase UI for Android')
151+
152+
// Organization
153+
def organization = asNode().appendNode('organization')
154+
organization.appendNode('name', 'FirebaseUI')
155+
organization.appendNode('url', repoUrl)
156+
157+
// URL
158+
asNode().appendNode('url', repoUrl)
159+
160+
// SCM
161+
def scm = asNode().appendNode('scm')
162+
scm.appendNode('connection', scmUrl)
163+
scm.appendNode('developerConnection', scmUrl)
164+
scm.appendNode('url', repoUrl)
165+
scm.appendNode('tag', 'HEAD')
166+
167+
// Developers
168+
def developer = asNode().appendNode('developers').appendNode('developer')
169+
developer.appendNode('id', 'samtstern')
170+
developer.appendNode('email', '[email protected]')
171+
developer.appendNode('organization', 'Firebase')
172+
developer.appendNode('organizationUrl', 'https://firebase.google.com')
173+
def roles = developer.appendNode('roles')
174+
roles.appendNode('role', 'Project-Administrator')
175+
roles.appendNode('role', 'Developer')
176+
developer.appendNode('timezone', '-8')
177+
178+
// Licenses
179+
def license = asNode().appendNode('licenses').appendNode('license')
180+
license.appendNode('name', 'The Apache License, Version 2.0')
181+
license.appendNode('url', 'http://www.apache.org/licenses/LICENSE-2.0.txt')
182+
}
183+
}
184+
}
185+
}
186+
187+
def bintrayUsername = hasProperty('BINTRAY_USER') ? getProperty('BINTRAY_USER') : System.getenv('BINTRAY_USER')
188+
def bintrayKey = hasProperty('BINTRAY_KEY') ? getProperty('BINTRAY_KEY') : System.getenv('BINTRAY_KEY')
189+
190+
artifactory {
191+
contextUrl = 'https://oss.jfrog.org'
192+
publish {
193+
repository {
194+
repoKey = 'oss-snapshot-local'
195+
196+
username = bintrayUsername
197+
password = bintrayKey
198+
}
199+
}
200+
}
201+
202+
artifactoryPublish {
203+
publications(publishing.publications."$publicationName")
204+
}
205+
206+
// Bintray Configuration (applies to submodule and the monolith)
207+
project.apply plugin: 'com.jfrog.bintray'
208+
209+
def pomLoc = isLibrary ? "$buildDir/publications/monolithLibrary/pom-default.xml" : "$buildDir/publications/${project.name}Library/pom-default.xml"
210+
211+
bintray {
212+
user = bintrayUsername
213+
key = bintrayKey
214+
publications = [publicationName]
215+
216+
filesSpec {
217+
from pomLoc
218+
into "com/firebaseui/$archivesBaseName/$versionName/"
219+
rename { String fileName ->
220+
"${archivesBaseName}-${versionName}.pom"
221+
}
222+
}
223+
224+
configurations = ['archives']
225+
226+
pkg {
227+
repo = 'firebase-ui'
228+
name = archivesBaseName
229+
userOrg = 'firebaseui'
230+
licenses = ['Apache-2.0']
231+
vcsUrl = 'https://github.com/firebase/FirebaseUI-Android.git'
232+
233+
version {
234+
name = versionName
235+
}
236+
}
237+
}
238+
}
239+
}

0 commit comments

Comments
 (0)