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

3
apply plugin: "com.github.ben-manes.versions"
Johannes Mey's avatar
Johannes Mey committed
4
apply plugin: 'java'
5
apply plugin: 'java-library'
Johannes Mey's avatar
Johannes Mey committed
6
7
8
apply plugin: 'jastadd'
apply plugin: 'application'
apply plugin: "idea"
9
apply plugin: "org.jastadd.relast.plugin"
Johannes Mey's avatar
Johannes Mey committed
10
11
12
13
14
15
16
17
18

sourceCompatibility = 1.8

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

repositories {
    jcenter()
}

19
20
21
group = 'org.jastadd'
apply plugin: 'maven-publish'

Johannes Mey's avatar
Johannes Mey committed
22
23
24
25
buildscript {
    repositories.jcenter()
    dependencies {
        classpath 'org.jastadd:jastaddgradle:1.13.3'
26
        classpath "com.github.ben-manes:gradle-versions-plugin:0.34.0"
Johannes Mey's avatar
Johannes Mey committed
27
28
29
    }
}

30
31
32
dependencyUpdates.gradleReleaseChannel="current"
dependencyUpdates.revision="release"

Johannes Mey's avatar
Johannes Mey committed
33
dependencies {
34
35
36
37
38
39
40
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
    testImplementation 'org.assertj:assertj-core:3.18.0'
    testImplementation 'com.fasterxml.jackson.core:jackson-core:2.11.3'
    testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.11.3'
    implementation group: 'org.jastadd', name: 'jastadd', version: '2.3.4'
    api group: 'net.sf.beaver', name: 'beaver-rt', version: '0.9.11'
Johannes Mey's avatar
Johannes Mey committed
41
42
}

43
44
45
46
47
48
49
50
File genSrc = file("src/gen/java")
File testGenSrc = file("src/test/java-gen")
sourceSets.main.java.srcDir genSrc
sourceSets.main.java.srcDir "buildSrc/gen/java"
sourceSets.test.java.srcDir testGenSrc

idea.module.generatedSourceDirs += genSrc
idea.module.generatedSourceDirs += testGenSrc
Johannes Mey's avatar
Johannes Mey committed
51

52
53
54
55
56
57
def versionFile = 'src/main/resources/RelASTVersion.properties'
def oldProps = new Properties()

try {
    file(versionFile).withInputStream { stream -> oldProps.load(stream) }
    version = oldProps['version']
58
} catch (ignored) {
59
60
61
62
63
64
65
66
67
68
69
70
    // this happens, if either the properties file is not present, or cannot be read from
    throw new GradleException("File ${versionFile} not found or unreadable. Aborting.")
}

task newVersion() {
    doFirst {
        def props = new Properties()
        props['version'] = value
        props.store(file(versionFile).newWriter(), null)
    }
}

Johannes Mey's avatar
Johannes Mey committed
71
72
73
74
75
76
77
78
jar {
    manifest {
        attributes "Main-Class": 'org.jastadd.relast.compiler.Compiler'
    }

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

    archiveBaseName = 'relast'
Johannes Mey's avatar
Johannes Mey committed
81
82
83
84
85
}

