-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle.kts
152 lines (126 loc) · 4.78 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import org.jetbrains.grammarkit.tasks.GenerateLexerTask
import org.jetbrains.grammarkit.tasks.GenerateParserTask
import org.jetbrains.intellij.tasks.RunIdeTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
alias(libs.plugins.com.diffplug.spotless)
alias(libs.plugins.com.github.ben.manes.versions)
alias(libs.plugins.io.gitlab.arturbosch.detekt)
alias(libs.plugins.nl.littlerobots.version.catalog.update)
alias(libs.plugins.org.gradle.test.retry)
alias(libs.plugins.org.jetbrains.grammarkit)
alias(libs.plugins.org.jetbrains.intellij)
alias(libs.plugins.org.jetbrains.kotlin.jvm)
java
}
spotless {
kotlin {
ktlint(libs.versions.com.pinterest.ktlint.get())
}
kotlinGradle {
target("*.gradle.kts")
ktlint(libs.versions.com.pinterest.ktlint.get())
}
}
detekt {
buildUponDefaultConfig = true
config.setFrom("$projectDir/detekt.yml")
}
group = "com.carbonblack"
version = "2.2.1"
tasks.compileJava {
options.release.set(17)
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "17"
}
tasks.withType<JavaCompile>().configureEach {
options.compilerArgs.add("-Xlint:deprecation")
options.compilerArgs.add("-Xlint:unchecked")
}
sourceSets {
main {
java.srcDir("$projectDir/src/main/gen")
}
}
tasks.withType<Test> {
environment("NO_FS_ROOTS_ACCESS_CHECK", "true")
// Workaround for IDEA-278926
// See https://youtrack.jetbrains.com/issue/IDEA-278926#focus=Comments-27-5561012.0-0
isScanForTestClasses = false
// Only run tests from classes that end with "Test"
include("**/*Test.class")
retry {
maxRetries.set(2)
}
}
tasks.withType<RunIdeTask> {
jvmArgs("-Xmx2048m")
}
repositories {
mavenCentral()
}
dependencies {
testImplementation(libs.io.mockk.mockk)
testImplementation(libs.io.strikt.strikt.core)
}
// See https://github.com/JetBrains/gradle-intellij-plugin/
intellij {
type.set("IC")
version.set(libs.versions.com.jetbrains.ideaIC)
updateSinceUntilBuild.set(false)
plugins.set(listOf("com.jetbrains.sh")) // , "au.com.glassechidna.luanalysis:1.2.2-IDEA203"))
}
val generateSpecParser = tasks.create<GenerateParserTask>("generateSpecParser") {
sourceFile.set(file("$projectDir/src/main/grammars/RpmSpecParser.bnf"))
targetRoot.set("$projectDir/src/main/gen")
pathToParser.set("/com/carbonblack/intellij/rpmspec/parser/RpmSpecParser.java")
pathToPsiRoot.set("/com/carbonblack/intellij/rpmspec/psi")
purgeOldFiles.set(true)
}
val generateSpecLexer = tasks.create<GenerateLexerTask>("generateSpecLexer") {
sourceFile.set(file("$projectDir/src/main/grammars/RpmSpecLexer.flex"))
skeleton.set(file("$projectDir/src/main/grammars/idea-flex.skeleton"))
targetDir.set("$projectDir/src/main/gen/com/carbonblack/intellij/rpmspec")
targetClass.set("_RpmSpecLexer")
purgeOldFiles.set(true)
}
val generateMacroParser = tasks.create<GenerateParserTask>("generateMacroParser") {
sourceFile.set(file("$projectDir/src/main/grammars/RpmMacroParser.bnf"))
targetRoot.set("$projectDir/src/main/gen")
pathToParser.set("/com/carbonblack/intellij/rpmmacro/parser/RpmMacroParser.java")
pathToPsiRoot.set("/com/carbonblack/intellij/rpmmacro/psi")
purgeOldFiles.set(true)
}
val generateMacroLexer = tasks.create<GenerateLexerTask>("generateMacroLexer") {
sourceFile.set(file("$projectDir/src/main/grammars/RpmMacroLexer.flex"))
skeleton.set(file("$projectDir/src/main/grammars/idea-flex.skeleton"))
targetDir.set("$projectDir/src/main/gen/com/carbonblack/intellij/rpmmacro")
targetClass.set("_RpmMacroLexer")
purgeOldFiles.set(true)
}
val generateShellLexer = tasks.create<GenerateLexerTask>("generateShellLexer") {
sourceFile.set(file("$projectDir/src/main/grammars/RpmSpecShellLexer.flex"))
skeleton.set(file("$projectDir/src/main/grammars/idea-flex.skeleton"))
targetDir.set("$projectDir/src/main/gen/com/carbonblack/intellij/rpmspec/shell")
targetClass.set("_RpmSpecShellLexer")
purgeOldFiles.set(true)
}
val generateGrammars: TaskProvider<Task> = tasks.register("generateGrammars") {
dependsOn(generateSpecParser, generateSpecLexer, generateMacroParser, generateMacroLexer, generateShellLexer)
}
tasks.withType<KotlinCompile> {
dependsOn(generateGrammars)
}
tasks.withType<DependencyUpdatesTask> {
fun isNonStable(version: String): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.uppercase().contains(it) }
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isStable = stableKeyword || regex.matches(version)
return isStable.not()
}
rejectVersionIf {
isNonStable(candidate.version) && !isNonStable(currentVersion)
}
}