Skip to content

Commit b0c6d2d

Browse files
committed
Add ignored deps + RegularFile usage
1 parent d5ec939 commit b0c6d2d

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

buildSrc/src/main/java/com/google/firebase/gradle/plugins/BaseFirebaseLibraryPlugin.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ abstract class BaseFirebaseLibraryPlugin : Plugin<Project> {
7878

7979
protected fun getIsPomValidTask(project: Project, firebaseLibrary: FirebaseLibraryExtension) {
8080
project.tasks.register<PomValidator>("isPomDependencyValid") {
81-
pomFile.value(project.file("build/publications/mavenAar/pom-default.xml"))
82-
groupId.value(firebaseLibrary.groupId.get())
83-
artifactId.value(firebaseLibrary.artifactId.get())
81+
pomFile.set(project.layout.buildDirectory.file("publications/mavenAar/pom-default.xml"))
82+
groupId.set(firebaseLibrary.groupId.get())
83+
artifactId.set(firebaseLibrary.artifactId.get())
8484
dependsOn("generatePomFileForMavenAarPublication")
8585
}
8686
}

buildSrc/src/main/java/com/google/firebase/gradle/plugins/PomValidator.kt

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

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

17-
import java.io.File
1817
import java.net.URL
1918
import javax.xml.parsers.DocumentBuilderFactory
2019
import org.gradle.api.DefaultTask
2120
import org.gradle.api.GradleException
21+
import org.gradle.api.file.RegularFile
2222
import org.gradle.api.provider.Property
2323
import org.gradle.api.tasks.Input
2424
import org.gradle.api.tasks.InputFile
@@ -31,14 +31,13 @@ import org.w3c.dom.Element
3131
* Compares the latest pom at gmaven for the given artifact with the one generate for the current
3232
* release.
3333
*
34-
* @throws GradleException if a dependency is found with a degraded version
35-
*
3634
* @property pomFile The pom file for the current release
3735
* @property artifactId The artifactId for the pom parent
3836
* @property groupId The groupId for the pom parent
37+
* @throws GradleException if a dependency is found with a degraded version
3938
*/
4039
abstract class PomValidator : DefaultTask() {
41-
@get:InputFile abstract val pomFile: Property<File>
40+
@get:InputFile abstract val pomFile: Property<RegularFile>
4241
@get:Input abstract val artifactId: Property<String>
4342
@get:Input abstract val groupId: Property<String>
4443

@@ -60,7 +59,7 @@ abstract class PomValidator : DefaultTask() {
6059
doc
6160
.findElementsByTag("dependency")
6261
.associate { it.textByTag("artifactId") to it.textByTag("version") }
63-
.filter { it.key != "javax.inject" } // javax.inject doesn't respect SemVer and doesn't update
62+
.filterKeys { it !in IGNORED_DEPENDENCIES }
6463
.mapValues {
6564
ModuleVersion.fromStringOrNull(it.value)
6665
?: throw RuntimeException("Invalid module version found for '${it.key}': ${it.value}")
@@ -76,7 +75,7 @@ abstract class PomValidator : DefaultTask() {
7675
val documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder()
7776

7877
val oldPom = documentBuilder.parse(URL(url).openStream())
79-
val currentPom = documentBuilder.parse(pomFile.get())
78+
val currentPom = documentBuilder.parse(pomFile.get().asFile)
8079

8180
val oldDependencies = getMapOfDependencies(oldPom.documentElement)
8281
val currentDependencies = getMapOfDependencies(currentPom.documentElement)
@@ -89,4 +88,11 @@ abstract class PomValidator : DefaultTask() {
8988
}
9089
.joinToString("\n")
9190
}
91+
92+
companion object {
93+
val IGNORED_DEPENDENCIES =
94+
listOf(
95+
"javax.inject" // javax.inject doesn't respect SemVer and doesn't update
96+
)
97+
}
9298
}

0 commit comments

Comments
 (0)