This repository has been archived by the owner on Jun 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
111 lines (90 loc) · 2.89 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
buildscript {
ext.kotlin_version = '1.1.3'
ext.javaVersion = '1.8'
repositories {
mavenCentral()
maven { url 'http://dl.bintray.com/jetbrains/intellij-plugin-service' }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
plugins {
id "org.jetbrains.intellij" version "0.1.10"
}
apply plugin: 'idea'
idea {
module {
generatedSourceDirs += file('src/gen')
}
}
intellij {
pluginName 'intellij-crystal'
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
instrumentCode = false
publish {
username publishUsername
password publishPassword
channel publishChannel
}
}
apply plugin: 'java'
apply plugin: 'kotlin'
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
tasks.withType(JavaCompile) { options.encoding = 'UTF-8' }
sourceSets {
main {
java.srcDirs += 'src/gen'
// Exclude miglayout bundled with the IDE because we need a newer version, which
// is only available since 2016.3
compileClasspath = compileClasspath.filter { it.name != 'miglayout-swing.jar' }
}
}
group 'io.github.intellij-crystal'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
lexerTask(project, 'CrystalLexer', 'org/crystal/lang/core/parser')
parserTask(project, 'CrystalParser', 'org/crystal/lang/core/parser')
static def codegenTask(project, task) {
project.compileKotlin.dependsOn task
project.compileTestKotlin.dependsOn task
return task
}
def lexerTask(project, lexerName, pkg) {
return codegenTask(project, tasks.create("generate${lexerName}", JavaExec) {
def src = "$project.projectDir/src/main/grammars/${lexerName}.flex"
def dst = "$project.projectDir/src/gen/$pkg"
main = 'jflex.Main'
classpath = files('lib/jflex/jflex-1.7.0-SNAPSHOT.jar')
args = ['--skel', 'lib/jflex/idea-flex.skeleton',
'-d', dst,
src
]
inputs.file file(src)
outputs.dir file("$dst/_${lexerName}.java")
})
}
def parserTask(project, parserName, pkg) {
return codegenTask(project, tasks.create("generate${parserName}", JavaExec) {
def dstRoot = "$project.projectDir/src/gen"
def src = "$project.projectDir/src/main/grammars/${parserName}.bnf"
def dst = "$dstRoot/$pkg/$parserName"
doFirst {
delete file(dst)
}
main = 'org.intellij.grammar.Main'
classpath(configurations.compile + files('lib/grammar-kit.jar'))
args = [dstRoot, file(src)]
inputs.file file(src)
outputs.dir fileTree(dir: dst, include: '**/*.java')
})
}