build.gradle 12.9 KB
Newer Older
René Schöne's avatar
René Schöne committed
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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
buildscript {
    repositories.mavenCentral()
    dependencies {
        classpath 'org.jastadd:jastaddgradle:1.13.3'
        classpath fileTree(include: ['buildSrc.jar'], dir: '../libs')
    }
}

import org.jastadd.relast.plugin.RelastPlugin
import org.jastadd.relast.plugin.RelastTest

plugins {
    id 'java'
    id 'java-library'
    id 'idea'
    id 'com.github.ben-manes.versions' version '0.36.0'
    id 'com.google.protobuf' version "0.8.14"
}

apply plugin: 'jastadd'
apply plugin: RelastPlugin

group = 'de.tudresden.inf.st'

repositories {
    mavenCentral()
    jcenter()
}

dependencies {
    implementation project(':ragconnect.base')

    runtime group: 'org.jastadd', name: 'jastadd', version: '2.3.4'
    testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.4.0'
    testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.4.0'
    testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.12.1'

    // mqtt
    testImplementation group: 'org.fusesource.mqtt-client', name: 'mqtt-client', version: '1.15'

    // rest and client
    testImplementation group: 'com.sparkjava', name: 'spark-core', version: '2.9.2'
    testImplementation group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.11.2'
    testImplementation group: 'org.glassfish.jersey.core', name: 'jersey-client', version: '2.31'
    testImplementation group: 'org.glassfish.jersey.inject', name: 'jersey-hk2', version: '2.31'

    testImplementation group: 'net.sf.beaver', name: 'beaver-rt', version: '0.9.11'
    api group: 'com.google.protobuf', name: 'protobuf-java', version: '3.0.0'
}

test {
    useJUnitPlatform {
        excludeTags 'mqtt'
    }

    maxHeapSize = '1G'
}

protobuf {
    protoc {
        // The artifact spec for the Protobuf Compiler
        artifact = 'com.google.protobuf:protoc:3.0.0'
    }
}

task allTests(type: Test, dependsOn: testClasses) {
    description = 'Run every test'
    group = 'verification'

    useJUnitPlatform {
        includeTags 'mqtt'
    }
}

relastTest {
    //noinspection GroovyAssignabilityCheck
    compilerLocation = '../libs/relast.jar'
}

File genSrc = file("src/test/java-gen")
sourceSets.test.java.srcDir genSrc
idea.module.generatedSourceDirs += genSrc

clean {
    delete 'src/test/02-after-ragconnect/*/', 'src/test/03-after-relast/*/', 'src/test/java-gen/*/'
}

// --- Test: Example ---
task preprocessExampleTest(type: JavaExec, group: 'verification') {
    doFirst {
        delete 'src/test/02-after-ragconnect/example/Test.relast',
                'src/test/02-after-ragconnect/example/MqttHandler.jadd',
                'src/test/02-after-ragconnect/example/RagConnect.jadd'
    }

    classpath = sourceSets.main.runtimeClasspath
    main = 'org.jastadd.ragconnect.compiler.Compiler'
    args '--o=src/test/02-after-ragconnect/example',
            'src/test/01-input/example/Test.relast',
            'src/test/01-input/example/Test.connect',
            '--rootNode=Model',
            '--logReads', '--logWrites'
}

task compileExampleTest(type: RelastTest) {
    useJastAddNames = true
    jastAddList = 'JastAddList'
    relastFiles 'src/test/02-after-ragconnect/example/Test.relast',
            'src/test/02-after-ragconnect/example/RagConnect.relast'
    grammarName = 'src/test/03-after-relast/example/example'
    packageName = 'example.ast'
    moreInputFiles 'src/test/01-input/example/Test.jadd',
            'src/test/02-after-ragconnect/example/MqttHandler.jadd',
            'src/test/02-after-ragconnect/example/RagConnect.jadd'
}

compileTestJava.dependsOn compileExampleTest
compileExampleTest.dependsOn preprocessExampleTest

// --- Test: default-only-read ---
task preprocessDefaultOnlyReadTest(type: JavaExec, group: 'verification') {
    doFirst {
        delete 'src/test/02-after-ragconnect/defaultOnlyRead/Test.relast',
                'src/test/02-after-ragconnect/defaultOnlyRead/MqttHandler.jadd',
                'src/test/02-after-ragconnect/defaultOnlyRead/RagConnect.jadd'
    }

    classpath = sourceSets.main.runtimeClasspath
    main = 'org.jastadd.ragconnect.compiler.Compiler'
    args '--o=src/test/02-after-ragconnect/defaultOnlyRead',
            'src/test/01-input/defaultOnlyRead/Test.relast',
            'src/test/01-input/defaultOnlyRead/Test.connect',
            '--rootNode=A'
}

