build.gradle 6.13 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
File genSrc = file("src/gen/java")
René Schöne's avatar
René Schöne committed
55
56
sourceSets.main.java.srcDir genSrc
idea.module.generatedSourceDirs += genSrc
57
58
59

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

    from {
René Schöne's avatar
René Schöne committed
64
        configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
65
    }
René Schöne's avatar
René Schöne committed
66
67

    archiveBaseName = 'ragconnect'
68
69
}

René Schöne's avatar
René Schöne committed
70
71
72
73
File preprocessorGrammar = file('../relast-preprocessor/src/main/jastadd/RelAst.relast')
File ragConnectGrammar = file('./src/main/jastadd/RagConnect.relast')
File intermediateGrammar = file('./src/main/jastadd/intermediate/MustacheNodes.relast')
File mustacheGrammar = file('./src/main/jastadd/mustache/Mustache.relast')
74
75
76
77
78
79
task relast(type: JavaExec) {
    group = 'Build'
    main = "-jar"

    args = [
            "../libs/relast.jar",
René Schöne's avatar
René Schöne committed
80
81
82
83
            preprocessorGrammar,
            ragConnectGrammar,
            intermediateGrammar,
            mustacheGrammar,
84
85
86
87
88
            "--listClass=java.util.ArrayList",
            "--jastAddList=JastAddList",
            "--useJastAddNames",
            "--file",
            "--resolverHelper",
89
            "--grammarName=./src/gen/jastadd/RagConnect"
90
91
    ]

92
    inputs.files("../libs/relast.jar",
René Schöne's avatar
René Schöne committed
93
94
95
96
            preprocessorGrammar,
            ragConnectGrammar,
            intermediateGrammar,
            mustacheGrammar)
97
98
99
100
    outputs.files("./src/gen/jastadd/RagConnect.ast",
            "./src/gen/jastadd/RagConnect.jadd",
            "./src/gen/jastadd/RagConnectRefResolver.jadd",
            './src/gen/jastadd/RagConnectResolverStubs.jrag')
101
102
}

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

            java {
110
                basedir ".."
René Schöne's avatar
René Schöne committed
111
112
                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
                basedir ".."
René Schöne's avatar
René Schöne committed
119
120
121
                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 ".."
René Schöne's avatar
René Schöne committed
132
133
134
135
136
137
                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]
138
                include "ragconnect.base/src/main/jastadd/scanner/Keywords.flex"
René Schöne's avatar
René Schöne committed
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"
René Schöne's avatar
René Schöne committed
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