-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
288 lines (237 loc) · 7.48 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
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
import org.jetbrains.grammarkit.tasks.GenerateParser
import org.jetbrains.grammarkit.tasks.GenerateLexer
buildscript {
dependencies {
classpath "org.jetbrains.intellij.plugins:gradle-intellij-plugin:0.5.0-SNAPSHOT"
}
repositories {
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
maven {
url 'https://jetbrains.bintray.com/intellij-plugin-service'
}
maven {
url 'https://cache-redirector.jetbrains.com/intellij-dependencies'
}
}
}
plugins {
id 'java'
id 'idea'
id "org.jetbrains.intellij" version "0.6.3"
id "de.undercouch.download" version "3.2.0"
id "org.jetbrains.grammarkit" version "2020.3.1"
id 'net.ltgt.errorprone' version '2.0.1' apply false
}
wrapper {
gradleVersion='5.6.4'
}
def isRelease = System.getProperty('aldor.plugin.release', 'false')
List libFiles = ["aldor", "algebra", "foam", "foamj", "SpadType"]
def libSource = "/home/pab/Work/IdeaProjects/type-library/aldor-types/types/index/out/jar"
def libLocation = new File(libSource).exists() ? libSource : "extjars"
group 'pab.aldor'
version isRelease ? baseVersion : "${baseVersion}-SNAPSHOT"
println "VERSION IS ${baseVersion} Release: ${isRelease}"
tasks.withType(JavaCompile) { options.encoding = 'UTF-8' }
tasks.withType(Test) {
testLogging.showStandardStreams = true
testLogging.exceptionFormat = 'full'
systemProperties['aldor.build.skip_ci'] = System.getProperty('aldor.build.skip_ci')
}
java {
sourceCompatibility = JavaVersion.VERSION_11
}
intellij {
plugins = ['java']
downloadSources = true
type = 'IC'
pluginName = "${pluginName}"
version = "${platformVersion}"
updateSinceUntilBuild = true
}
runPluginVerifier {
ideVersions pluginVerifierIdeVersions
}
buildSearchableOptions {
}
allprojects {
apply plugin: 'java'
tasks.withType(JavaCompile) { options.encoding = 'UTF-8' }
repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
maven {
url 'https://dl.bintray.com/jetbrains/intellij-plugin-service'
}
maven {
url 'https://dl.bintray.com/jetbrains/intellij-third-party-dependencies/'
}
}
sourceSets {
main {
java.srcDirs 'src/main/java', 'src/gen/java'
resources.srcDirs 'resources'
}
test {
java.srcDir 'src/test/java'
}
}
}
grammarKit {
// version of IntelliJ patched JFlex (see bintray link below), Default is 1.7.0-1
jflexRelease = '1.7.0-1'
grammarKitRelease = '2020.1'
}
dependencies {
//errorprone 'com.google.errorprone:error_prone_core:2.6.0'
compile project('jps-plugin')
testCompile group: 'junit', name: 'junit', version: '4.13.2'
compile files(libFiles.collect({"lib/${it}.jar"}))
compile group: 'org.jetbrains.intellij.deps', name: 'asm-all', version: '8.0.1'
}
patchPluginXml {
sinceBuild("${pluginSinceBuild}")
untilBuild("${pluginUntilBuild}")
// changeNotes "Notes"
version
}
task downloadGrammarKit(type: Download) {
src 'https://github.com/JetBrains/Grammar-Kit/releases/download/2019.1/grammar-kit-2019.1.zip'
dest 'download/GrammarKit.zip'
overwrite false
outputs.file file(dest)
}
task downloadJFlexSkel(type: Download) {
src 'https://raw.githubusercontent.com/JetBrains/intellij-community/master/tools/lexer/idea-flex.skeleton'
dest 'lib/jflex/idea-flex.skeleton'
overwrite false
outputs.file 'lib/jflex/idea-flex.skeleton'
}
task downloadJFlex(type: Download) {
src 'https://bintray.com/jetbrains/intellij-third-party-dependencies/download_file?file_path=org%2Fjetbrains%2Fintellij%2Fdeps%2Fjflex%2Fjflex%2F1.7.0%2Fjflex-1.7.0.jar'
dest 'lib/jflex/jflex-1.7.0-SNAPSHOT.jar'
overwrite false
outputs.file 'lib/jflex/jflex-1.7.0-SNAPSHOT.jar'
}
task cleanLexer {
doLast {
for (f in generateLexer.outputs.files) { delete f }
}
}
task cleanLibs {
doLast {
for (f in libFiles) { delete "lib/${f}.jar"}
}
}
tasks.clean.dependsOn tasks.cleanLexer
tasks.clean.dependsOn tasks.cleanLibs
task generateLexer(type: GenerateLexer) {
source = "src/main/jflex/aldor/lexer/aldor.flex"
targetDir = "src/gen/java/aldor/lexer"
targetClass = "AldorLexer"
skeleton = 'lib/jflex/idea-flex.skeleton'
purgeOldFiles = true
}
task generateLexer1(type: JavaExec) {
String pkg = 'aldor/lexer'
String src = "$project.projectDir/src/main/jflex/${pkg}/aldor.flex"
String dst = "src/gen/jflex/" + pkg
doFirst {
delete file(dst)
}
main = 'jflex.Main'
classpath = files('lib/jflex/jflex-1.7.0-SNAPSHOT.jar')
inputs.files files(['lib/jflex/jflex-1.7.0-SNAPSHOT.jar', 'lib/jflex/idea-flex.skeleton', src])
outputs.files fileTree("${dst}").include('**/*.java')
}
task copyLibraryFiles(type: Copy) {
from libFiles.collect({"${libLocation}/${it}.jar"})
into 'lib'
doLast {
println("copied library files from " + libLocation)
}
}
task updateExternalJars(type: Copy) {
from libFiles.collect({"${libLocation}/${it}.jar"})
into 'extjars'
eachFile {
if (it.relativePath.getFile(destinationDir).exists()) {
it.exclude()
}
}
doLast {
println("updated external library files from " + libLocation)
}
}
task list(dependsOn: configurations.compile) {
doLast {
println "classpath = ${configurations.runtime.collect { File file -> file.toString() }}"
}
}
task listCompileOnly(dependsOn: configurations.compile) {
doLast {
for (f in project.configurations.compileOnly.files) {
println "compileOnly "+ f
}
}
}
tasks.prepareSandbox.dependsOn project('aldorunit').tasks.jar
tasks.prepareTestingSandbox.dependsOn project('aldorunit').tasks.jar
prepareTestingSandbox {
from(project('aldorunit').tasks.jar) {
into "${intellij.pluginName}/aldorunit"
}
}
prepareSandbox {
from(project('aldorunit').tasks.jar) {
into "${intellij.pluginName}/aldorunit"
}
eachFile {
println "File: ${it}"
}
}
tasks.generateLexer.dependsOn tasks.downloadJFlex
tasks.generateLexer.dependsOn tasks.downloadJFlexSkel
parserTask(project, "Aldor", "aldor/parser")
parserTask(project, "Expression", "aldor/expression")
tasks.compileJava.dependsOn tasks.generateAldorParser
tasks.compileJava.dependsOn tasks.generateExpressionParser
tasks.compileJava.dependsOn tasks.generateLexer
tasks.compileJava.dependsOn tasks.copyLibraryFiles
tasks.compileJava.dependsOn tasks.updateExternalJars
def parserTask(project, parserName, pkg) {
def tt = tasks.create(name: "generate${parserName}Parser", type: GenerateParser) {
source = "${project.projectDir}/src/main/grammar/${parserName}.bnf"
targetRoot = "src/gen/java"
pathToParser = "${pkg}/${parserName}Parser.java"
pathToPsiRoot = "${pkg}/psi"
purgeOldFiles = true
def extra = 'fastutil'
}
def cleaner = tasks.create("clean${parserName}Parser") {
outputs.upToDateWhen { false }
doLast {
for (f in tt.outputs.getFiles()) { println 'clean ' + f + " " + f.class.canonicalName}
for (f in tt.outputs.getFiles()) { f.delete() }
}
}
tasks.clean.dependsOn cleaner
return tt
}
test {
testLogging {
events "failed"
exceptionFormat "full"
}
maxHeapSize = "6g"
}
idea {
module {
downloadSources = true
}
}