task compileDefaultOnlyReadTest(type: RelastTest) {
    useJastAddNames = true
    jastAddList = 'JastAddList'
    relastFiles 'src/test/02-after-ragconnect/defaultOnlyRead/Test.relast',
            'src/test/02-after-ragconnect/defaultOnlyRead/RagConnect.relast'
    grammarName = 'src/test/03-after-relast/defaultOnlyRead/defaultOnlyRead'
    packageName = 'defaultOnlyRead.ast'
    moreInputFiles 'src/test/02-after-ragconnect/defaultOnlyRead/MqttHandler.jadd',
            'src/test/02-after-ragconnect/defaultOnlyRead/RagConnect.jadd'
}

compileTestJava.dependsOn compileDefaultOnlyReadTest
compileDefaultOnlyReadTest.dependsOn preprocessDefaultOnlyReadTest

// --- Test: default-only-write ---
task preprocessDefaultOnlyWriteTest(type: JavaExec, group: 'verification') {
    doFirst {
        delete 'src/test/02-after-ragconnect/defaultOnlyWrite/Test.relast',
                'src/test/02-after-ragconnect/defaultOnlyWrite/MqttHandler.jadd',
                'src/test/02-after-ragconnect/defaultOnlyWrite/RagConnect.jadd'
    }

    classpath = sourceSets.main.runtimeClasspath
    main = 'org.jastadd.ragconnect.compiler.Compiler'
    args '--o=src/test/02-after-ragconnect/defaultOnlyWrite',
            'src/test/01-input/defaultOnlyWrite/Test.relast',
            'src/test/01-input/defaultOnlyWrite/Test.connect',
            '--rootNode=A'
}

task compileDefaultOnlyWriteTest(type: RelastTest) {
    useJastAddNames = true
    jastAddList = 'JastAddList'
    relastFiles 'src/test/02-after-ragconnect/defaultOnlyWrite/Test.relast',
            'src/test/02-after-ragconnect/defaultOnlyWrite/RagConnect.relast'
    grammarName = 'src/test/03-after-relast/defaultOnlyWrite/defaultOnlyWrite'
    packageName = 'defaultOnlyWrite.ast'
    moreInputFiles 'src/test/01-input/defaultOnlyWrite/Test.jadd',
            'src/test/02-after-ragconnect/defaultOnlyWrite/MqttHandler.jadd',
            'src/test/02-after-ragconnect/defaultOnlyWrite/RagConnect.jadd'
}

compileTestJava.dependsOn compileDefaultOnlyWriteTest
compileDefaultOnlyWriteTest.dependsOn preprocessDefaultOnlyWriteTest

// --- Test: read1write2 ---
task preprocessRead1Write2Test(type: JavaExec, group: 'verification') {
    doFirst {
        delete 'src/test/02-after-ragconnect/read1write2/Test.relast',
                'src/test/02-after-ragconnect/read1write2/MqttHandler.jadd',
                'src/test/02-after-ragconnect/read1write2/RagConnect.jadd'
    }

    classpath = sourceSets.main.runtimeClasspath
    main = 'org.jastadd.ragconnect.compiler.Compiler'
    args '--o=src/test/02-after-ragconnect/read1write2',
            'src/test/01-input/read1write2/Test.relast',
            'src/test/01-input/read1write2/Test.connect',
            '--rootNode=A'
}

task compileRead1Write2Test(type: RelastTest) {
    useJastAddNames = true
    jastAddList = 'JastAddList'
    relastFiles 'src/test/02-after-ragconnect/read1write2/Test.relast',
            'src/test/02-after-ragconnect/read1write2/RagConnect.relast'
    grammarName = 'src/test/03-after-relast/read1write2/read1write2'
    packageName = 'read1write2.ast'
    moreInputFiles 'src/test/01-input/read1write2/Test.jadd',
            'src/test/02-after-ragconnect/read1write2/MqttHandler.jadd',
            'src/test/02-after-ragconnect/read1write2/RagConnect.jadd'
}

compileTestJava.dependsOn compileRead1Write2Test
compileRead1Write2Test.dependsOn preprocessRead1Write2Test

// --- Test: read2write1 ---
task preprocessRead2Write1Test(type: JavaExec, group: 'verification') {
    doFirst {
        delete 'src/test/02-after-ragconnect/read2write1/Test.relast',
                'src/test/02-after-ragconnect/read2write1/MqttHandler.jadd',
                'src/test/02-after-ragconnect/read2write1/RagConnect.jadd'
    }

    classpath = sourceSets.main.runtimeClasspath
    main = 'org.jastadd.ragconnect.compiler.Compiler'
    args '--o=src/test/02-after-ragconnect/read2write1',
            'src/test/01-input/read2write1/Test.relast',
            'src/test/01-input/read2write1/Test.connect',
            '--rootNode=A'
}

task compileRead2Write1Test(type: RelastTest) {
    useJastAddNames = true
    jastAddList = 'JastAddList'
    relastFiles 'src/test/02-after-ragconnect/read2write1/Test.relast',
            'src/test/02-after-ragconnect/read2write1/RagConnect.relast'
    grammarName = 'src/test/03-after-relast/read2write1/read2write1'
    packageName = 'read2write1.ast'
    moreInputFiles 'src/test/01-input/read2write1/Test.jadd',
            'src/test/02-after-ragconnect/read2write1/MqttHandler.jadd',
            'src/test/02-after-ragconnect/read2write1/RagConnect.jadd'
}

