-
Notifications
You must be signed in to change notification settings - Fork 314
/
Copy pathbuild.gradle.kts
220 lines (190 loc) · 5.89 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.changelog.Changelog
import org.jetbrains.changelog.markdownToHTML
import org.jetbrains.intellij.tasks.RunIdeTask
import java.io.FileInputStream
import java.util.*
val localPropertiesFile = file("local.properties")
val env = environment("env").getOrNull()
fun loadProperties(filename: String): Properties = Properties().apply {
load(FileInputStream(filename))
}
val localProperties: Properties? = if (localPropertiesFile.exists()) {
loadProperties("local.properties")
} else {
null
}
val customIdePath: String? = localProperties?.getProperty("customIdePath")
fun properties(key: String): Provider<String> {
if ("win-arm64" == env) {
val property = loadProperties("gradle-win-arm64.properties").getProperty(key)
?: return providers.gradleProperty(key)
return providers.provider { property }
}
return providers.gradleProperty(key)
}
fun environment(key: String) = providers.environmentVariable(key)
plugins {
id("codegpt.java-conventions")
alias(libs.plugins.changelog)
alias(libs.plugins.protobuf)
}
group = properties("pluginGroup").get()
version = properties("pluginVersion").get() + "-" + properties("pluginSinceBuild").get()
checkstyle {
toolVersion = libs.versions.checkstyle.get()
}
repositories {
mavenCentral()
gradlePluginPortal()
}
intellij {
pluginName.set(properties("pluginName"))
version.set(properties("platformVersion"))
type.set(properties("platformType"))
plugins.set(listOf("java", "PythonCore:241.14494.240", "Git4Idea", "org.jetbrains.kotlin"))
}
changelog {
groups.empty()
repositoryUrl.set(properties("pluginRepositoryUrl"))
}
dependencies {
implementation(project(":codegpt-telemetry"))
implementation(project(":codegpt-treesitter"))
implementation(platform(libs.jackson.bom))
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation(libs.flexmark.all) {
// vulnerable transitive dependency
exclude(group = "org.jsoup", module = "jsoup")
}
implementation(kotlin("stdlib"))
implementation(kotlin("reflect"))
implementation(libs.jsoup)
implementation(libs.commons.text)
implementation(libs.jtokkit)
implementation(libs.grpc.protobuf)
implementation(libs.grpc.stub)
implementation(libs.grpc.netty.shaded)
testImplementation(kotlin("test"))
}
tasks.register<Exec>("updateSubmodules") {
workingDir(rootDir)
commandLine("git", "submodule", "update", "--init", "--recursive")
}
/**
* Task to run a custom IntelliJ IDEA sandbox.
*
* This task launches a custom IntelliJ IDEA installation using the path specified in the
* 'customIdePath' property from local.properties.
*
* IMPORTANT:
* - On macOS, the path must include the 'Contents' directory (e.g., /Applications/IntelliJ IDEA.app/Contents).
* - For Windows or Linux, specify the appropriate path to the IntelliJ IDEA installation.
*
* Usage:
* ./gradlew runCustomIde
*/
if (customIdePath != null) {
tasks.register<RunIdeTask>("runCustomIde") {
group = "intellij"
description = "Start custom idea sandbox"
ideDir.set(file(customIdePath))
environment("ENVIRONMENT", "LOCAL")
autoReloadPlugins.set(false)
}
}
tasks {
wrapper {
gradleVersion = properties("gradleVersion").get()
}
verifyPlugin {
enabled = true
}
runPluginVerifier {
enabled = true
}
patchPluginXml {
enabled = true
version.set(properties("pluginVersion").get() + "-" + properties("pluginSinceBuild").get())
sinceBuild.set(properties("pluginSinceBuild"))
untilBuild.set(properties("pluginUntilBuild"))
pluginDescription.set(providers.fileContents(layout.projectDirectory.file("DESCRIPTION.md")).asText.map {
val start = "<!-- Plugin description -->"
val end = "<!-- Plugin description end -->"
with(it.lines()) {
if (!containsAll(listOf(start, end))) {
throw GradleException("Plugin description section not found in DESCRIPTION.md:\n$start ... $end")
}
subList(indexOf(start) + 1, indexOf(end)).joinToString("\n").let(::markdownToHTML)
}
})
val changelog = project.changelog // local variable for configuration cache compatibility
// Get the latest available change notes from the changelog file
changeNotes.set(properties("pluginVersion").map { pluginVersion ->
with(changelog) {
renderItem(
(getOrNull(pluginVersion) ?: getUnreleased())
.withHeader(false)
.withEmptySections(false),
Changelog.OutputType.HTML,
)
}
})
}
prepareSandbox {
enabled = true
dependsOn("updateSubmodules")
from("src/main/cpp/llama.cpp") {
into("ProxyAI/llama.cpp")
}
}
signPlugin {
enabled = true
certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
privateKey.set(System.getenv("PRIVATE_KEY"))
password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
}
buildPlugin {
enabled = true
}
publishPlugin {
enabled = true
dependsOn("patchChangelog")
token.set(System.getenv("PUBLISH_TOKEN"))
channels.set(listOf("stable"))
}
runIde {
enabled = true
environment("ENVIRONMENT", "LOCAL")
autoReloadPlugins.set(false) // is triggered when building llama server
}
test {
exclude("**/testsupport/*")
useJUnitPlatform()
testLogging {
events("started", "passed", "skipped", "failed")
exceptionFormat = TestExceptionFormat.FULL
showStandardStreams = true
}
}
}
protobuf {
protoc {
artifact = libs.protobuf.protoc.get().toString()
}
plugins {
create("grpc") {
artifact = libs.protobuf.java.get().toString()
}
}
generateProtoTasks {
all()
.forEach {
it.plugins {
create("grpc")
}
}
}
}