build.gradle 9.57 KB
Newer Older
René Schöne's avatar
René Schöne committed
1
2
import org.jastadd.relast.plugin.RelastPlugin
import org.jastadd.relast.plugin.RelastTest
3
apply plugin: 'jastadd'
4
apply plugin: 'com.google.protobuf'
René Schöne's avatar
René Schöne committed
5
6
apply plugin: RelastPlugin

7
8
9
10
11
12
13
14
15
16
sourceCompatibility = 1.8

repositories {
    jcenter()
}

buildscript {
    repositories.jcenter()
    dependencies {
        classpath 'org.jastadd:jastaddgradle:1.13.3'
17
        classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.12'
18
    }
René Schöne's avatar
René Schöne committed
19
20
21
}

dependencies {
22
    implementation project(':ragconnect.base')
René Schöne's avatar
René Schöne committed
23
24
25
26
27

    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'
René Schöne's avatar
René Schöne committed
28
29
    testImplementation group: 'org.fusesource.mqtt-client', name: 'mqtt-client', version: '1.15'
    testImplementation group: 'net.sf.beaver', name: 'beaver-rt', version: '0.9.11'
30
    api group: 'com.google.protobuf', name: 'protobuf-java', version: '3.0.0'
René Schöne's avatar
René Schöne committed
31
32
}

33
test {
34
35
36
    useJUnitPlatform {
        excludeTags 'mqtt'
    }
37
38
39
40

    maxHeapSize = '1G'
}

41
42
43
44
45
46
47
protobuf {
    protoc {
        // The artifact spec for the Protobuf Compiler
        artifact = 'com.google.protobuf:protoc:3.0.0'
    }
}

48
49
50
51
52
53
54
55
56
task allTests(type: Test, dependsOn: testClasses) {
    description = 'Run every test'
    group = 'verification'

    useJUnitPlatform {
        includeTags 'mqtt'
    }
}

57
58
59
60
relastTest {
    compilerLocation = '../libs/relast.jar'
}

René Schöne's avatar
René Schöne committed
61
62
63
64
65
66
sourceSets {
    test {
        java.srcDir "src/test/java-gen"
    }
}

René Schöne's avatar
René Schöne committed
67
68
69
70
clean {
    delete 'src/test/02-after-ragconnect/*/', 'src/test/03-after-relast/*/', 'src/test/java-gen/*/'
}

71
// --- Test: Example ---
René Schöne's avatar
René Schöne committed
72
73
task preprocessExampleTest(type: JavaExec, group: 'verification') {
    doFirst {
74
        delete 'src/test/02-after-ragconnect/example/Test.relast',
75
76
                'src/test/02-after-ragconnect/example/MqttHandler.java',
                'src/test/02-after-ragconnect/example/RagConnect.jadd'
René Schöne's avatar
René Schöne committed
77
78
79
    }

    classpath = sourceSets.main.runtimeClasspath
80
    main = 'org.jastadd.ragconnect.compiler.Compiler'
81
82
83
    args '--o=src/test/02-after-ragconnect/example',
            'src/test/01-input/example/Test.relast',
            'src/test/01-input/example/Test.connect',
84
85
            '--rootNode=Model',
            '--logReads', '--logWrites'
René Schöne's avatar
René Schöne committed
86
87
88
}

task compileExampleTest(type: RelastTest) {
89
    useJastAddNames = true
90
    jastAddList = 'JastAddList'
91
92
    relastFiles 'src/test/02-after-ragconnect/example/Test.relast',
            'src/test/02-after-ragconnect/example/RagConnect.relast'
René Schöne's avatar
René Schöne committed
93
94
    grammarName = 'src/test/03-after-relast/example/example'
    packageName = 'example.ast'
René Schöne's avatar
René Schöne committed
95
    moreInputFiles 'src/test/01-input/example/Test.jadd',
96
97
            'src/test/02-after-ragconnect/example/MqttHandler.jadd',
            'src/test/02-after-ragconnect/example/RagConnect.jadd'
René Schöne's avatar
René Schöne committed
98
99
}

