build.gradle 5.89 KB
Newer Older
René Schöne's avatar
René Schöne committed
1
2
apply plugin: 'java-library'
apply plugin: 'idea'
3
4
5
apply plugin: 'jastadd'
apply plugin: 'application'

René Schöne's avatar
René Schöne committed
6
7
group = 'de.tudresden.inf.st'

8
sourceCompatibility = 1.8
René Schöne's avatar
René Schöne committed
9
targetCompatibility = 1.8
10

11
mainClassName = 'org.jastadd.ragconnect.compiler.Compiler'
12
13

repositories {
René Schöne's avatar
René Schöne committed
14
    mavenCentral()
15
16
17
18
19
20
21
22
23
24
25
    jcenter()
}

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

dependencies {
René Schöne's avatar
René Schöne committed
26
27
28
    implementation project(':relast-preprocessor')
    implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.11.2'
    implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.11.2'
René Schöne's avatar
René Schöne committed
29
    implementation group: 'org.apache.logging.log4j', name: 'log4j-jul', version: '2.11.2'
René Schöne's avatar
René Schöne committed
30
    implementation group: 'com.github.spullara.mustache.java', name: 'compiler', version: '0.9.6'
René Schöne's avatar
René Schöne committed
31
    runtime group: 'org.jastadd', name: 'jastadd', version: '2.3.4'
René Schöne's avatar
René Schöne committed
32
    api group: 'net.sf.beaver', name: 'beaver-rt', version: '0.9.11'
33
34
}

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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)
    }
}

René Schöne's avatar
René Schöne committed
54
55
sourceSets.main.java {
    srcDir "src/gen/java"
56
57
58
59
}

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",
René Schöne's avatar
René Schöne committed
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
            "./src/main/jastadd/YAML.relast",
78
79
80
81
82
            "--listClass=java.util.ArrayList",
            "--jastAddList=JastAddList",
            "--useJastAddNames",
            "--file",
            "--resolverHelper",
83
            "--grammarName=./src/gen/jastadd/RagConnect"
84
85
    ]

86
    inputs.files("../libs/relast.jar",
René Schöne's avatar
René Schöne committed
87
            "../relast-preprocessor/src/main/jastadd/RelAst.relast",
88
            "./src/main/jastadd/RagConnect.relast",
89
90
            "./src/main/jastadd/MustacheNodes.relast",
            "./src/main/jastadd/YAML.relast")
91
92
93
94
    outputs.files("./src/gen/jastadd/RagConnect.ast",
            "./src/gen/jastadd/RagConnect.jadd",
            "./src/gen/jastadd/RagConnectRefResolver.jadd",
            './src/gen/jastadd/RagConnectResolverStubs.jrag')
95
96
}

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

            java {
104
                basedir ".."
René Schöne's avatar
René Schöne committed
105
106
                include "relast-preprocessor/main/**/*.java"
                include "relast-preprocessor/gen/**/*.java"
107
108
                include "ragconnect.base/src/main/**/*.java"
                include "ragconnect.base/src/gen/**/*.java"
109
110
111
            }

            jastadd {
112
                basedir ".."
René Schöne's avatar
René Schöne committed
113
114
115
                include "relast-preprocessor/src/main/jastadd/**/*.ast"
                include "relast-preprocessor/src/main/jastadd/**/*.jadd"
                include "relast-preprocessor/src/main/jastadd/**/*.jrag"
116
117
118
119
120
121
                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"
122
123
124
            }

            scanner {
125
                basedir ".."
René Schöne's avatar
René Schöne committed
126
127
128
129
130
131
                include "ragconnect.base/src/main/jastadd/scanner/Header.flex",             [-5]
                include "relast-preprocessor/src/main/jastadd/scanner/Preamble.flex",       [-4]
                include "relast-preprocessor/src/main/jastadd/scanner/Macros.flex",         [-3]
                include "ragconnect.base/src/main/jastadd/scanner/Macros.flex",             [-3]
                include "relast-preprocessor/src/main/jastadd/scanner/RulesPreamble.flex",  [-2]
                include "ragconnect.base/src/main/jastadd/scanner/MappingContent.flex",     [-1]
132
                include "ragconnect.base/src/main/jastadd/scanner/Keywords.flex"
René Schöne's avatar
René Schöne committed
133
134
135
                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]
136
137
138
            }

            parser {
139
                basedir ".."
140
141
                include "ragconnect.base/src/main/jastadd/parser/Preamble.parser"
                include "ragconnect.base/src/main/jastadd/parser/RagConnect.parser"
René Schöne's avatar
René Schöne committed
142
                include "relast-preprocessor/src/main/jastadd/parser/RelAst.parser"
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
            }
        }
    }

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

    preprocessParser.doFirst {

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

    }

158
    module = "RagConnect"
159

160
    astPackage = 'org.jastadd.ragconnect.ast'
161

162
    parser.name = 'RagConnectParser'
163
164
165
166
167

    genDir = 'src/gen/java'

    buildInfoDir = 'src/gen-res'

168
169
    scanner.genDir = "src/gen/java/org/jastadd/ragconnect/scanner"
    parser.genDir = "src/gen/java/org/jastadd/ragconnect/parser"
170

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

174
generateAst.dependsOn relast