build.gradle 7.78 KB
Newer Older
1
2
import org.jastadd.relast.plugin.RelastTest

Johannes Mey's avatar
Johannes Mey committed
3
4
5
6
apply plugin: 'java'
apply plugin: 'jastadd'
apply plugin: 'application'
apply plugin: "idea"
7
apply plugin: "org.jastadd.relast.plugin"
Johannes Mey's avatar
Johannes Mey committed
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

sourceCompatibility = 1.8

mainClassName = 'org.jastadd.relast.compiler.Compiler'

repositories {
    jcenter()
}

buildscript {
    repositories.jcenter()
    dependencies {
        classpath 'org.jastadd:jastaddgradle:1.13.3'
    }
}

dependencies {
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.4.0'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.4.0'
27
    testCompile 'org.assertj:assertj-core:3.12.1'
28
29
    compile 'com.fasterxml.jackson.core:jackson-core:2.9.8'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.9.8'
30
    runtime 'org.jastadd:jastadd:2.3.2'
Johannes Mey's avatar
Johannes Mey committed
31
    compile group: 'net.sf.beaver', name: 'beaver-rt', version: '0.9.11'
Johannes Mey's avatar
Johannes Mey committed
32
33
    compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.10.0'
    compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.10.0'
Johannes Mey's avatar
Johannes Mey committed
34
35
36
37
38
}

sourceSets {
    main {
        java.srcDir "src/gen/java"
39
        java.srcDir "buildSrc/gen/java"
Johannes Mey's avatar
Johannes Mey committed
40
    }
41
42
43
    test {
        java.srcDir "src/test/java-gen"
    }
Johannes Mey's avatar
Johannes Mey committed
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
}

jar {
    manifest {
        attributes "Main-Class": 'org.jastadd.relast.compiler.Compiler'
    }

    from {
        configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
    }
}

jastadd {
    configureModuleBuild()
    modules {
59
        //noinspection GroovyAssignabilityCheck
Johannes Mey's avatar
Johannes Mey committed
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
        module("RelAst") {

            java {
                basedir "."
                include "src/main/**/*.java"
                include "src/gen/**/*.java"
            }

            jastadd {
                basedir "src/main/jastadd/"
                include "**/*.ast"
                include "**/*.jadd"
                include "**/*.jrag"
            }

            scanner {
                include "src/main/jastadd/RelAst.flex"
            }

            parser {
                include "src/main/jastadd/Preamble.parser"
                include "src/main/jastadd/RelAst.parser"
            }
        }
    }

    cleanGen.doFirst {
87
        delete "src/gen/java/org"
Johannes Mey's avatar
Johannes Mey committed
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
        delete "src/gen-res/BuildInfo.properties"
    }

    preprocessParser.doFirst {

        args += ["--no-beaver-symbol"]

    }

    module = "RelAst"

    astPackage = 'org.jastadd.relast.ast'

    parser.name = 'RelAstParser'

    genDir = 'src/gen/java'

    buildInfoDir = 'src/gen-res'

    scanner.genDir = "src/gen/java/org/jastadd/relast/scanner"
    parser.genDir = "src/gen/java/org/jastadd/relast/parser"

    jastaddOptions = ["--lineColumnNumbers", "--safeLazy", "--visitCheck=true", "--rewrite=cnta", "--cache=all"]
}

113
114
115
116
117
118
119
120
task preprocessRelationTest(type: JavaExec, group: 'verification') {

    doFirst {
        delete 'src/test/jastadd/relations/Relations.ast', 'src/test/jastadd/relations/Relations.jadd'
    }

    classpath = sourceSets.main.runtimeClasspath
    main = 'org.jastadd.relast.compiler.Compiler'
121
    //noinspection GroovyAssignabilityCheck
122
    args 'src/test/jastadd/relations/Relations.relast', '--quiet', '--useJastAddNames', '--file', '--grammarName=src/test/jastadd/relations/Relations'
123
124
125
126
127
128
129
130
131
132
}

task doublePreprocessRelationTest(type: JavaExec, group: 'verification') {

    doFirst {
        delete 'src/test/jastadd/relations/Relations2.ast', 'src/test/jastadd/relations/Relations2.jadd'
    }

    classpath = sourceSets.main.runtimeClasspath
    main = 'org.jastadd.relast.compiler.Compiler'
133
    //noinspection GroovyAssignabilityCheck
134
    args 'src/test/jastadd/relations/Relations.ast', '--quiet', '--useJastAddNames', '--file', '--grammarName=src/test/jastadd/relations/Relations2'
135
136
137
138
139
140
141
142
143
144
}

task compileRelationTest(type: JavaExec, group: 'verification') {

    doFirst {
        delete 'src/test/java-gen/relations'
    }

    classpath = sourceSets.main.runtimeClasspath
    main = 'org.jastadd.JastAdd'
145
146
147
148
149
    //noinspection GroovyAssignabilityCheck
    args '--o=src/test/java-gen/', '--package=relations.ast',
            'src/test/jastadd/relations/Relations.ast',
            'src/test/jastadd/relations/Relations.jadd',
            'src/test/jastadd/Utils.jadd'
150
151
}