100
testClasses.dependsOn compileExampleTest
René Schöne's avatar
René Schöne committed
101
compileExampleTest.dependsOn preprocessExampleTest
102

103
104
105
// --- Test: default-only-read ---
task preprocessDefaultOnlyReadTest(type: JavaExec, group: 'verification') {
    doFirst {
106
        delete 'src/test/02-after-ragconnect/defaultOnlyRead/Test.relast',
107
108
                'src/test/02-after-ragconnect/defaultOnlyRead/MqttHandler.java',
                'src/test/02-after-ragconnect/defaultOnlyRead/RagConnect.jadd'
109
110
111
    }

    classpath = sourceSets.main.runtimeClasspath
112
    main = 'org.jastadd.ragconnect.compiler.Compiler'
113
114
115
    args '--o=src/test/02-after-ragconnect/defaultOnlyRead',
            'src/test/01-input/defaultOnlyRead/Test.relast',
            'src/test/01-input/defaultOnlyRead/Test.connect',
116
117
118
119
120
121
122
            '--rootNode=A',
            '--verbose'
}

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

131
testClasses.dependsOn compileDefaultOnlyReadTest
132
133
compileDefaultOnlyReadTest.dependsOn preprocessDefaultOnlyReadTest

René Schöne's avatar
René Schöne committed
134
135
136
// --- Test: default-only-write ---
task preprocessDefaultOnlyWriteTest(type: JavaExec, group: 'verification') {
    doFirst {
137
        delete 'src/test/02-after-ragconnect/defaultOnlyWrite/Test.relast',
138
139
                'src/test/02-after-ragconnect/defaultOnlyWrite/MqttHandler.java',
                'src/test/02-after-ragconnect/defaultOnlyWrite/RagConnect.jadd'
René Schöne's avatar
René Schöne committed
140
141
142
    }

    classpath = sourceSets.main.runtimeClasspath
143
    main = 'org.jastadd.ragconnect.compiler.Compiler'
144
145
146
    args '--o=src/test/02-after-ragconnect/defaultOnlyWrite',
            'src/test/01-input/defaultOnlyWrite/Test.relast',
            'src/test/01-input/defaultOnlyWrite/Test.connect',
René Schöne's avatar
René Schöne committed
147
148
149
150
151
152
153
            '--rootNode=A',
            '--verbose'
}

task compileDefaultOnlyWriteTest(type: RelastTest) {
    useJastAddNames = true
    jastAddList = 'JastAddList'
154
155
    relastFiles 'src/test/02-after-ragconnect/defaultOnlyWrite/Test.relast',
            'src/test/02-after-ragconnect/defaultOnlyWrite/RagConnect.relast'
René Schöne's avatar
René Schöne committed
156
157
    grammarName = 'src/test/03-after-relast/defaultOnlyWrite/defaultOnlyWrite'
    packageName = 'defaultOnlyWrite.ast'
René Schöne's avatar
René Schöne committed
158
    moreInputFiles 'src/test/01-input/defaultOnlyWrite/Test.jadd',
159
160
            'src/test/02-after-ragconnect/defaultOnlyWrite/MqttHandler.jadd',
            'src/test/02-after-ragconnect/defaultOnlyWrite/RagConnect.jadd'
René Schöne's avatar
René Schöne committed
161
162
}

163
testClasses.dependsOn compileDefaultOnlyWriteTest
René Schöne's avatar
René Schöne committed
164
165
compileDefaultOnlyWriteTest.dependsOn preprocessDefaultOnlyWriteTest

