forked from intellij-rust/intellij-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
213 lines (161 loc) · 5.87 KB
/
build.gradle
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
///////////////////////////////////////////////////////////////////////////////////////////////////
// Buildscript
///////////////////////////////////////////////////////////////////////////////////////////////////
buildscript {
repositories {
mavenCentral()
maven { url 'http://dl.bintray.com/jetbrains/intellij-plugin-service' }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
plugins {
id 'org.jetbrains.intellij' version "0.1.9"
id 'de.undercouch.download' version "2.1.0"
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// Projects
///////////////////////////////////////////////////////////////////////////////////////////////////
allprojects {
// IntelliJ plugin configuration
apply plugin: 'org.jetbrains.intellij'
apply plugin: 'de.undercouch.download'
intellij {
pluginName 'intellij-rust'
version ideaVersion
downloadSources Boolean.valueOf(downloadIdeaSources)
// FIXME: hack to support both IDEA 15 and IDEA 16.
// See https://github.com/intellij-rust/intellij-rust/issues/243
updateSinceUntilBuild = false
publish {
username publishUsername
password publishPassword
channel publishChannel
}
sandboxDirectory project.rootDir.canonicalPath + "/.sandbox"
}
apply plugin: 'java'
apply plugin: 'kotlin'
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
tasks.withType(JavaCompile) { options.encoding = 'UTF-8' }
sourceSets {
main.java.srcDirs += "gen"
}
test {
useJUnit {
excludeCategories 'org.rust.Performance'
}
testLogging {
events "passed", "skipped", "failed"
exceptionFormat = 'full'
}
}
repositories {
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
compile "org.jetbrains.kotlin:kotlin-runtime:$kotlinVersion"
testCompile "junit:junit:4.+"
testCompile 'org.assertj:assertj-core:3.2.0'
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// IDE support
///////////////////////////////////////////////////////////////////////////////////////////////////
apply plugin: 'idea'
idea {
project {
jdkName = javaVersion
languageLevel = javaVersion
}
module {
generatedSourceDirs += file('gen')
excludeDirs += file('.sandbox')
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// Tasks
///////////////////////////////////////////////////////////////////////////////////////////////////
task downloadJetBrainsJflex(type: de.undercouch.gradle.tasks.download.Download) {
overwrite false
src([
// This is a patched version of Jflex which is used together with GrammarKit.
'https://raw.github.com/JetBrains/intellij-community/idea/162.1145/tools/lexer/jflex-1.7.0-SNAPSHOT.jar',
'https://raw.github.com/JetBrains/intellij-community/idea/162.1145/tools/lexer/idea-flex.skeleton'
])
def jflexDir = new File(projectDir, 'lib/jflex')
if (!jflexDir.exists()) {
jflexDir.mkdirs()
}
dest(jflexDir)
}
def lexerConfig(src, dst, lexerFileName) {
return {
dependsOn downloadJetBrainsJflex
classpath = files('lib/jflex/jflex-1.7.0-SNAPSHOT.jar')
main = "jflex.Main"
args = ["--skel", 'lib/jflex/idea-flex.skeleton',
"-d", dst,
src
]
inputs .file file(src)
outputs .dir file(dst + lexerFileName)
}
}
task generateRustLexer(type: JavaExec) {
configure lexerConfig(
"src/main/kotlin/org/rust/lang/core/lexer/RustLexer.flex",
"gen/org/rust/lang/core/lexer/",
"_RustLexer.java"
)
}
task generateRustDocHighlightingLexer(type: JavaExec) {
configure lexerConfig(
"src/main/kotlin/org/rust/lang/doc/lexer/RustDocHighlightingLexer.flex",
"gen/org/rust/lang/doc/lexer/",
"_RustDocHighlightingLexer.java"
)
}
task generateRustPsiAndParser(type: JavaExec) {
doFirst {
delete file("gen/org/rust/lang/core/psi/")
}
ext.src = "src/main/kotlin/org/rust/lang/core/grammar/rust.bnf"
ext.dstRoot = "gen"
main = "org.intellij.grammar.Main"
args = [ dstRoot, file(src) ]
inputs .file file(src)
outputs .dir fileTree(dir: dstRoot + '/org/rust/lang/core/', include: '**/*.java')
classpath (configurations.compile + files('lib/grammar-kit.jar'))
}
task generate {
dependsOn generateRustLexer, generateRustDocHighlightingLexer, generateRustPsiAndParser
}
compileKotlin.dependsOn generate
compileTestKotlin.dependsOn generate
task downloadRustSources(type: de.undercouch.gradle.tasks.download.Download) {
overwrite false
src 'https://github.com/rust-lang/rust/archive/1.7.0.zip'
dest new File(projectDir, "src/test/resources/rustc-src.zip")
}
test.dependsOn downloadRustSources
task performanceTest(type: Test, group: 'Verification', dependsOn: [classes, testClasses, downloadRustSources]) {
useJUnit {
includeCategories 'org.rust.Performance'
reports.html.destination = "$buildDir/reports/performanceTests"
}
testLogging {
events "passed", "skipped", "failed"
showStandardStreams = true
exceptionFormat = 'full'
}
outputs.upToDateWhen { false } // always execute task, even if already executed.
}
check.dependsOn performanceTest
///////////////////////////////////////////////////////////////////////////////////////////////////
// Misc
///////////////////////////////////////////////////////////////////////////////////////////////////
version = "${version}.$buildNumber"