Skip to content

Commit 5171ee4

Browse files
committed
improve version update check
1 parent 21ecf04 commit 5171ee4

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

buildSrc/src/main/kotlin/openapi-parser.java-conventions.gradle.kts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import com.github.benmanes.gradle.versions.reporter.PlainTextReporter
2+
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
13
import org.gradle.accessors.dm.LibrariesForLibs
24

35
plugins {
@@ -94,3 +96,45 @@ configure<org.checkerframework.gradle.plugin.CheckerFrameworkExtension> {
9496
)
9597
}
9698

99+
100+
101+
102+
103+
tasks.withType<DependencyUpdatesTask> {
104+
rejectVersionIf {
105+
candidate.version.isNonStable()
106+
}
107+
108+
outputFormatter {
109+
exceeded.dependencies.removeIf { d -> ignore.contains("${d.group}:${d.name}") }
110+
111+
val plainTextReporter = PlainTextReporter(
112+
project,
113+
revision,
114+
gradleReleaseChannel
115+
)
116+
plainTextReporter.write(System.out, this)
117+
}
118+
}
119+
120+
121+
fun String.isNonStable(): Boolean {
122+
val nonStable = listOf(
123+
".M[0-9]+$",
124+
".RC[0-9]*$",
125+
".alpha[0-9]+$",
126+
".beta[0-9]+$",
127+
)
128+
129+
for (n in nonStable) {
130+
if (this.contains("(?i)$n".toRegex())) {
131+
return true
132+
}
133+
}
134+
135+
return false
136+
}
137+
138+
val ignore = listOf(
139+
"org.checkerframework:jdk8"
140+
)

0 commit comments

Comments
 (0)