Skip to content

Commit d013643

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/ImplementDocumentIdAnnotation' into ImplementDocumentIdAnnotation
2 parents 554ede5 + 89bc187 commit d013643

File tree

82 files changed

+3216
-922
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+3216
-922
lines changed

buildSrc/src/main/groovy/com/google/firebase/gradle/plugins/license/LicenseResolverPlugin.groovy

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package com.google.firebase.gradle.plugins.license
1616

17+
import com.android.build.gradle.tasks.BundleAar
1718
import com.google.firebase.gradle.plugins.license.RemoteLicenseFetcher.AnotherMITLicenseFetcher
1819
import com.google.firebase.gradle.plugins.license.RemoteLicenseFetcher.AndroidSdkTermsFetcher
1920
import com.google.firebase.gradle.plugins.license.RemoteLicenseFetcher.AnotherApache2LicenseFetcher
@@ -22,6 +23,7 @@ import com.google.firebase.gradle.plugins.license.RemoteLicenseFetcher.BSDLicens
2223
import com.google.firebase.gradle.plugins.license.RemoteLicenseFetcher.CreativeCommonsLicenseFetcher
2324
import com.google.firebase.gradle.plugins.license.RemoteLicenseFetcher.GnuClasspathLicenseFetcher
2425
import com.google.firebase.gradle.plugins.license.RemoteLicenseFetcher.MITLicenseFetcher
26+
import com.google.firebase.gradle.plugins.license.RemoteLicenseFetcher.YetAnotherApache2LicenseFetcher
2527
import org.gradle.api.Plugin
2628
import org.gradle.api.Project
2729
import org.gradle.api.artifacts.Configuration
@@ -49,8 +51,9 @@ class LicenseResolverPlugin implements Plugin<Project> {
4951
List<RemoteLicenseFetcher> remoteLicenseFetchers =
5052
[new AndroidSdkTermsFetcher(),
5153
new Apache2LicenseFetcher(),
52-
new BSDLicenseFetcher(),
5354
new AnotherApache2LicenseFetcher(),
55+
new YetAnotherApache2LicenseFetcher(),
56+
new BSDLicenseFetcher(),
5457
new CreativeCommonsLicenseFetcher(), new MITLicenseFetcher(), new AnotherMITLicenseFetcher(), new GnuClasspathLicenseFetcher()]
5558
final static ANDROID_PLUGINS = ["com.android.application", "com.android.library",
5659
"com.android.test"]
@@ -90,7 +93,7 @@ class LicenseResolverPlugin implements Plugin<Project> {
9093
outputDir = licensesDir
9194
}
9295

93-
project.tasks.getByName("bundleReleaseAar") {
96+
project.tasks.withType(BundleAar) {
9497
dependsOn licensesTask
9598
from licensesTask.outputDir
9699
}
@@ -102,4 +105,4 @@ class LicenseResolverPlugin implements Plugin<Project> {
102105
static isAndroidProject(project) {
103106
ANDROID_PLUGINS.find { plugin -> project.plugins.hasPlugin(plugin) }
104107
}
105-
}
108+
}

buildSrc/src/main/groovy/com/google/firebase/gradle/plugins/license/RemoteLicenseFetcher.groovy

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,24 @@ interface RemoteLicenseFetcher extends Serializable {
5656
}
5757
}
5858