jastadd {
    configureModuleBuild()
    modules {
86
        //noinspection GroovyAssignabilityCheck
Johannes Mey's avatar
Johannes Mey committed
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
        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 {
114
        delete "src/gen/java/org"
Johannes Mey's avatar
Johannes Mey committed
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
        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"]
}

140
141
142
143
144
145
publishing {
    publications {
        maven(MavenPublication) {
            artifact("build/libs/relast-${version}.jar") {
                extension 'jar'
            }
146
        }
147
148
149
150
151
152
153
154
    }
    repositories {
        maven {
            name 'nexus'
            url "http://172.22.1.152:8081/repository/" + (project.hasProperty('asSnapshot') ? "maven-snapshots" : "maven-releases/")
            credentials {
                username project.ext.properties.repoUser
                password project.ext.properties.repoPassword
155
156
157
158
159
            }
        }
    }
}

160
publish.dependsOn jar
161

162
163
164
165
166
task firstRelationsRun(type: RelastTest) {
    relastFiles 'src/test/jastadd/relations/Relations.relast'
    grammarName = 'src/test/jastadd/relations/Relations'
    useJastAddNames = true
    packageName = 'relations.ast'
167
    moreInputFiles 'src/test/jastadd/Utils.jadd', 'src/test/jastadd/relations/Relations.jrag'
168
169
}

170
171
172
173
174
task secondRelationsRun(type: RelastTest, dependsOn: firstRelationsRun) {
    relastFiles 'src/test/jastadd/relations/Relations.ast'
    grammarName = 'src/test/jastadd/relations/Relations2'
    useJastAddNames = true
    packageName = 'ignored'
175

176
177
178
    doLast {
        delete fileTree('src/test/java-gen/ignored')
        delete 'src/test/java-gen/ignored'
179
180
181
    }
}

182
183
184
185
186
187
188
task compileConstructorTest(type: RelastTest) {
    relastFiles 'src/test/jastadd/constructors/Constructors.relast'
    grammarName = 'src/test/jastadd/constructors/Constructors'
    packageName = 'constructors.ast'
    moreInputFiles 'src/test/jastadd/constructors/Constructors.jrag'
}

189
190
191
192
task compileDefaultNamesTest(type: RelastTest) {
    relastFiles 'src/test/jastadd/relations/Relations.relast'
    grammarName = 'src/test/jastadd/relations/Relations3'
    packageName = 'defaultnames.ast'
193
    moreInputFiles 'src/test/jastadd/Utils.jadd', 'src/test/jastadd/relations/Relations.jrag'
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
}

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'
}

224
225
226
227
228
229
230
231
232
233
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'
}

234
235
236
237
238
239
240
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',
241
            'src/test/jastadd/resolver/ResolverUtils.jadd',
242
            'src/test/jastadd/resolver/MyRefResolver.jadd'
243
244
}

245
246
247
248
249
250
251
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',
252
            'src/test/jastadd/resolver2/ResolverUtils.jadd',
253
            'src/test/jastadd/resolver2/MyRefResolver.jadd'
Johannes Mey's avatar
Johannes Mey committed
254
255
}

256
257
258
259
260
task compileListNamesTest(type: RelastTest) {
    relastFiles 'src/test/jastadd/listnames/ListNames.relast'
    grammarName = 'src/test/jastadd/listnames/ListNames'
    useJastAddNames = true
    jastAddList = 'ListyMcListface'
261
    listClass = 'java.util.LinkedList'
262
263
    packageName = 'listnames.ast'
    moreInputFiles 'src/test/jastadd/Utils.jadd'
264
265
}

266
267
268
269
270
271
272
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'
273
274
}

275
276
277
278
279
280
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'
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
task compileSerializerPointerTest(type: RelastTest) {
    resolverHelper = true
    relastFiles 'src/test/jastadd/serializer-pointer/Serializer.relast'
    grammarName = 'src/test/jastadd/serializer-pointer/Serializer'
    serializer = 'jackson-json-pointer'
    packageName = 'pointer.serializer.ast'
    moreInputFiles 'src/test/jastadd/Utils.jadd'
}

task compileSerializerManualTest(type: RelastTest) {
    resolverHelper = true
    relastFiles 'src/test/jastadd/serializer-manual/Serializer.relast'
    grammarName = 'src/test/jastadd/serializer-manual/Serializer'
    serializer = 'jackson-manual-references'
    packageName = 'manual.serializer.ast'
    moreInputFiles 'src/test/jastadd/Utils.jadd', 'src/test/jastadd/serializer-manual/JsonPointer.jrag'
}

task compileSerializerManualRelativeTest(type: RelastTest) {
    resolverHelper = true
    relastFiles 'src/test/jastadd/serializer-manual-relative/Serializer.relast'
    grammarName = 'src/test/jastadd/serializer-manual-relative/Serializer'
    serializer = 'jackson-manual-references'
    packageName = 'manual.relative.serializer.ast'
    moreInputFiles 'src/test/jastadd/Utils.jadd', 'src/test/jastadd/serializer-manual-relative/JsonPointer.jrag'
}

