forked from JetBrains/idea-gitignore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
217 lines (171 loc) · 5.16 KB
/
Copy pathbuild.gradle
File metadata and controls
217 lines (171 loc) · 5.16 KB
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
plugins {
id 'jacoco'
id 'org.jetbrains.intellij' version '0.3.1'
id 'de.undercouch.download' version '3.4.2'
id 'com.github.kt3k.coveralls' version '2.8.2'
}
apply plugin: 'org.jetbrains.intellij'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'checkstyle'
sourceCompatibility = javaVersion
targetCompatibility = javaTargetVersion
group pluginGroup
version = pluginVersion
tasks.withType(JavaCompile) { options.encoding = 'UTF-8' }
sourceSets {
main {
java.srcDirs 'src', 'gen'
resources.srcDir 'resources'
}
test {
java.srcDir 'tests'
resources.srcDir 'testData'
}
}
intellij {
version System.getenv().getOrDefault('IDEA_VERSION', ideaVersion)
type ideaType
pluginName pluginName
downloadSources Boolean.valueOf(sources)
sameSinceUntilBuild Boolean.valueOf(isEAP)
alternativeIdePath idePath
updateSinceUntilBuild false
plugins 'git4idea'
publishPlugin {
username publishUsername
password publishPassword
channels publishChannel
}
}
idea {
project {
jdkName = javaVersion
languageLevel = javaVersion
}
module {
generatedSourceDirs += file('gen')
}
}
checkstyle {
configFile = new File(rootDir, "gradle/checkstyle.xml")
}
// Configurations
configurations {
bnf
jflex
}
repositories {
mavenCentral()
maven { url 'https://dl.bintray.com/jetbrains/intellij-plugin-service' }
}
test {
testLogging {
exceptionFormat = 'full'
}
}
jacocoTestReport {
reports {
xml.enabled = true
html.enabled = true
}
}
dependencies {
bnf files("$buildDir/tools/GrammarKit/lib/grammar-kit.jar")
bnf files("$buildDir/tools/light-psi-all.jar")
jflex files("$buildDir/tools/JFlex.jar")
testCompile group: 'junit', name: 'junit', version: '4.11'
}
import groovy.io.FileType
// Tasks
task downloadJFlexJar(type: Download) {
description 'Downloads JFlex.'
src 'https://jetbrains.bintray.com/intellij-third-party-dependencies/org/jetbrains/intellij/deps/jflex/jflex/1.7.0/jflex-1.7.0.jar'
dest "$buildDir/tools/JFlex.jar"
onlyIf { !file("$buildDir/tools/JFlex.jar").exists() }
}
task downloadJFlexSkeleton(type: Download) {
description 'Downloads JFlex skeleton.'
src 'https://raw.github.com/JetBrains/intellij-community/master/tools/lexer/idea-flex.skeleton'
dest "$buildDir/tools/idea-flex.skeleton"
onlyIf { !file("$buildDir/tools/idea-flex.skeleton").exists() }
}
task generateLexer(type: JavaExec) {
description 'Generates lexer sources with JFlex.'
dependsOn downloadJFlexJar, downloadJFlexSkeleton
main = 'jflex.Main'
args = [
'-skel',
"$buildDir/tools/idea-flex.skeleton",
'-d',
'gen/mobi/hsz/idea/gitignore/lexer/',
'src/mobi/hsz/idea/gitignore/lexer/Ignore.flex',
]
classpath = configurations.jflex
}
task downloadGrammarKit(type: Download) {
description 'Downloads GrammarKit.'
src 'https://github.com/JetBrains/Grammar-Kit/releases/download/1.2.0.1/GrammarKit.zip'
dest "$buildDir/tools/GrammarKit.zip"
onlyIfNewer true
}
task downloadGrammarLightPsi(type: Download) {
description 'Downloads GrammarKit Light Psi.'
src 'https://github.com/JetBrains/Grammar-Kit/releases/download/1.2.0.1/light-psi-all.jar'
dest "$buildDir/tools/light-psi-all.jar"
onlyIfNewer true
}
task unzipGrammarKit(type: Copy) {
description 'Extracts GrammarKit files.'
dependsOn downloadGrammarKit
from zipTree("$buildDir/tools/GrammarKit.zip")
into "${buildDir}/tools/"
include "GrammarKit/lib/*"
}
task generateParser(type: JavaExec) {
description 'Generates parser sources with GrammarKit.'
dependsOn unzipGrammarKit, downloadGrammarLightPsi
main = 'org.intellij.grammar.Main'
args = [ 'gen', file('resources/bnf/Ignore.bnf').absolutePath ]
classpath = configurations.bnf + configurations.compile
}
task pullResources(type: Exec) {
description 'Pulls gitignore resources from Git.'
workingDir 'resources/gitignore'
commandLine 'git', 'pull', 'origin', 'master'
}
task generateTemplatesList() {
description 'Generates templates list based on the gitignore submodule.'
dependsOn pullResources
def content = "";
file('resources/gitignore').eachFileRecurse (FileType.FILES) { file ->
if (file.name.endsWith(".gitignore")) {
content += relativePath(file).substring(10) + "\n"
}
}
file('resources/templates.list').write(content)
}
task generateSources() {
if (Boolean.valueOf(runGenerators)) {
dependsOn generateParser, generateLexer, generateTemplatesList
}
}
clean.doFirst {
delete 'gen', 'out'
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
if (!Boolean.valueOf(System.getenv('CI'))) {
def javaHome = System.getenv("JAVA_HOME")
if (null == javaHome || "".equals(javaHome)) {
javaHome = JDK6_HOME
}
options.bootClasspath = "$javaHome/jre/lib/rt.jar"
}
}
afterEvaluate {
tasks.getByName('runIde') {
jvmArgs(javaArguments)
}
}
compileJava.dependsOn generateSources