forked from intellij-rust/intellij-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
198 lines (162 loc) · 5.53 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
import org.jetbrains.intellij.tasks.PublishTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import de.undercouch.gradle.tasks.download.Download
import org.gradle.api.internal.HasConvention
import org.gradle.api.tasks.SourceSet
import org.jetbrains.grammarkit.GrammarKitPluginExtension
import org.jetbrains.grammarkit.tasks.GenerateLexer
import org.jetbrains.grammarkit.tasks.GenerateParser
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
import org.gradle.api.JavaVersion.VERSION_1_8
buildscript {
repositories {
maven { setUrl("https://jitpack.io") }
}
dependencies {
classpath("com.github.hurricup:gradle-grammar-kit-plugin:2017.1.1")
}
}
val CI = System.getenv("CI") != null
val channel = prop("publishChannel")
plugins {
idea
kotlin("jvm") version "1.1.4"
id("org.jetbrains.intellij") version "0.2.15"
id("de.undercouch.download") version "3.2.0"
}
allprojects {
apply {
plugin("idea")
plugin("kotlin")
plugin("org.jetbrains.grammarkit")
plugin("org.jetbrains.intellij")
}
repositories {
mavenCentral()
}
idea {
module {
generatedSourceDirs.add(file("src/gen"))
}
}
intellij {
version = prop("ideaVersion")
downloadSources = !CI
updateSinceUntilBuild = false
instrumentCode = false
}
configure<GrammarKitPluginExtension> {
grammarKitRelease = "1.5.2"
}
tasks.withType<PublishTask> {
username(prop("publishUsername"))
password(prop("publishPassword"))
channels(channel)
}
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
languageVersion = "1.1"
apiVersion = "1.1"
}
}
configure<JavaPluginConvention> {
sourceCompatibility = VERSION_1_8
targetCompatibility = VERSION_1_8
}
java.sourceSets {
getByName("main").java.srcDirs("src/gen")
}
}
val versionSuffix = if (channel.isBlank()) "" else "-$channel"
project(":") {
val clionVersion = prop("clionVersion")
version = "0.1.0.${prop("buildNumber")}$versionSuffix"
intellij { pluginName = "intellij-rust" }
idea {
module {
generatedSourceDirs.add(file("tstData"))
}
}
repositories {
maven { setUrl("https://dl.bintray.com/jetbrains/markdown") }
}
dependencies {
compile("org.jetbrains:markdown:0.1.12") {
exclude(module = "kotlin-runtime")
exclude(module = "kotlin-stdlib")
}
testCompile("org.assertj:assertj-core:3.2.0")
}
java.sourceSets {
getByName("main").kotlin.srcDirs("debugger/src/main/kotlin")
getByName("main").compileClasspath += files("debugger/lib/clion-$clionVersion/lib/clion.jar")
}
val generateRustLexer = task<GenerateLexer>("generateRustLexer") {
source = "src/main/grammars/RustLexer.flex"
targetDir = "src/gen/org/rust/lang/core/lexer"
targetClass = "_RustLexer"
purgeOldFiles = true
}
val generateRustDocHighlightingLexer = task<GenerateLexer>("generateRustDocHighlightingLexer") {
source = "src/main/grammars/RustDocHighlightingLexer.flex"
targetDir = "src/gen/org/rust/lang/doc/lexer"
targetClass = "_RustDocHighlightingLexer"
purgeOldFiles = true
}
val generateRustParser = task<GenerateParser>("generateRustParser") {
source = "src/main/grammars/RustParser.bnf"
targetRoot = "src/gen"
pathToParser = "/org/rust/lang/core/parser/RustParser.java"
pathToPsiRoot = "/org/rust/lang/core/psi"
purgeOldFiles = true
}
val downloadClion = task<Download>("downloadClion") {
src("https://download.jetbrains.com/cpp/CLion-$clionVersion.tar.gz")
dest(file("${project.projectDir}/debugger/lib/clion-$clionVersion.tar.gz"))
overwrite(false)
}
val unpackClion = task<Copy>("unpackClion") {
from(tarTree("debugger/lib/clion-$clionVersion.tar.gz"))
into(file("${project.projectDir}/debugger/lib"))
dependsOn(downloadClion)
}
tasks.withType<KotlinCompile> {
dependsOn(
generateRustLexer, generateRustDocHighlightingLexer,
generateRustParser, unpackClion
)
}
}
project(":toml") {
version = "0.1.0.${prop("buildNumber")}$versionSuffix"
intellij { pluginName = "intellij-toml" }
val generateTomlLexer = task<GenerateLexer>("generateTomlLexer") {
source = "src/main/grammars/TomlLexer.flex"
targetDir = "src/gen/org/toml/lang/core/lexer"
targetClass = "_TomlLexer"
purgeOldFiles = true
}
val generateTomlParser = task<GenerateParser>("generateTomlParser") {
source = "src/main/grammars/TomlParser.bnf"
targetRoot = "src/gen"
pathToParser = "/org/toml/lang/core/parser/TomlParser.java"
pathToPsiRoot = "/org/toml/lang/core/psi"
purgeOldFiles = true
}
tasks.withType<KotlinCompile> {
dependsOn(generateTomlLexer, generateTomlParser)
}
}
fun prop(name: String): String =
extra.properties[name] as? String
?: error("Property `$name` is not defined in gradle.properties")
inline operator fun <T : Task> T.invoke(a: T.() -> Unit): T = apply(a)
val SourceSet.kotlin: SourceDirectorySet
get() =
(this as HasConvention)
.convention
.getPlugin(KotlinSourceSet::class.java)
.kotlin
fun SourceSet.kotlin(action: SourceDirectorySet.() -> Unit) =
kotlin.action()