-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathbuild.gradle
More file actions
247 lines (184 loc) · 6.04 KB
/
Copy pathbuild.gradle
File metadata and controls
247 lines (184 loc) · 6.04 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
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
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'de.undercouch:gradle-download-task:3.2.0'
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:1.0.2'
}
}
plugins {
id "jacoco"
id 'com.github.kt3k.coveralls' version '2.8.2'
id 'java'
id 'antlr'
id 'eclipse'
id 'idea'
id 'application'
}
import de.undercouch.gradle.tasks.download.Download
import java.util.regex.Matcher
import java.util.regex.Pattern
mainClassName = "de.peeeq.wurstio.Main"
version = "1.8.1.0"
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
jacoco {
toolVersion = "0.8.5"
}
jacocoTestReport {
reports {
xml.enabled true
}
afterEvaluate {
classDirectories = files(classDirectories.files.collect {
fileTree(dir: it,
exclude: ['**/ast/**', '**/jassAst/**', '**/jassIm/**', '**/luaAst/**', '**/antlr/**'])
})
}
}
String genDir = "$projectDir/src-gen"
sourceSets {
main {
java {
srcDir 'src/main/java'
srcDir genDir
}
resources {
srcDir 'src/main/resources'
}
}
}
repositories {
mavenLocal()
mavenCentral()
maven { url 'https://jitpack.io' }
jcenter()
}
dependencies {
// Antlr parsing library
antlr "org.antlr:antlr4:4.7"
// tool for generating AST-classes
compileOnly 'com.github.peterzeller:abstractsyntaxgen:3510802026'
// JUnit for testing
testCompile group: 'org.testng', name: 'testng', version: '6.14.3'
testCompile group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3'
// Google guava
compile 'com.google.guava:guava:26.0-jre'
// Better functional data structures:
compile 'io.vavr:vavr:1.0.0-alpha-3'
// Support for the vscode language server protocol
compile group: 'org.eclipse.lsp4j', name: 'org.eclipse.lsp4j', version: '0.7.0'
// @Nullable annotations
compile group: 'org.eclipse.jdt', name: 'org.eclipse.jdt.annotation', version: '2.1.0'
// Gson for json parsing
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
// Velocity template engine for generating Html documents from Hotdoc documentation
compile group: 'org.apache.velocity', name: 'velocity', version: '1.7'
// Chardet for guessing the file-encoding of a source-file
compile group: 'net.sourceforge.jchardet', name: 'jchardet', version: '1.0'
// Crigges' jmpq
compile 'com.github.inwc3:jmpq3:1.7.14'
// Water's wc3 libs
compile 'com.github.inwc3:wc3libs:257fcbd610'
// The setup tool for wurst.build handling
compile 'com.github.wurstscript:wurstsetup:e038293d07'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
// Smallcheck testing library:
testCompile group: 'com.github.peterzeller', name: 'java-smallcheck', version: '3f6a178ba7'
}
configurations.all {
exclude group: "org.slf4j", module: "slf4j-log4j12"
exclude group: "log4j", module: "log4j"
}
task genAst {
description = 'Compile ast specifications'
fileTree(dir: 'parserspec', include: '**/*.parseq').each { file ->
Pattern PACKAGE_PATTERN = Pattern.compile("package\\s+(\\S+)\\s*;");
String fileContents = file.text
Matcher matcher = PACKAGE_PATTERN.matcher(fileContents);
String packageName = "";
if (matcher.find()) {
packageName = matcher.group(1);
}
String targetDir = "$genDir/" + packageName.replace(".", "/")
inputs.file(file)
outputs.dir(targetDir)
doLast {
javaexec {
classpath configurations.compileOnly
main = "asg.Main"
args = [file, targetDir]
}
}
}
}
task versionInfoFile {
description "Generates a file CompileTimeInfo.java with version number etc."
String gitRevision = "unknown-version"
String gitRevisionlong = "unknown-version"
new ByteArrayOutputStream().withStream { os ->
def result = exec {
executable = 'git'
args = ['describe', '--tags', '--always']
standardOutput = os
}
gitRevision = os.toString().trim()
}
new ByteArrayOutputStream().withStream { os ->
def result = exec {
executable = 'git'
args = ['describe', '--tags', '--always', '--abbrev=0']
standardOutput = os
}
gitRevisionlong = os.toString().trim()
}
String wurstVersion = "${version}-${gitRevision}"
inputs.property("wurstVersion", wurstVersion)
def dir = new File('./src-gen/de/peeeq/wurstscript/')
def f = new File(dir, 'CompileTimeInfo.java')
outputs.file(f)
doLast {
dir.mkdirs()
String currentTime = new Date().format("yyyy/MM/dd KK:mm:ss")
f.text = """
package de.peeeq.wurstscript;
public class CompileTimeInfo {
public static final String time="${currentTime}";
public static final String revision="${gitRevision}";
public static final String revisionLong="${gitRevisionlong}";
public static final String version="${wurstVersion}";
}
"""
}
}
task gen {
description "Generates code from various input files"
}
gen.dependsOn genAst
gen.dependsOn versionInfoFile
gen.dependsOn generateGrammarSource
compileJava.dependsOn gen
test {
// set minimal heap size required to run tests:
maxHeapSize = "1G"
useTestNG()
}
// delete the generated sources on clean
clean.doFirst {
delete genDir
}
//task wrapper(type: Wrapper) {
// gradleVersion = '2.12'
//}
apply plugin: 'de.undercouch.download'
task downloadZipFile(type: Download) {
src 'https://github.com/wurstscript/wurstStdlib2/archive/master.zip'
dest new File(buildDir, 'stdlib2.zip')
}
task downloadAndUnzipFile(dependsOn: downloadZipFile, type: Copy) {
from zipTree(downloadZipFile.dest)
into new File(buildDir, '/deps/')
}
apply from: 'deploy.gradle'