compileTestJava.dependsOn compileRead2Write1Test
compileRead2Write1Test.dependsOn preprocessRead2Write1Test

// --- Test: via ---
task preprocessViaTest(type: JavaExec, group: 'verification') {
    doFirst {
        delete 'src/test/02-after-ragconnect/via/Test.relast',
                'src/test/02-after-ragconnect/via/MqttHandler.jadd',
                'src/test/02-after-ragconnect/via/RestHandler.jadd',
                'src/test/02-after-ragconnect/via/RagConnect.jadd'
    }

    classpath = sourceSets.main.runtimeClasspath
    main = 'org.jastadd.ragconnect.compiler.Compiler'
    args '--o=src/test/02-after-ragconnect/via',
            'src/test/01-input/via/Test.relast',
            'src/test/01-input/via/Test.connect',
            '--rootNode=A',
            '--protocols=mqtt,rest'
}

task compileViaTest(type: RelastTest) {
    useJastAddNames = true
    jastAddList = 'JastAddList'
    relastFiles 'src/test/02-after-ragconnect/via/Test.relast',
            'src/test/02-after-ragconnect/via/RagConnect.relast'
    grammarName = 'src/test/03-after-relast/via/via'
    packageName = 'via.ast'
    moreInputFiles 'src/test/01-input/via/Test.jadd',
            'src/test/02-after-ragconnect/via/MqttHandler.jadd',
            'src/test/02-after-ragconnect/via/RestHandler.jadd',
            'src/test/02-after-ragconnect/via/RagConnect.jadd'
}

compileTestJava.dependsOn compileViaTest
compileViaTest.dependsOn preprocessViaTest

// --- Test: token-value-send ---
task preprocessTokenValueSendTest(type: JavaExec, group: 'verification') {
    doFirst {
        delete 'src/test/02-after-ragconnect/tokenValueSend/Test.relast',
                'src/test/02-after-ragconnect/tokenValueSend/MqttHandler.jadd',
                'src/test/02-after-ragconnect/tokenValueSend/RestHandler.jadd',
                'src/test/02-after-ragconnect/tokenValueSend/RagConnect.jadd'
    }

    classpath = sourceSets.main.runtimeClasspath
    main = 'org.jastadd.ragconnect.compiler.Compiler'
    args '--o=src/test/02-after-ragconnect/tokenValueSend',
            'src/test/01-input/tokenValueSend/Test.relast',
            'src/test/01-input/tokenValueSend/Test.connect',
            '--rootNode=A'
}

task compileTokenValueSendTest(type: RelastTest) {
    useJastAddNames = true
    jastAddList = 'JastAddList'
    relastFiles 'src/test/02-after-ragconnect/tokenValueSend/Test.relast',
            'src/test/02-after-ragconnect/tokenValueSend/RagConnect.relast'
    grammarName = 'src/test/03-after-relast/tokenValueSend/tokenValueSend'
    packageName = 'tokenValueSend.ast'
    moreInputFiles 'src/test/01-input/tokenValueSend/Test.jadd',
            'src/test/02-after-ragconnect/tokenValueSend/MqttHandler.jadd',
            'src/test/02-after-ragconnect/tokenValueSend/RagConnect.jadd'
}

compileTestJava.dependsOn compileTokenValueSendTest
compileTokenValueSendTest.dependsOn preprocessTokenValueSendTest

// --- Test: tutorial ---
task preprocessTutorialTest(type: JavaExec, group: 'verification') {
    doFirst {
        delete 'src/test/02-after-ragconnect/tutorial/Test.relast',
                'src/test/02-after-ragconnect/tutorial/MqttHandler.jadd',
                'src/test/02-after-ragconnect/tutorial/RagConnect.jadd'
    }

    classpath = sourceSets.main.runtimeClasspath
    main = 'org.jastadd.ragconnect.compiler.Compiler'
    args '--o=src/test/02-after-ragconnect/tutorial',
            'src/test/01-input/tutorial/Test.relast',
            'src/test/01-input/tutorial/Test.connect',
            '--rootNode=A'
}

task compileTutorialTest(type: RelastTest) {
    useJastAddNames = true
    jastAddList = 'JastAddList'
    relastFiles 'src/test/02-after-ragconnect/tutorial/Test.relast',
            'src/test/02-after-ragconnect/tutorial/RagConnect.relast'
    grammarName = 'src/test/03-after-relast/tutorial/tutorial'
    packageName = 'tutorial.ast'
    moreInputFiles 'src/test/01-input/tutorial/Test.jadd',
            'src/test/02-after-ragconnect/tutorial/MqttHandler.jadd',
            'src/test/02-after-ragconnect/tutorial/RagConnect.jadd'
}

compileTestJava.dependsOn compileTutorialTest
compileTutorialTest.dependsOn preprocessTutorialTest