59-
static final class BSDLicenseFetcher implements RemoteLicenseFetcher {
60-
private URI BSD_LICENSE_URI = URI.create("http://www.opensource.org/licenses/bsd-license.php")
59+
static final class AnotherApache2LicenseFetcher implements RemoteLicenseFetcher {
60+
private URI APACHE_2_LICENSE_URI = URI.create("https://opensource.org/licenses/Apache-2.0")
6161

6262
@Override
6363
URI getServiceUri() {
64-
BSD_LICENSE_URI
64+
APACHE_2_LICENSE_URI
6565
}
6666

6767
@Override
6868
String get() {
69-
def doc = Jsoup.connect(BSD_LICENSE_URI.toString()).get()
69+
def doc = Jsoup.connect(APACHE_2_LICENSE_URI.toString()).get()
7070

71-
TEXT_FORMATTER.getPlainText(doc.select('#content-wrapper')[0])
71+
TEXT_FORMATTER.getPlainText(doc.select('#content-wrapper'))
7272
}
7373
}
7474

75-
static final class AnotherApache2LicenseFetcher implements RemoteLicenseFetcher {
76-
private URI APACHE_2_LICENSE_URI = URI.create("https://opensource.org/licenses/Apache-2.0")
75+
static final class YetAnotherApache2LicenseFetcher implements RemoteLicenseFetcher {
76+
private URI APACHE_2_LICENSE_URI = URI.create("http://www.apache.org/licenses/LICENSE-2.0")
7777

7878
@Override
7979
URI getServiceUri() {
@@ -82,9 +82,23 @@ interface RemoteLicenseFetcher extends Serializable {
8282

8383
@Override
8484
String get() {
85-
def doc = Jsoup.connect(APACHE_2_LICENSE_URI.toString()).get()
85+
APACHE_2_LICENSE_URI.toURL().getText()
86+
}
87+
}
8688

87-
TEXT_FORMATTER.getPlainText(doc.select('#content-wrapper'))
89+
static final class BSDLicenseFetcher implements RemoteLicenseFetcher {
90+
private URI BSD_LICENSE_URI = URI.create("http://www.opensource.org/licenses/bsd-license.php")
91+
92+
@Override
93+
URI getServiceUri() {
94+
BSD_LICENSE_URI
95+
}
96+
97+
@Override
98+
String get() {
99+
def doc = Jsoup.connect(BSD_LICENSE_URI.toString()).get()
100+
101+
TEXT_FORMATTER.getPlainText(doc.select('#content-wrapper')[0])
88102
}
89103
}
90104

@@ -151,4 +165,4 @@ interface RemoteLicenseFetcher extends Serializable {
151165
TEXT_FORMATTER.getPlainText(doc.select('body > table > tbody > tr:nth-child(2) > td:nth-child(2) > table > tbody > tr:nth-child(3) > td > en > blockquote'))
152166
}
153167
}
154-
}
168+
}

buildSrc/src/main/groovy/com/google/firebase/gradle/plugins/publish/Publisher.groovy

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ package com.google.firebase.gradle.plugins.publish
1616

1717
import org.gradle.api.GradleException
1818
import org.gradle.api.Project
19+
import org.gradle.api.artifacts.Configuration
20+
import org.gradle.api.artifacts.Dependency
21+
import org.gradle.api.artifacts.ProjectDependency
1922
import org.gradle.api.publish.maven.MavenPublication
2023

2124
/** Handles publication versioning and pom validation upon release. */
@@ -26,7 +29,7 @@ class Publisher {
2629
SNAPSHOT
2730
}
2831
private final Mode mode;
29-
private final Set<Project> projectsToPublish;
32+
private final Set<Project> projectsToPublish
3033

3134
Publisher(Mode mode, Set<Project> projectsToPublish) {
3235
this.mode = mode
@@ -37,6 +40,7 @@ class Publisher {
3740
publication.pom.withXml {
3841
def rootNode = asNode()
3942
validatePomXml(project, rootNode)
43+
processDependencies(project, rootNode)
4044
}
4145
}
4246

@@ -51,7 +55,7 @@ class Publisher {
5155
return UNRELEASED_VERSION
5256
}
5357

54-
private void validatePomXml(Project p, Node pom) {
58+
private static void validatePomXml(Project p, Node pom) {
5559
def unreleased = pom.dependencies.dependency.findAll { it.version.text() == UNRELEASED_VERSION }
5660
.collect { "${it.groupId.text()}:${it.artifactId.text()}"}
5761
if(unreleased) {
@@ -63,4 +67,53 @@ class Publisher {
6367
return "${baseVersion}${mode == Mode.SNAPSHOT ? '-SNAPSHOT' : ''}"
6468
}
6569

70+
private static void processDependencies(Project project, Node pom) {
71+
def deps = getDependencyTypes(project)
72+
73+
pom.dependencies.dependency.each {
74+
// remove multidex as it is supposed to be added by final applications and is needed for
75+
// some libraries only for instrumentation tests to build.
76+
if (it.groupId.text() in ['com.android.support', 'androidx'] && it.artifactId.text() == 'multidex') {
77+
it.parent().remove(it)
78+
}
79+
it.appendNode('type', [:], deps["${it.groupId.text()}:${it.artifactId.text()}"])
80+
81+
// change scope to compile to preserve existing behavior
82+
it.scope.replaceNode {
83+
createNode('scope', 'compile')
84+
}
85+
}
86+
}
87+
88+
private static Map<String, String> getDependencyTypes(Project project) {
89+
def dummyDependencyConfiguration = project.configurations.create('publisherDummyConfig')
90+
def nonProjectDependencies = project.configurations.releaseRuntimeClasspath.allDependencies.findAll {
91+
!(it instanceof ProjectDependency)
92+
}
93+
dummyDependencyConfiguration.dependencies.addAll(nonProjectDependencies)
94+
try {
95+
return project.configurations.releaseRuntimeClasspath.getAllDependencies().collectEntries {
96+
[("$it.group:$it.name" as String): getType(dummyDependencyConfiguration, it)]
97+
}
98+
} finally {
99+
project.configurations.remove(dummyDependencyConfiguration)
100+
}
101+
102+
}
103+
104+
private static String getType(Configuration config, Dependency d) {
105+
if (d instanceof ProjectDependency) {
106+
// we currently only support aar libraries to be produced in this repository
107+
return 'aar'
108+
}
109+
String path = config.find {
110+
it.absolutePath.matches(".*\\Q$d.group/$d.name/$d.version/\\E[a-zA-Z0-9]+/\\Q$d.name-$d.version.\\E[aj]ar")
111+
}?.absolutePath
112+
if (path && path.endsWith (".aar")) {
113+
return "aar"
114+
} else {
115+
return "jar"
116+
}
117+
}
118+
66119
}

buildSrc/src/test/groovy/com/google/firebase/gradle/plugins/publish/PublishingPluginSpec.groovy

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,15 @@ class PublishingPluginSpec extends Specification {
4444
}
4545
dependencies {
4646
<%dependencies.each { println "implementation project(':$it.name')" } %>
47+
<%externalDependencies.each { println "implementation '$it'" } %>
4748
}
4849
'''
4950
String name
5051
String group = 'com.example'
5152
String version = 'undefined'
5253
String latestReleasedVersion = ''
5354
Set<Project> projectDependencies = []
55+
Set<String> externalDependencies = []
5456
Project releaseWith = null
5557
String customizePom = null
5658

@@ -60,6 +62,7 @@ class PublishingPluginSpec extends Specification {
6062
group: group,
6163
version: version,
6264
dependencies: projectDependencies,
65+
externalDependencies: externalDependencies,
6366
releaseWith: releaseWith,
6467
latestReleasedVersion: latestReleasedVersion,
6568
customizePom: customizePom,
@@ -253,6 +256,42 @@ licenses {
253256
dependency.version == project1.version
254257
}
255258

259+
def "Publish project should correctly set dependency types"() {
260+
Project project1 = new Project(name: 'childProject1', version: '1.0', latestReleasedVersion: '0.8')
261+
Project project2 = new Project(
262+
name: 'childProject2',
263+
version: '0.9',
264+
projectDependencies: [project1],
265+
externalDependencies: [
266+
'com.google.dagger:dagger:2.22',
267+
'com.google.dagger:dagger-android-support:2.22',
268+
'com.android.support:multidex:1.0.3'
269+
])
270+
271+
when: "publishFirebase invoked"
272+
subprojectsDefined(project1, project2)
273+
def result = publish(Mode.RELEASE, project2)
274+
then: 'poms exist'
275+
def pom1 = project1.getPublishedPom("$testProjectDir.root/build/m2repository")
276+
def pom2 = project2.getPublishedPom("$testProjectDir.root/build/m2repository")
277+
assert !pom1.isPresent()
278+
assert pom2.isPresent()
279+
280+
and: 'versions and dependency types are valid'
281+
282+
def xml2 = new XmlSlurper().parseText(pom2.get().text)
283+
xml2.version == project2.version
284+
def dependencies = xml2.dependencies.dependency.collect {
285+
"${it.groupId.text()}:${it.artifactId.text()}:${it.version.text()}:${it.type.text()}:${it.scope.text()}"
286+
} as Set<String>
287+
dependencies == [
288+
"$project1.group:$project1.name:$project1.latestReleasedVersion:aar:compile",
289+
'com.google.dagger:dagger:2.22:jar:compile',
290+
'com.google.dagger:dagger-android-support:2.22:aar:compile'
291+
] as Set<String>
292+
293+
}
294+
256295
private BuildResult build(String... args) {
257296
GradleRunner.create()
258297
.withProjectDir(testProjectDir.root)

firebase-common/firebase-common.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,13 @@ dependencies {
7878
androidTestImplementation 'org.mockito:mockito-core:2.21.0'
7979
androidTestImplementation 'com.linkedin.dexmaker:dexmaker:2.16.0'
8080
androidTestImplementation 'com.linkedin.dexmaker:dexmaker-mockito:2.16.0'
81-
androidTestImplementation ('com.google.firebase:firebase-auth:16.0.2') {
81+
androidTestImplementation ('com.google.firebase:firebase-auth:17.0.0') {
8282
exclude group: "com.google.firebase", module: "firebase-common"
8383
}
84+
8485
androidTestImplementation ('com.google.firebase:firebase-core:16.0.4') {
8586
exclude group: "com.google.firebase", module: "firebase-common"
8687
}
8788

8889
annotationProcessor 'com.google.auto.value:auto-value:1.6'
89-
}
90+
}

firebase-common/gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version=16.1.1
2-
latestReleasedVersion=16.1.0
1+
version=17.1.1
2+
latestReleasedVersion=17.1.0

firebase-common/src/androidTest/AndroidManifest.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
34
package="com.google.firebase.test">
45

5-
<uses-sdk android:minSdkVersion="14"/>
6+
<uses-sdk android:minSdkVersion="16" tools:overrideLibrary="com.google.firebase.auth"/>
67
<application>
78
<service android:name="com.google.firebase.components.ComponentDiscoveryService"
89
android:exported="false">
@@ -15,4 +16,4 @@
1516
</service>
1617
</application>
1718

18-
</manifest>
19+
</manifest>

0 commit comments

Comments
 (0)