forked from carlrobertoh/CodeGPT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
165 lines (138 loc) · 4.48 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
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.changelog.Changelog
import org.jetbrains.changelog.markdownToHTML
import java.io.FileInputStream
import java.util.*
val env = environment("env").getOrNull()
fun loadProperties(filename: String): Properties = Properties().apply {
load(FileInputStream(filename))
}
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)
}
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"))
}
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(libs.jsoup)
implementation(libs.commons.text)
implementation(libs.jtokkit)
testImplementation(kotlin("test"))
}
tasks.register<Exec>("updateSubmodules") {
workingDir(rootDir)
commandLine("git", "submodule", "update", "--init", "--recursive")
}
tasks.register<Copy>("copyLlamaSubmodule") {
dependsOn("updateSubmodules")
from(layout.projectDirectory.file("src/main/cpp/llama.cpp"))
into(layout.buildDirectory.dir("idea-sandbox/plugins/CodeGPT/llama.cpp"))
}
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("copyLlamaSubmodule")
}
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
}
}
}