build.gradle 5.58 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"

    args = [
            "../libs/relast.jar",
74
            "../relast.preprocessor/src/main/jastadd/RelAst.relast",
75
            "./src/main/jastadd/RagConnect.relast",
René Schöne's avatar
René Schöne committed
76
            "./src/main/jastadd/MustacheNodes.relast",
77
78
79
80
81
            "--listClass=java.util.ArrayList",
            "--jastAddList=JastAddList",
            "--useJastAddNames",
            "--file",
            "--resolverHelper",
82
            "--grammarName=./src/gen/jastadd/RagConnect"
83
84
    ]

85
86
87
88
89
90
91
92
    inputs.files("../libs/relast.jar",
            "../relast.preprocessor/src/main/jastadd/RelAST.relast",
            "./src/main/jastadd/RagConnect.relast",
            "./src/main/jastadd/MustacheNodes.relast")
    outputs.files("./src/gen/jastadd/RagConnect.ast",
            "./src/gen/jastadd/RagConnect.jadd",
            "./src/gen/jastadd/RagConnectRefResolver.jadd",
            './src/gen/jastadd/RagConnectResolverStubs.jrag')
93
94
}

95
96
97
98
jastadd {
    configureModuleBuild()
    modules {
        //noinspection GroovyAssignabilityCheck
99
        module("RagConnect") {
100
101

            java {
102
103
104
                basedir ".."
                include "relast.preprocessor/main/**/*.java"
                include "relast.preprocessor/gen/**/*.java"
105
106
                include "ragconnect.base/src/main/**/*.java"
                include "ragconnect.base/src/gen/**/*.java"
107
108
109
            }

            jastadd {
110
111
112
113
                basedir ".."
                include "relast.preprocessor/src/main/jastadd/**/*.ast"
                include "relast.preprocessor/src/main/jastadd/**/*.jadd"
                include "relast.preprocessor/src/main/jastadd/**/*.jrag"
114
115
116
117
118
119
                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"
120
121
122
            }

            scanner {
123
                basedir ".."
124
                include "ragconnect.base/src/main/jastadd/scanner/Header.flex",               [-5]
125
126
                include "relast.preprocessor/src/main/jastadd/scanner/Preamble.flex",      [-4]
                include "relast.preprocessor/src/main/jastadd/scanner/Macros.flex",        [-3]
127
                include "ragconnect.base/src/main/jastadd/scanner/Macros.flex",               [-3]
128
                include "relast.preprocessor/src/main/jastadd/scanner/RulesPreamble.flex", [-2]
129
130
                include "ragconnect.base/src/main/jastadd/scanner/MappingContent.flex",       [-1]
                include "ragconnect.base/src/main/jastadd/scanner/Keywords.flex"
131
132
133
                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]
134
135
136
            }

            parser {
137
                basedir ".."
138
139
                include "ragconnect.base/src/main/jastadd/parser/Preamble.parser"
                include "ragconnect.base/src/main/jastadd/parser/RagConnect.parser"
140
                include "relast.preprocessor/src/main/jastadd/parser/RelAst.parser"
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
            }
        }
    }

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

    preprocessParser.doFirst {

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

    }

156
    module = "RagConnect"
157

158
    astPackage = 'org.jastadd.ragconnect.ast'
159

160
    parser.name = 'RagConnectParser'
161
162
163
164
165

    genDir = 'src/gen/java'

    buildInfoDir = 'src/gen-res'

166
167
    scanner.genDir = "src/gen/java/org/jastadd/ragconnect/scanner"
    parser.genDir = "src/gen/java/org/jastadd/ragconnect/parser"
168

169
    jastaddOptions = ["--lineColumnNumbers", "--List=JastAddList", "--safeLazy", "--visitCheck=true", "--rewrite=cnta", "--cache=all"]
170
171
}

172
generateAst.dependsOn relast