14
14
15
15
package com.google.firebase.gradle.plugins
16
16
17
- import java.io.File
18
17
import java.net.URL
19
18
import javax.xml.parsers.DocumentBuilderFactory
20
19
import org.gradle.api.DefaultTask
21
20
import org.gradle.api.GradleException
21
+ import org.gradle.api.file.RegularFile
22
22
import org.gradle.api.provider.Property
23
23
import org.gradle.api.tasks.Input
24
24
import org.gradle.api.tasks.InputFile
@@ -31,14 +31,13 @@ import org.w3c.dom.Element
31
31
* Compares the latest pom at gmaven for the given artifact with the one generate for the current
32
32
* release.
33
33
*
34
- * @throws GradleException if a dependency is found with a degraded version
35
- *
36
34
* @property pomFile The pom file for the current release
37
35
* @property artifactId The artifactId for the pom parent
38
36
* @property groupId The groupId for the pom parent
37
+ * @throws GradleException if a dependency is found with a degraded version
39
38
*/
40
39
abstract class PomValidator : DefaultTask () {
41
- @get:InputFile abstract val pomFile: Property <File >
40
+ @get:InputFile abstract val pomFile: Property <RegularFile >
42
41
@get:Input abstract val artifactId: Property <String >
43
42
@get:Input abstract val groupId: Property <String >
44
43
@@ -60,7 +59,7 @@ abstract class PomValidator : DefaultTask() {
60
59
doc
61
60
.findElementsByTag(" dependency" )
62
61
.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 }
64
63
.mapValues {
65
64
ModuleVersion .fromStringOrNull(it.value)
66
65
? : throw RuntimeException (" Invalid module version found for '${it.key} ': ${it.value} " )
@@ -76,7 +75,7 @@ abstract class PomValidator : DefaultTask() {
76
75
val documentBuilder = DocumentBuilderFactory .newInstance().newDocumentBuilder()
77
76
78
77
val oldPom = documentBuilder.parse(URL (url).openStream())
79
- val currentPom = documentBuilder.parse(pomFile.get())
78
+ val currentPom = documentBuilder.parse(pomFile.get().asFile )
80
79
81
80
val oldDependencies = getMapOfDependencies(oldPom.documentElement)
82
81
val currentDependencies = getMapOfDependencies(currentPom.documentElement)
@@ -89,4 +88,11 @@ abstract class PomValidator : DefaultTask() {
89
88
}
90
89
.joinToString(" \n " )
91
90
}
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
+ }
92
98
}
0 commit comments