build.gradle 5.88 KB
Newer Older
1
2
3
4
5
apply plugin: 'jastadd'
apply plugin: 'application'

sourceCompatibility = 1.8

6
mainClassName = 'org.jastadd.ragconnect.compiler.Compiler'
7
8
9
10
11
12
13
14
15
16
17
18
19

repositories {
    jcenter()
}

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

dependencies {
20
    implementation project(':relast.preprocessor')
René Schöne's avatar
René Schöne committed
21
    implementation group: 'com.github.spullara.mustache.java', name: 'compiler', version: '0.9.6'
René Schöne's avatar
René Schöne committed
22
    implementation group: 'org.apache.logging.log4j', name: 'log4j-jul', version: '2.11.2'
René Schöne's avatar
René Schöne committed
23
    runtime group: 'org.jastadd', name: 'jastadd', version: '2.3.4'
René Schöne's avatar
René Schöne committed
24
    api group: 'net.sf.beaver', name: 'beaver-rt', version: '0.9.11'
25
26
}

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
def versionFile = 'src/main/resources/ragConnectVersion.properties'
def oldProps = new Properties()

try {
    file(versionFile).withInputStream { stream -> oldProps.load(stream) }
    version = oldProps['version']
} catch (e) {
    // 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.", e)
}

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

46
47
48
49
50
51
52
53
54
55
56
57
58
59
sourceSets {
    main {
        java.srcDir "src/gen/java"
    }
}

test {
    useJUnitPlatform()

    maxHeapSize = '1G'
}

jar {
    manifest {
60
        attributes "Main-Class": 'org.jastadd.ragconnect.compiler.Compiler'
61
62
63
64
65
66
67
    }

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

68
69
70
71
72
73
task relast(type: JavaExec) {
    group = 'Build'
    main = "-jar"

    doFirst {
        delete "src/gen/jastadd/*.ast"
74
75
76
        delete "src/gen/jastadd/RagConnect.jadd"
        delete "src/gen/jastadd/RagConnectRefResolver.jadd"
        delete "src/gen/jastadd/RagConnectResolverStubs.jrag"
77
78
79
80
81
        mkdir  "src/gen/jastadd/"
    }

    args = [
            "../libs/relast.jar",
82
            "../relast.preprocessor/src/main/jastadd/RelAst.relast",
83
            "./src/main/jastadd/RagConnect.relast",
René Schöne's avatar
René Schöne committed
84
            "./src/main/jastadd/MustacheNodes.relast",
85
86
87
88
89
            "--listClass=java.util.ArrayList",
            "--jastAddList=JastAddList",
            "--useJastAddNames",
            "--file",
            "--resolverHelper",
90
            "--grammarName=./src/gen/jastadd/RagConnect"
91
92
93
    ]

    inputs.files file("../libs/relast.jar"),
94
            file("../relast.preprocessor/src/main/jastadd/RelAST.relast"),
95
            file("./src/main/jastadd/RagConnect.relast")
96
            file("./src/main/jastadd/MustacheNodes.relast")
97
98
99
100
    outputs.files file("./src/gen/jastadd/RagConnect.ast"),
            file("./src/gen/jastadd/RagConnect.jadd"),
            file("./src/gen/jastadd/RagConnectRefResolver.jadd"),
            file('./src/gen/jastadd/RagConnectResolverStubs.jrag')
101
102
}

103
104
105
106
jastadd {
    configureModuleBuild()
    modules {
        //noinspection GroovyAssignabilityCheck
107
        module("RagConnect") {
108
109

            java {
110
111
112
                basedir ".."
                include "relast.preprocessor/main/**/*.java"
                include "relast.preprocessor/gen/**/*.java"
113
114
                include "ragconnect.base/src/main/**/*.java"
                include "ragconnect.base/src/gen/**/*.java"
115
116
117
            }

            jastadd {
118
119
120
121
                basedir ".."
                include "relast.preprocessor/src/main/jastadd/**/*.ast"
                include "relast.preprocessor/src/main/jastadd/**/*.jadd"
                include "relast.preprocessor/src/main/jastadd/**/*.jrag"
122
123
124
125
126
127
                include "ragconnect.base/src/main/jastadd/**/*.ast"
                include "ragconnect.base/src/main/jastadd/**/*.jadd"
                include "ragconnect.base/src/main/jastadd/**/*.jrag"
                include "ragconnect.base/src/gen/jastadd/**/*.ast"
                include "ragconnect.base/src/gen/jastadd/**/*.jadd"
                include "ragconnect.base/src/gen/jastadd/**/*.jrag"
128
129
130
            }

            scanner {
131
                basedir ".."
132
                include "ragconnect.base/src/main/jastadd/scanner/Header.flex",               [-5]
133
134
                include "relast.preprocessor/src/main/jastadd/scanner/Preamble.flex",      [-4]
                include "relast.preprocessor/src/main/jastadd/scanner/Macros.flex",        [-3]
135
                include "ragconnect.base/src/main/jastadd/scanner/Macros.flex",               [-3]
136
                include "relast.preprocessor/src/main/jastadd/scanner/RulesPreamble.flex", [-2]
137
138
                include "ragconnect.base/src/main/jastadd/scanner/MappingContent.flex",       [-1]
                include "ragconnect.base/src/main/jastadd/scanner/Keywords.flex"
139
140
141
                include "relast.preprocessor/src/main/jastadd/scanner/Keywords.flex"
                include "relast.preprocessor/src/main/jastadd/scanner/Symbols.flex",        [1]
                include "relast.preprocessor/src/main/jastadd/scanner/RulesPostamble.flex", [2]
142
143
144
            }

            parser {
145
                basedir ".."
146
147
                include "ragconnect.base/src/main/jastadd/parser/Preamble.parser"
                include "ragconnect.base/src/main/jastadd/parser/RagConnect.parser"
148
                include "relast.preprocessor/src/main/jastadd/parser/RelAst.parser"
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
            }
        }
    }

    cleanGen.doFirst {
        delete "src/gen/java/org"
        delete "src/gen-res/BuildInfo.properties"
    }

    preprocessParser.doFirst {

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

    }

164
    module = "RagConnect"
165

166
    astPackage = 'org.jastadd.ragconnect.ast'
167

168
    parser.name = 'RagConnectParser'
169
170
171
172
173

    genDir = 'src/gen/java'

    buildInfoDir = 'src/gen-res'

174
175
    scanner.genDir = "src/gen/java/org/jastadd/ragconnect/scanner"
    parser.genDir = "src/gen/java/org/jastadd/ragconnect/parser"
176

177
    jastaddOptions = ["--lineColumnNumbers", "--List=JastAddList", "--safeLazy", "--visitCheck=true", "--rewrite=cnta", "--cache=all"]
178
179
}

180
generateAst.dependsOn relast