forked from JetBrains/resharper-fsharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
305 lines (259 loc) · 10.7 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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
import com.jetbrains.rd.generator.gradle.RdgenParams
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.grammarkit.tasks.GenerateLexer
import org.jetbrains.intellij.IntelliJPlugin
import org.jetbrains.intellij.tasks.PrepareSandboxTask
import org.jetbrains.intellij.tasks.RunIdeTask
import org.jetbrains.kotlin.daemon.common.toHexString
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.net.URI
buildscript {
repositories {
maven { setUrl("https://cache-redirector.jetbrains.com/www.myget.org/F/rd-snapshots/maven") }
maven { setUrl("https://cache-redirector.jetbrains.com/dl.bintray.com/kotlin/kotlin-eap") }
maven { setUrl("https://cache-redirector.jetbrains.com/repo.maven.apache.org/maven2")}
}
dependencies {
classpath("com.jetbrains.rd:rd-gen:0.201.57")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50")
}
}
repositories {
maven { setUrl("https://cache-redirector.jetbrains.com/repo.maven.org/maven2")}
maven { setUrl("https://cache-redirector.jetbrains.com/repo.maven.apache.org/maven2")}
}
plugins {
id("org.jetbrains.intellij") version "0.4.13"
id("org.jetbrains.grammarkit") version "2018.1.7"
id("me.filippov.gradle.jvm.wrapper") version "0.9.3"
}
apply {
plugin("kotlin")
plugin("com.jetbrains.rdgen")
plugin("org.jetbrains.grammarkit")
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
val baseVersion = "2020.1"
val buildCounter = ext.properties["build.number"] ?: "9999"
version = "$baseVersion.$buildCounter"
intellij {
type = "RD"
// Download a version of Rider to compile and run with. Either set `version` to
// 'LATEST-TRUNK-SNAPSHOT' or 'LATEST-EAP-SNAPSHOT' or a known version.
// This will download from www.jetbrains.com/intellij-repository/snapshots or
// www.jetbrains.com/intellij-repository/releases, respectively.
// Note that there's no guarantee that these are kept up to date
// version = 'LATEST-TRUNK-SNAPSHOT'
// If the build isn't available in intellij-repository, use an installed version via `localPath`
// localPath = '/Users/matt/Library/Application Support/JetBrains/Toolbox/apps/Rider/ch-1/171.4089.265/Rider EAP.app/Contents'
// localPath = "C:\\Users\\Ivan.Shakhov\\AppData\\Local\\JetBrains\\Toolbox\\apps\\Rider\\ch-0\\171.4456.459"
// localPath = "C:\\Users\\ivan.pashchenko\\AppData\\Local\\JetBrains\\Toolbox\\apps\\Rider\\ch-0\\dev"
// localPath 'build/riderRD-173-SNAPSHOT'
val dir = file("build/rider")
if (dir.exists()) {
logger.lifecycle("*** Using Rider SDK from local path " + dir.absolutePath)
localPath = dir.absolutePath
} else {
logger.lifecycle("*** Using Rider SDK from intellij-snapshots repository")
version = "$baseVersion-SNAPSHOT"
}
instrumentCode = false
downloadSources = false
updateSinceUntilBuild = false
// Workaround for https://youtrack.jetbrains.com/issue/IDEA-179607
setPlugins("rider-plugins-appender")
}
repositories.forEach {
fun replaceWithCacheRedirector(u: URI): URI {
val cacheHost = "cache-redirector.jetbrains.com"
return if (u.scheme.startsWith("http") && u.host != cacheHost)
URI("https", cacheHost, "/${u.host}/${u.path}", u.query, u.fragment)
else u
}
when (it) {
is MavenArtifactRepository -> {
it.url = replaceWithCacheRedirector(it.url)
}
is IvyArtifactRepository -> {
it.url = replaceWithCacheRedirector(it.url)
}
}
}
val repoRoot = projectDir.parentFile!!
val resharperPluginPath = File(repoRoot, "ReSharper.FSharp")
val buildConfiguration = ext.properties["BuildConfiguration"] ?: "Debug"
val libFiles = listOf(
"FSharp.Common/bin/$buildConfiguration/net461/FSharp.Core.dll",
"FSharp.Common/bin/$buildConfiguration/net461/FSharp.Core.xml",
"FSharp.Common/bin/$buildConfiguration/net461/FSharp.Compiler.Service.dll", // todo: add pdb after next repack
"FSharp.Common/bin/$buildConfiguration/net461/FSharp.Compiler.Interactive.Settings.dll",
"FSharp.Psi.Features/bin/$buildConfiguration/net461/Fantomas.dll")
val pluginFiles = listOf(
"FSharp.ProjectModelBase/bin/$buildConfiguration/net461/JetBrains.ReSharper.Plugins.FSharp.ProjectModelBase",
"FSharp.Common/bin/$buildConfiguration/net461/JetBrains.ReSharper.Plugins.FSharp.Common",
"FSharp.Psi/bin/$buildConfiguration/net461/JetBrains.ReSharper.Plugins.FSharp.Psi",
"FSharp.Psi.Features/bin/$buildConfiguration/net461/JetBrains.ReSharper.Plugins.FSharp.Psi.Features",
"Daemon.FSharp/bin/$buildConfiguration/net461/JetBrains.ReSharper.Plugins.FSharp.Daemon.Cs",
"Services.FSharp/bin/$buildConfiguration/net461/JetBrains.ReSharper.Plugins.FSharp.Services.Cs")
val dotNetSdkPath by lazy {
val sdkPath = intellij.ideaDependency.classes.resolve("lib").resolve("DotNetSdkForRdPlugins")
if (sdkPath.isDirectory.not()) error("$sdkPath does not exist or not a directory")
println("SDK path: $sdkPath")
return@lazy sdkPath
}
val nugetConfigPath = File(repoRoot, "NuGet.Config")
val dotNetSdkPathPropsPath = File("build", "DotNetSdkPath.generated.props")
val riderFSharpTargetsGroup = "rider-fsharp"
fun File.writeTextIfChanged(content: String) {
val bytes = content.toByteArray()
if (!exists() || readBytes().toHexString() != bytes.toHexString()) {
println("Writing $path")
writeBytes(bytes)
}
}
configure<RdgenParams> {
val csOutput = File(repoRoot, "Resharper.FSharp/src/FSharp.ProjectModelBase/src/Protocol")
val ktOutput = File(repoRoot, "rider-fsharp/src/main/java/com/jetbrains/rider/plugins/fsharp/protocol")
verbose = true
hashFolder = "build/rdgen"
logger.info("Configuring rdgen params")
classpath({
logger.info("Calculating classpath for rdgen, intellij.ideaDependency is ${intellij.ideaDependency}")
val sdkPath = intellij.ideaDependency.classes
val rdLibDirectory = File(sdkPath, "lib/rd").canonicalFile
"$rdLibDirectory/rider-model.jar"
})
sources(File(repoRoot, "rider-fsharp/protocol/src/kotlin/model"))
packages = "model"
generator {
language = "kotlin"
transform = "asis"
root = "com.jetbrains.rider.model.nova.ide.IdeRoot"
namespace = "com.jetbrains.rider.model"
directory = "$ktOutput"
}
generator {
language = "csharp"
transform = "reversed"
root = "com.jetbrains.rider.model.nova.ide.IdeRoot"
namespace = "JetBrains.Rider.Model"
directory = "$csOutput"
}
}
tasks {
withType<PrepareSandboxTask> {
var files = libFiles + pluginFiles.map { "$it.dll" } + pluginFiles.map { "$it.pdb" }
files = files.map { "$resharperPluginPath/src/$it" }
if (name == IntelliJPlugin.PREPARE_TESTING_SANDBOX_TASK_NAME) {
val testHostPath = "$resharperPluginPath/test/src/FSharp.Tests.Host/bin/$buildConfiguration/net461"
val testHostName = "$testHostPath/JetBrains.ReSharper.Plugins.FSharp.Tests.Host"
files = files + listOf("$testHostName.dll", "$testHostName.pdb")
}
files.forEach {
from(it, { into("${intellij.pluginName}/dotnet") })
}
into("${intellij.pluginName}/projectTemplates") {
from("projectTemplates")
}
doLast {
files.forEach {
val file = file(it)
if (!file.exists()) throw RuntimeException("File $file does not exist")
logger.warn("$name: ${file.name} -> $destinationDir/${intellij.pluginName}/dotnet")
}
}
}
// Initially introduced in:
// https://github.com/JetBrains/ForTea/blob/master/Frontend/build.gradle.kts
withType<RunIdeTask> {
// IDEs from SDK are launched with 512m by default, which is not enough for Rider.
// Rider uses this value when launched not from SDK.
maxHeapSize = "1500m"
}
val generateFSharpLexer = task<GenerateLexer>("generateFSharpLexer") {
source = "src/main/java/com/jetbrains/rider/ideaInterop/fileTypes/fsharp/lexer/_FSharpLexer.flex"
targetDir = "src/main/java/com/jetbrains/rider/ideaInterop/fileTypes/fsharp/lexer"
targetClass = "_FSharpLexer"
purgeOldFiles = true
}
withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
dependsOn(generateFSharpLexer, "rdgen")
}
withType<Test> {
useTestNG()
testLogging {
showStandardStreams = true
exceptionFormat = TestExceptionFormat.FULL
}
val rerunSuccessfulTests = false
outputs.upToDateWhen { !rerunSuccessfulTests }
ignoreFailures = true
}
create("writeDotNetSdkPathProps") {
group = riderFSharpTargetsGroup
doLast {
dotNetSdkPathPropsPath.writeTextIfChanged("""<Project>
<PropertyGroup>
<DotNetSdkPath>$dotNetSdkPath</DotNetSdkPath>
</PropertyGroup>
</Project>
""")
}
getByName("buildSearchableOptions") {
enabled = buildConfiguration == "Release"
}
}
create("writeNuGetConfig") {
group = riderFSharpTargetsGroup
doLast {
nugetConfigPath.writeTextIfChanged("""<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="resharper-sdk" value="$dotNetSdkPath" />
</packageSources>
</configuration>
""")
}
}
getByName("assemble") {
doLast {
logger.lifecycle("Plugin version: $version")
logger.lifecycle("##teamcity[buildNumber '$version']")
}
}
create("prepare") {
group = riderFSharpTargetsGroup
dependsOn("rdgen", "writeNuGetConfig", "writeDotNetSdkPathProps")
}
create("buildReSharperPlugin") {
group = riderFSharpTargetsGroup
dependsOn("prepare")
doLast {
exec {
executable = "msbuild"
args = listOf("$resharperPluginPath/ReSharper.FSharp.sln")
}
}
}
task("listrepos"){
doLast {
logger.lifecycle("Repositories:")
project.repositories.forEach {
when (it) {
is MavenArtifactRepository -> logger.lifecycle("Name: ${it.name}, url: ${it.url}")
is IvyArtifactRepository -> logger.lifecycle("Name: ${it.name}, url: ${it.url}")
else -> logger.lifecycle("Name: ${it.name}, $it")
}
}
}
}
}
defaultTasks("prepare")
// workaround for https://youtrack.jetbrains.com/issue/RIDER-18697
dependencies {
testCompile("xalan", "xalan", "2.7.2")
}