310
311
312
313
task cleanTestGen(type: Delete) {
    group 'verification'
    description 'Cleans all generated test resources'

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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
    delete 'src/test/jastadd/serializer-names/Serializer.ast'
    delete 'src/test/jastadd/serializer-names/Serializer.jadd'
    delete 'src/test/jastadd/serializer-names/SerializerSerializer.jadd'
    delete 'src/test/jastadd/serializer-names/SerializerResolverStubs.jrag'
    delete 'src/test/jastadd/serializer-names/SerializerRefResolver.jadd'
    delete 'src/test/jastadd/serializer-manual/Serializer.ast'
    delete 'src/test/jastadd/serializer-manual/Serializer.jadd'
    delete 'src/test/jastadd/serializer-manual/SerializerSerializer.jadd'
    delete 'src/test/jastadd/serializer-manual/SerializerResolverStubs.jrag'
    delete 'src/test/jastadd/serializer-manual/SerializerRefResolver.jadd'
    delete 'src/test/jastadd/resolver2/Resolver.jadd'
    delete 'src/test/jastadd/resolver2/Resolver.ast'
    delete 'src/test/jastadd/resolver2/ResolverRefResolver.jadd'
    delete 'src/test/jastadd/resolver2/ResolverResolverStubs.jrag'
    delete 'src/test/jastadd/serializer-manual-relative/Serializer.ast'
    delete 'src/test/jastadd/serializer-manual-relative/Serializer.jadd'
    delete 'src/test/jastadd/serializer-manual-relative/SerializerSerializer.jadd'
    delete 'src/test/jastadd/serializer-manual-relative/SerializerResolverStubs.jrag'
    delete 'src/test/jastadd/serializer-manual-relative/SerializerRefResolver.jadd'
    delete 'src/test/jastadd/serializer-pointer/Serializer.ast'
    delete 'src/test/jastadd/serializer-pointer/Serializer.jadd'
    delete 'src/test/jastadd/serializer-pointer/SerializerSerializer.jadd'
    delete 'src/test/jastadd/serializer-pointer/SerializerResolverStubs.jrag'
    delete 'src/test/jastadd/serializer-pointer/SerializerRefResolver.jadd'
    delete 'src/test/jastadd/lowerbounds/LowerBounds.jadd'
    delete 'src/test/jastadd/lowerbounds/LowerBounds.ast'
    delete 'src/test/jastadd/resolver/Resolver.jadd'
    delete 'src/test/jastadd/resolver/Resolver.ast'
    delete 'src/test/jastadd/resolver/Resolver2.jadd'
    delete 'src/test/jastadd/resolver/Resolver2.ast'
    delete 'src/test/jastadd/resolver/Resolver2ResolverStubs.jrag'
    delete 'src/test/jastadd/resolver/ResolverRefResolver.jadd'
    delete 'src/test/jastadd/resolver/ResolverResolverStubs.jrag'
    delete 'src/test/jastadd/resolver/Resolver2RefResolver.jadd'
    delete 'src/test/jastadd/errors/Errors.out'
    delete 'src/test/jastadd/errors/Inheritance.out'
    delete 'src/test/jastadd/errors/Multiple.out'
    delete 'src/test/jastadd/errors/InheritanceLeft.out'
    delete 'src/test/jastadd/errors/ErrorsLeft.out'
    delete 'src/test/jastadd/errors/MultipleLeft.out'
    delete 'src/test/jastadd/serializer/Serializer.ast'
    delete 'src/test/jastadd/serializer/Serializer.jadd'
    delete 'src/test/jastadd/serializer/SerializerSerializer.jadd'
    delete 'src/test/jastadd/serializer/SerializerResolverStubs.jrag'
    delete 'src/test/jastadd/serializer/SerializerRefResolver.jadd'
    delete 'src/test/jastadd/listnames/ListNames.jadd'
    delete 'src/test/jastadd/listnames/ListNames.ast'
    delete 'src/test/jastadd/relations/Relations2.jadd'
    delete 'src/test/jastadd/relations/Relations3.ast'
    delete 'src/test/jastadd/relations/Relations2.ast'
    delete 'src/test/jastadd/relations/Relations.ast'
    delete 'src/test/jastadd/relations/Relations.jadd'
    delete 'src/test/jastadd/relations/Relations3.jadd'
    delete 'src/test/jastadd/multiple/Multiple.jadd'
    delete 'src/test/jastadd/multiple/Multiple.ast'

370
371
372
    delete fileTree('src/test/java-gen/') {
        exclude '.gitignore'
    }
373
374
}

Johannes Mey's avatar
Johannes Mey committed
375
test {
Johannes Mey's avatar
Johannes Mey committed
376
    outputs.upToDateWhen { false }
Johannes Mey's avatar
Johannes Mey committed
377
    useJUnitPlatform()
378
    dependsOn cleanTestGen
379
}