166
// --- Test: read1write2 ---
167
168
task preprocessRead1Write2Test(type: JavaExec, group: 'verification') {
    doFirst {
169
        delete 'src/test/02-after-ragconnect/read1write2/Test.relast',
170
171
                'src/test/02-after-ragconnect/read1write2/MqttHandler.java',
                'src/test/02-after-ragconnect/read1write2/RagConnect.jadd'
172
173
174
    }

    classpath = sourceSets.main.runtimeClasspath
175
    main = 'org.jastadd.ragconnect.compiler.Compiler'
176
177
178
    args '--o=src/test/02-after-ragconnect/read1write2',
            'src/test/01-input/read1write2/Test.relast',
            'src/test/01-input/read1write2/Test.connect',
179
            '--rootNode=A',
180
181
182
183
184
185
            '--logReads', '--logWrites'
}

task compileRead1Write2Test(type: RelastTest) {
    useJastAddNames = true
    jastAddList = 'JastAddList'
186
187
    relastFiles 'src/test/02-after-ragconnect/read1write2/Test.relast',
            'src/test/02-after-ragconnect/read1write2/RagConnect.relast'
188
189
    grammarName = 'src/test/03-after-relast/read1write2/read1write2'
    packageName = 'read1write2.ast'
René Schöne's avatar
René Schöne committed
190
    moreInputFiles 'src/test/01-input/read1write2/Test.jadd',
191
192
            'src/test/02-after-ragconnect/read1write2/MqttHandler.jadd',
            'src/test/02-after-ragconnect/read1write2/RagConnect.jadd'
193
194
}

195
testClasses.dependsOn compileRead1Write2Test
196
197
compileRead1Write2Test.dependsOn preprocessRead1Write2Test

René Schöne's avatar
René Schöne committed
198
199
200
// --- Test: read2write1 ---
task preprocessRead2Write1Test(type: JavaExec, group: 'verification') {
    doFirst {
201
        delete 'src/test/02-after-ragconnect/read2write1/Test.relast',
202
203
                'src/test/02-after-ragconnect/read2write1/MqttHandler.java',
                'src/test/02-after-ragconnect/read2write1/RagConnect.jadd'
René Schöne's avatar
René Schöne committed
204
205
206
    }

    classpath = sourceSets.main.runtimeClasspath
207
    main = 'org.jastadd.ragconnect.compiler.Compiler'
208
209
210
    args '--o=src/test/02-after-ragconnect/read2write1',
            'src/test/01-input/read2write1/Test.relast',
            'src/test/01-input/read2write1/Test.connect',
René Schöne's avatar
René Schöne committed
211
212
213
214
215
216
217
            '--rootNode=A', '--verbose',
            '--logReads', '--logWrites'
}

task compileRead2Write1Test(type: RelastTest) {
    useJastAddNames = true
    jastAddList = 'JastAddList'
218
219
    relastFiles 'src/test/02-after-ragconnect/read2write1/Test.relast',
            'src/test/02-after-ragconnect/read2write1/RagConnect.relast'
René Schöne's avatar
René Schöne committed
220
221
    grammarName = 'src/test/03-after-relast/read2write1/read2write1'
    packageName = 'read2write1.ast'
René Schöne's avatar
René Schöne committed
222
    moreInputFiles 'src/test/01-input/read2write1/Test.jadd',
223
224
            'src/test/02-after-ragconnect/read2write1/MqttHandler.jadd',
            'src/test/02-after-ragconnect/read2write1/RagConnect.jadd'
René Schöne's avatar
René Schöne committed
225
226
}

227
testClasses.dependsOn compileRead2Write1Test
René Schöne's avatar
René Schöne committed
228
229
compileRead2Write1Test.dependsOn preprocessRead2Write1Test

René Schöne's avatar
René Schöne committed
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
// --- 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.java',
                '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', '--verbose',
            '--logReads', '--logWrites'
245
}
René Schöne's avatar
René Schöne committed
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260

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/RagConnect.jadd'
}

testClasses.dependsOn compileViaTest
compileViaTest.dependsOn preprocessViaTest