build.gradle 7.62 KB
Newer Older
René Schöne's avatar
René Schöne committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
buildscript {
    repositories.mavenCentral()
    dependencies {
        classpath 'org.jastadd:jastaddgradle:1.13.3'
    }
}

plugins {
    id 'java'
    id 'java-library'
    id 'idea'
    id 'com.github.ben-manes.versions' version '0.36.0'
    id 'maven-publish'
    id 'application'
}

17
18
apply plugin: 'jastadd'

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

21
mainClassName = 'org.jastadd.ragconnect.compiler.Compiler'
22
23

repositories {
René Schöne's avatar
René Schöne committed
24
    mavenCentral()
25
26
27
28
    jcenter()
}

dependencies {
René Schöne's avatar
René Schöne committed
29
    implementation project(':relast-preprocessor')
René Schöne's avatar
René Schöne committed
30
31
32
33
    implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: "${log4j_version}"
    implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: "${log4j_version}"
    implementation group: 'org.apache.logging.log4j', name: 'log4j-jul', version: "${log4j_version}"
    implementation group: 'com.github.spullara.mustache.java', name: 'compiler', version: "${mustache_java_version}"
34
35
    // https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
    compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
René Schöne's avatar
René Schöne committed
36
    runtimeOnly group: 'org.jastadd', name: 'jastadd', version: '2.3.4'
René Schöne's avatar
René Schöne committed
37
    api group: 'net.sf.beaver', name: 'beaver-rt', version: '0.9.11'
38
39
}

40
41
42
43
44
45
46
47
48
49
50
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)
}

René Schöne's avatar
René Schöne committed
51
52
53
54
55
56
task printVersion() {
    doLast {
        println(version)
    }
}

57
58
59
60
61
62
63
64
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
65
File genSrc = file("src/gen/java")
René Schöne's avatar
René Schöne committed
66
67
sourceSets.main.java.srcDir genSrc
idea.module.generatedSourceDirs += genSrc
68
69
70

jar {
    manifest {
71
        attributes "Main-Class": 'org.jastadd.ragconnect.compiler.Compiler'
72
73
74

        // Log4J + Java 11 compatibility, see https://stackoverflow.com/q/53049346/2493208
        attributes "Multi-Release": true
75
76
77
    }

    from {
René Schöne's avatar
René Schöne committed
78
        configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
79
    }
René Schöne's avatar
René Schöne committed
80
81

    archiveBaseName = 'ragconnect'
82
83
}

René Schöne's avatar
René Schöne committed
84
85
86
87
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')
88
89
90
91
92
93
task relast(type: JavaExec) {
    group = 'Build'
    main = "-jar"

    args = [
            "../libs/relast.jar",
René Schöne's avatar
René Schöne committed
94
95
96
97
            preprocessorGrammar,
            ragConnectGrammar,
            intermediateGrammar,
            mustacheGrammar,
98
99
100
101
102
            "--listClass=java.util.ArrayList",
            "--jastAddList=JastAddList",
            "--useJastAddNames",
            "--file",
            "--resolverHelper",
103
            "--grammarName=./src/gen/jastadd/RagConnect"
104
105
    ]

106
    inputs.files("../libs/relast.jar",
René Schöne's avatar
René Schöne committed
107
108
109
110
            preprocessorGrammar,
            ragConnectGrammar,
            intermediateGrammar,
            mustacheGrammar)
111
112
113
114
    outputs.files("./src/gen/jastadd/RagConnect.ast",
            "./src/gen/jastadd/RagConnect.jadd",
            "./src/gen/jastadd/RagConnectRefResolver.jadd",
            './src/gen/jastadd/RagConnectResolverStubs.jrag')
115
116
}

117
118
119
120
jastadd {
    configureModuleBuild()
    modules {
        //noinspection GroovyAssignabilityCheck
121
        module("RagConnect") {
122
123

            java {
124
                basedir ".."
René Schöne's avatar
René Schöne committed
125
126
                include "relast-preprocessor/main/**/*.java"
                include "relast-preprocessor/gen/**/*.java"
127
128
                include "ragconnect.base/src/main/**/*.java"
                include "ragconnect.base/src/gen/**/*.java"
129
130
131
            }

            jastadd {
132
                basedir ".."
René Schöne's avatar
René Schöne committed
133
134
135
                include "relast-preprocessor/src/main/jastadd/**/*.ast"
                include "relast-preprocessor/src/main/jastadd/**/*.jadd"
                include "relast-preprocessor/src/main/jastadd/**/*.jrag"
136
137
138
139
140
141
                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"
142
143
144
            }

            scanner {
145
                basedir ".."
René Schöne's avatar
René Schöne committed
146
147
148
149
150
151
                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]
152
                include "ragconnect.base/src/main/jastadd/scanner/Keywords.flex"
René Schöne's avatar
René Schöne committed
153
154
155
                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]
156
157
158
            }

            parser {
159
                basedir ".."
160
161
                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
162
                include "relast-preprocessor/src/main/jastadd/parser/RelAst.parser"
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
            }
        }
    }

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

    preprocessParser.doFirst {

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

    }

178
    module = "RagConnect"
179

180
    astPackage = 'org.jastadd.ragconnect.ast'
181

182
    parser.name = 'RagConnectParser'
183
184
185
186
187

    genDir = 'src/gen/java'

    buildInfoDir = 'src/gen-res'

188
189
    scanner.genDir = "src/gen/java/org/jastadd/ragconnect/scanner"
    parser.genDir = "src/gen/java/org/jastadd/ragconnect/parser"
190

191
    jastaddOptions = ["--lineColumnNumbers", "--List=JastAddList", "--safeLazy", "--visitCheck=true", "--rewrite=cnta", "--cache=all"]
192
193
}

194
generateAst.dependsOn relast
René Schöne's avatar
René Schöne committed
195
196
197
198
199
200

//708
publishing {
    publications {
        maven(MavenPublication) {
            artifactId = 'ragconnect'
201
202
203
204
205
            // Comment rs: components.java does not include relast.preprocessor
            // from components.java
            artifact("build/libs/ragconnect-${version}.jar") {
                extension 'jar'
            }
René Schöne's avatar
René Schöne committed
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
        }
    }
    repositories {
        maven {
            url "https://git-st.inf.tu-dresden.de/api/v4/projects/708/packages/maven"
            // Uncomment the following lines to publish manually (and comment out the other credentials section)
//            credentials(HttpHeaderCredentials) {
//                name = "Private-Token"
//                value = gitLabPrivateToken // the variable resides in ~/.gradle/gradle.properties
//            }
            credentials(HttpHeaderCredentials) {
                name = 'Job-Token'
                value = System.getenv("CI_JOB_TOKEN")
            }
            authentication {
                header(HttpHeaderAuthentication)
            }
        }

    }
}

publish.dependsOn jar