-
Notifications
You must be signed in to change notification settings - Fork 18
/
build.gradle.kts
152 lines (123 loc) · 3.54 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
@file:Suppress("VulnerableLibrariesLocal")
import org.jetbrains.grammarkit.tasks.GenerateLexerTask
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
fun stringProperty(key: String, default: String? = null): String =
findProperty(key)?.toString() ?: default ?: error("Expected a valid property $key")
plugins {
java
alias(libs.plugins.jetbrains.intellij)
alias(libs.plugins.jetbrains.grammarkit)
alias(libs.plugins.kotlin.jvm)
}
group = "com.github.lppedd"
repositories {
mavenCentral()
// For org.everit.json.schema
maven("https://jitpack.io")
maven("https://packages.jetbrains.team/maven/p/ij/intellij-dependencies")
}
dependencies {
implementation(kotlin("stdlib"))
implementation(libs.commons.validator) {
exclude("commons-beanutils", "commons-beanutils")
}
implementation(libs.org.json)
implementation(libs.org.json.schema)
// TODO: move to catalog if it is really needed
testImplementation("junit:junit:4.13.2")
}
intellij {
type = stringProperty("platformType")
version = stringProperty("platformVersion")
downloadSources = true
pluginName = "idea-conventional-commit"
plugins = listOf("java")
}
grammarKit {
// See https://github.com/JetBrains/intellij-deps-jflex/
jflexRelease = "1.9.2"
grammarKitRelease = "2021.1.2"
}
sourceSets {
main {
java {
srcDir("src/main/gen")
}
}
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlin {
explicitApiWarning()
compilerOptions {
jvmTarget = JvmTarget.JVM_17
languageVersion = KotlinVersion.KOTLIN_1_9
freeCompilerArgs.addAll(
"-Xno-call-assertions",
"-Xno-receiver-assertions",
"-Xno-param-assertions",
"-Xjvm-default=all",
"-Xallow-kotlin-package",
)
optIn.add("kotlin.contracts.ExperimentalContracts")
}
}
tasks {
wrapper {
distributionType = Wrapper.DistributionType.ALL
}
val generateLexer = task<GenerateLexerTask>("generateConventionalCommitLexer") {
source = "src/main/kotlin/com/github/lppedd/cc/language/lexer/conventionalCommit.flex"
targetDir = "src/main/gen/com/github/lppedd/cc/language/lexer"
targetClass = "ConventionalCommitFlexLexer"
purgeOldFiles = true
}
compileKotlin {
dependsOn(generateLexer)
}
compileTestKotlin {
dependsOn(generateLexer)
}
val versionStr = "$version"
val projectPath = layout.projectDirectory
patchPluginXml {
version = versionStr
sinceBuild = stringProperty("pluginSinceBuild")
untilBuild = stringProperty("pluginUntilBuild")
val pluginDescriptionFile = File("$projectPath/plugin-description.html")
pluginDescription = pluginDescriptionFile.readText()
val changeNotesFile = File("$projectPath/change-notes/${versionStr.replace('.', '_')}.html")
changeNotes = changeNotesFile.readText()
}
val buildApiSourceJar = task<Jar>("buildConventionalCommitApiSourceJar") {
dependsOn(generateLexer)
from(kotlin.sourceSets.main.get().kotlin) {
include("com/github/lppedd/cc/api/*.kt")
}
destinationDirectory = layout.buildDirectory.dir("libs")
archiveClassifier = "src"
}
buildPlugin {
dependsOn(buildApiSourceJar)
from(buildApiSourceJar) {
into("lib/src")
}
}
runPluginVerifier {
ideVersions = listOf(
"IC-2022.3",
"IC-2023.1",
"IC-2023.3",
"IC-2024.1",
)
}
runIde {
val dcevm = stringProperty("dcevmExecutable", default = "")
if (dcevm.isNotBlank()) {
executable = dcevm
}
}
}