Skip to content
This repository was archived by the owner on Dec 18, 2022. It is now read-only.

Commit f0ad243

Browse files
committed
implement ben manes' gradle versions plugin
1 parent d6b22ac commit f0ad243

File tree

2 files changed

+49
-7
lines changed

2 files changed

+49
-7
lines changed

build.gradle

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
apply plugin: 'org.jetbrains.dokka'
2-
31
buildscript {
42
apply from: "$rootDir/gradle/dependencies.gradle"
53

@@ -13,6 +11,7 @@ buildscript {
1311
classpath plugin.kotlin.dokka
1412
classpath plugin.kotlin.gradle
1513
classpath plugin.mavenPublish
14+
classpath plugin.gradleVersions
1615
}
1716
}
1817

@@ -28,6 +27,53 @@ allprojects {
2827
}
2928
}
3029

30+
task clean(type: Delete) {
31+
delete rootProject.buildDir
32+
}
33+
34+
////////////////////////////////////////////////////////////////////////////
35+
/// Gradle Versions: https://github.com/ben-manes/gradle-versions-plugin ///
36+
////////////////////////////////////////////////////////////////////////////
37+
38+
apply plugin: 'com.github.ben-manes.versions'
39+
40+
def isNonStable = { String version ->
41+
def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) }
42+
def regex = /^[0-9,.v-]+(-r)?$/
43+
return !stableKeyword && !(version ==~ regex)
44+
}
45+
46+
tasks.named("dependencyUpdates").configure {
47+
checkForGradleUpdate = true
48+
49+
// Example 1: reject all non stable versions
50+
rejectVersionIf {
51+
isNonStable(candidate.version)
52+
}
53+
54+
// Example 2: disallow release candidates as upgradable versions from stable versions
55+
rejectVersionIf {
56+
isNonStable(candidate.version) && !isNonStable(currentVersion)
57+
}
58+
59+
// Example 3: using the full syntax
60+
resolutionStrategy {
61+
componentSelection {
62+
all {
63+
if (isNonStable(candidate.version) && !isNonStable(currentVersion)) {
64+
reject('Release candidate')
65+
}
66+
}
67+
}
68+
}
69+
}
70+
71+
//////////////////////////////////////////////
72+
/// Dokka: https://github.com/Kotlin/dokka ///
73+
//////////////////////////////////////////////
74+
75+
apply plugin: 'org.jetbrains.dokka'
76+
3177
// Dokka's configuration.externalDocumentationLink.url setting for connecting methods/variables
3278
// in each module is quarky, especially when relying on Mkdocs to generate a website using the
3379
// Markdown files that are created. the `externalDocumentationLink.url` setting requires a
@@ -38,7 +84,3 @@ task fixDokkaDocLinks(type: Exec) {
3884
workingDir "$rootDir"
3985
commandLine "scripts/fix_dokka_doc_external_links.sh"
4086
}
41-
42-
task clean(type: Delete) {
43-
delete rootProject.buildDir
44-
}

gradle/dependencies.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ ext.deps = [
4545

4646
ext.plugin = [
4747
androidGradle: "com.android.tools.build:gradle:4.1.0",
48-
gradleVersions: "com.github.ben-manes:gradle-versions-plugin:0.20.0",
48+
gradleVersions: "com.github.ben-manes:gradle-versions-plugin:0.33.0",
4949
kotlin: [
5050
dokka: "org.jetbrains.dokka:dokka-gradle-plugin:0.10.1",
5151
gradle: "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}",

0 commit comments

Comments
 (0)