HRM
/
build.gradle.kts
76 строк · 2.0 Кб
1import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
2import io.gitlab.arturbosch.detekt.Detekt
3
4buildscript {
5repositories {
6mavenCentral()
7jcenter()
8maven(url = "https://plugins.gradle.org/m2/")
9}
10dependencies {
11classpath(kotlin("gradle-plugin", version = "1.6.10"))
12classpath(kotlin("serialization", version = "1.6.10"))
13classpath("org.openjfx:javafx-plugin:0.0.9")
14classpath("com.github.ben-manes:gradle-versions-plugin:0.29.0")
15}
16}
17
18plugins {
19id("io.gitlab.arturbosch.detekt").version("1.19.0")
20}
21
22allprojects {
23apply(plugin = "com.github.ben-manes.versions")
24
25repositories {
26mavenCentral()
27jcenter()
28maven(url = "https://oss.sonatype.org/content/repositories/snapshots/")
29}
30
31tasks.withType<DependencyUpdatesTask> {
32rejectVersionIf {
33isNonStable(candidate.version)
34}
35}
36}
37
38dependencies {
39detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.19.0")
40}
41
42val detektAll by tasks.registering(Detekt::class) {
43description = "Reformats whole code base."
44parallel = true
45disableDefaultRuleSets = false
46buildUponDefaultConfig = true
47autoCorrect = true
48setSource(files(projectDir))
49include("**/*.kt")
50include("**/*.kts")
51exclude("**/resources/**")
52exclude("**/build/**")
53config.setFrom(files(projectDir.resolve("${rootProject.projectDir}/detekt/all.yml")))
54reports {
55xml.required.set(false)
56html.required.set(true)
57txt.required.set(true)
58}
59}
60
61tasks {
62withType<Detekt> {
63this.jvmTarget = "1.8"
64}
65}
66
67tasks.register("clean", Delete::class) {
68delete(rootProject.buildDir)
69}
70
71fun isNonStable(version: String): Boolean {
72val stableKeyword = listOf("alpha", "beta", "rc", "cr", "m", "preview", "b", "ea").any { version.toUpperCase().contains(it) }
73val regex = "^[0-9,.v-]+(-r)?$".toRegex()
74val isStable = stableKeyword || regex.matches(version)
75return isStable.not()
76}
77