152
153
154
test.dependsOn compileRelationTest
compileRelationTest.dependsOn doublePreprocessRelationTest
doublePreprocessRelationTest.dependsOn preprocessRelationTest
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
task compileDefaultNamesTest(type: RelastTest) {
    relastFiles 'src/test/jastadd/relations/Relations.relast'
    grammarName = 'src/test/jastadd/relations/Relations3'
    packageName = 'defaultnames.ast'
    moreInputFiles 'src/test/jastadd/Utils.jadd'
}

task compileDefaultNamesResolverTest(type: RelastTest) {
    relastFiles 'src/test/jastadd/resolver/Resolver.relast'
    grammarName = 'src/test/jastadd/resolver/Resolver2'
    resolverHelper = true
    packageName = 'defaultnames.resolver.ast'
    moreInputFiles 'src/test/jastadd/Utils.jadd',
                   'src/test/jastadd/resolver/ResolverUtils.jadd',
                   'src/test/jastadd/resolver/MyRefResolver.jadd'
}

task compileLowerBoundsTest(type: RelastTest) {
    relastFiles 'src/test/jastadd/lowerbounds/LowerBounds.relast'
    grammarName = 'src/test/jastadd/lowerbounds/LowerBounds'
    useJastAddNames = true
    packageName = 'lowerbounds.ast'
    moreInputFiles 'src/test/jastadd/Utils.jadd'
}

task compileMultipleTest(type: RelastTest) {
    relastFiles 'src/test/jastadd/multiple/Part1.relast',
                'src/test/jastadd/multiple/Part2.relast',
                'src/test/jastadd/multiple/Part3.relast'
    grammarName = 'src/test/jastadd/multiple/Multiple'
    useJastAddNames = true
    packageName = 'multiple.ast'
    moreInputFiles 'src/test/jastadd/Utils.jadd'
}

191
192
193
194
195
196
197
198
199
200
task compileMultipleMixedTest(type: RelastTest) {
    relastFiles 'src/test/jastadd/multiple-mixed/Part1.relast',
            'src/test/jastadd/multiple-mixed/Part2.relast',
            'src/test/jastadd/multiple-mixed/Part3.relast'
    grammarName = 'src/test/jastadd/multiple/Multiple'
    useJastAddNames = true
    packageName = 'mixed.multiple.ast'
    moreInputFiles 'src/test/jastadd/Utils.jadd'
}

201
202
203
204
205
206
207
task compileResolverTest(type: RelastTest) {
    relastFiles 'src/test/jastadd/resolver/Resolver.relast'
    grammarName = 'src/test/jastadd/resolver/Resolver'
    useJastAddNames = true
    resolverHelper = true
    packageName = 'resolver.ast'
    moreInputFiles 'src/test/jastadd/Utils.jadd',
208
            'src/test/jastadd/resolver/ResolverUtils.jadd',
209
            'src/test/jastadd/resolver/MyRefResolver.jadd'
210
211
}

212
213
214
215
216
217
218
task compileResolver2Test(type: RelastTest) {
    relastFiles 'src/test/jastadd/resolver2/Resolver.relast'
    grammarName = 'src/test/jastadd/resolver2/Resolver'
    useJastAddNames = true
    resolverHelper = true
    packageName = 'resolver2.ast'
    moreInputFiles 'src/test/jastadd/Utils.jadd',
219
            'src/test/jastadd/resolver2/ResolverUtils.jadd',
220
            'src/test/jastadd/resolver2/MyRefResolver.jadd'
Johannes Mey's avatar
Johannes Mey committed
221
222
}

223
224
225
226
227
228
229
task compileListNamesTest(type: RelastTest) {
    relastFiles 'src/test/jastadd/listnames/ListNames.relast'
    grammarName = 'src/test/jastadd/listnames/ListNames'
    useJastAddNames = true
    jastAddList = 'ListyMcListface'
    packageName = 'listnames.ast'
    moreInputFiles 'src/test/jastadd/Utils.jadd'
230
231
}

232
233
234
235
236
237
238
task compileSerializerTest(type: RelastTest) {
    relastFiles 'src/test/jastadd/serializer/Serializer.relast'
    grammarName = 'src/test/jastadd/serializer/Serializer'
    useJastAddNames = true
    serializer = 'jackson'
    packageName = 'serializer.ast'
    moreInputFiles 'src/test/jastadd/Utils.jadd'
239
240
}

241
242
243
244
245
246
task compileSerializerDefaultNamesTest(type: RelastTest) {
    relastFiles 'src/test/jastadd/serializer-names/Serializer.relast'
    grammarName = 'src/test/jastadd/serializer-names/Serializer'
    serializer = 'jackson'
    packageName = 'defaultnames.serializer.ast'
    moreInputFiles 'src/test/jastadd/Utils.jadd'
247
248
}

Johannes Mey's avatar
Johannes Mey committed
249
test {
Johannes Mey's avatar
Johannes Mey committed
250
    outputs.upToDateWhen { false }
Johannes Mey's avatar
Johannes Mey committed
251
    useJUnitPlatform()
252
}