-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathbuild.gradle.kts
240 lines (200 loc) · 6.61 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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
import org.jetbrains.changelog.exceptions.MissingVersionException
import org.jetbrains.intellij.platform.gradle.Constants
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
import org.jetbrains.intellij.platform.gradle.tasks.PrepareSandboxTask
import kotlin.io.path.absolute
import kotlin.io.path.isDirectory
import kotlin.io.path.isRegularFile
plugins {
alias(libs.plugins.changelog)
alias(libs.plugins.gradleJvmWrapper)
alias(libs.plugins.intelliJPlatform)
alias(libs.plugins.kotlinJvm)
}
allprojects {
repositories {
mavenCentral()
}
}
repositories {
intellijPlatform {
defaultRepositories()
jetbrainsRuntime()
}
}
val dotNetPluginId = "AvaloniaRider.Plugin"
val intellijPluginId = "avalonia-rider"
val untilBuildVersion: String by project
val pluginVersionBase: String by project
val buildRelease: String by project
dependencies {
intellijPlatform {
rider(libs.versions.riderSdk, useInstaller = false)
jetbrainsRuntime()
instrumentationTools()
bundledModule("intellij.rider")
bundledPlugins("com.jetbrains.xaml.previewer")
testFramework(TestFrameworkType.Bundled)
}
implementation(libs.bson4Jackson)
testImplementation(libs.openTest4J)
}
val buildConfiguration = ext.properties["buildConfiguration"] ?: "Debug"
val buildNumber = (ext.properties["buildNumber"] as String?)?.toInt() ?: 0
val dotNetSrcDir = File(projectDir, "src/dotnet")
val dotNetSdkGeneratedPropsFile = File(projectDir, "build/DotNetSdkPath.Generated.props")
val nuGetConfigFile = File(projectDir, "nuget.config")
version =
if (buildRelease.equals("true", ignoreCase = true) || buildRelease == "1") pluginVersionBase
else "$pluginVersionBase.$buildNumber"
fun File.writeTextIfChanged(content: String) {
val bytes = content.toByteArray()
if (!exists() || !readBytes().contentEquals(bytes)) {
println("Writing $path")
parentFile.mkdirs()
writeBytes(bytes)
}
}
sourceSets {
main {
kotlin.srcDir("src/rider/main/kotlin")
resources.srcDir("src/rider/main/resources")
}
}
tasks {
wrapper {
gradleVersion = "8.12.1"
distributionType = Wrapper.DistributionType.ALL
}
val riderSdkPath by lazy {
val path = intellijPlatform.platformPath.resolve("lib/DotNetSdkForRdPlugins").absolute()
if (!path.isDirectory()) error("$path does not exist or not a directory")
println("Rider SDK path: $path")
return@lazy path
}
val generateDotNetSdkProperties by registering {
doLast {
dotNetSdkGeneratedPropsFile.writeTextIfChanged("""<Project>
<PropertyGroup>
<DotNetSdkPath>$riderSdkPath</DotNetSdkPath>
</PropertyGroup>
</Project>
""")
}
}
val generateNuGetConfig by registering {
doLast {
nuGetConfigFile.writeTextIfChanged("""<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="rider-sdk" value="$riderSdkPath" />
</packageSources>
</configuration>
""")
}
}
val rdGen = ":protocol:rdgen"
register("prepare") {
dependsOn(rdGen, generateDotNetSdkProperties, generateNuGetConfig)
}
val compileDotNet by registering(Exec::class) {
dependsOn(rdGen, generateDotNetSdkProperties, generateNuGetConfig)
executable("dotnet")
args("build", "-c", buildConfiguration)
}
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
dependsOn(rdGen)
kotlinOptions {
jvmTarget = "17"
freeCompilerArgs = freeCompilerArgs + "-opt-in=kotlin.RequiresOptIn"
// TODO[#416]: Enable this after https://github.com/JetBrains/rd/issues/492 gets resolved.
// allWarningsAsErrors = true
}
}
patchPluginXml {
untilBuild.set(untilBuildVersion)
val latestChangelog = try {
changelog.getUnreleased()
} catch (_: MissingVersionException) {
changelog.getLatest()
}
changeNotes.set(provider {
changelog.renderItem(
latestChangelog
.withHeader(false)
.withEmptySections(false),
org.jetbrains.changelog.Changelog.OutputType.HTML
)
})
}
buildPlugin {
dependsOn(compileDotNet)
}
runIde {
jvmArgs("-Xmx1500m")
}
val generateDisabledPluginsTxt by registering { // RIDER-115748
val out = layout.buildDirectory.file("disabled_plugins.txt")
outputs.file(out)
doLast {
file(out).writeText(
"""
com.intellij.ml.llm
""".trimIndent()
)
}
}
withType<Test> {
useTestNG()
testLogging {
showStandardStreams = true
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
}
environment["LOCAL_ENV_RUN"] = "true"
}
withType<PrepareSandboxTask> {
dependsOn(compileDotNet, generateDisabledPluginsTxt)
from(generateDisabledPluginsTxt.map { it.outputs.files.singleFile }) {
into("../config-test")
}
val reSharperPluginDesc = "fvnever.$intellijPluginId"
from("src/extensions") { into("${rootProject.name}/dotnet/Extensions/$reSharperPluginDesc") }
val outputFolder = file("$dotNetSrcDir/$dotNetPluginId/bin/${dotNetPluginId}/$buildConfiguration")
val dllFiles = listOf(
"$outputFolder/${dotNetPluginId}.dll",
"$outputFolder/${dotNetPluginId}.pdb"
)
for (f in dllFiles) {
from(f) { into("${rootProject.name}/dotnet") }
}
doLast {
for (f in dllFiles) {
val file = file(f)
if (!file.exists()) throw RuntimeException("File \"$file\" does not exist")
}
}
}
val testRiderPreview by intellijPlatformTesting.testIde.registering {
version = libs.versions.riderSdkPreview
useInstaller = false
task {
enabled = libs.versions.riderSdk.get() != libs.versions.riderSdkPreview.get()
}
}
check { dependsOn(testRiderPreview.name) }
}
val riderModel: Configuration by configurations.creating {
isCanBeConsumed = true
isCanBeResolved = false
}
artifacts {
add(riderModel.name, provider {
intellijPlatform.platformPath.resolve("lib/rd/rider-model.jar").also {
check(it.isRegularFile()) {
"rider-model.jar is not found at \"$it\"."
}
}
}) {
builtBy(Constants.Tasks.INITIALIZE_INTELLIJ_PLATFORM_PLUGIN)
}
}