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

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

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

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

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

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

dependencies {
René Schöne's avatar
René Schöne committed
27
28
29
    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
30
    implementation group: 'org.apache.logging.log4j', name: 'log4j-jul', version: '2.11.2'
René Schöne's avatar
René Schöne committed
31
    implementation group: 'com.github.spullara.mustache.java', name: 'compiler', version: '0.9.6'
René Schöne's avatar
René Schöne committed
32
    runtime group: 'org.jastadd', name: 'jastadd', version: '2.3.4'
René Schöne's avatar
René Schöne committed
33
    api group: 'net.sf.beaver', name: 'beaver-rt', version: '0.9.11'
34
35
}

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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
55
File genSrc = file("src/gen/java")
René Schöne's avatar
René Schöne committed
56
57
sourceSets.main.java.srcDir genSrc
idea.module.generatedSourceDirs += genSrc
58
59
60

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

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

    archiveBaseName = 'ragconnect'
69
70
}

René Schöne's avatar
René Schöne committed
71
72
73
74
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')
75
76
77
78
79
80
task relast(type: JavaExec) {
    group = 'Build'
    main = "-jar"

    args = [
            "../libs/relast.jar",
René Schöne's avatar
René Schöne committed
81
82
83
84
            preprocessorGrammar,
            ragConnectGrammar,
            intermediateGrammar,
            mustacheGrammar,
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("../libs/relast.jar",
René Schöne's avatar
René Schöne committed
94
95
96
97
            preprocessorGrammar,
            ragConnectGrammar,
            intermediateGrammar,
            mustacheGrammar)
98
99
100
101
    outputs.files("./src/gen/jastadd/RagConnect.ast",
            "./src/gen/jastadd/RagConnect.jadd",
            "./src/gen/jastadd/RagConnectRefResolver.jadd",
            './src/gen/jastadd/RagConnectResolverStubs.jrag')
102
103
}

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

            java {
111
                basedir ".."
René Schöne's avatar
René Schöne committed
112
113
                include "relast-preprocessor/main/**/*.java"
                include "relast-preprocessor/gen/**/*.java"
114
115
                include "ragconnect.base/src/main/**/*.java"
                include "ragconnect.base/src/gen/**/*.java"
116
117
118
            }

            jastadd {
119
                basedir ".."
René Schöne's avatar
René Schöne committed
120
121
122
                include "relast-preprocessor/src/main/jastadd/**/*.ast"
                include "relast-preprocessor/src/main/jastadd/**/*.jadd"
                include "relast-preprocessor/src/main/jastadd/**/*.jrag"
123
124
125
126
127
128
                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"
129
130
131
            }

            scanner {
132
                basedir ".."
René Schöne's avatar
René Schöne committed
133
134
135
136
137
138
                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]
139
                include "ragconnect.base/src/main/jastadd/scanner/Keywords.flex"
René Schöne's avatar
René Schöne committed
140
141
142
                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]
143
144
145
            }

            parser {
146
                basedir ".."
147
148
                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
149
                include "relast-preprocessor/src/main/jastadd/parser/RelAst.parser"
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
            }
        }
    }

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

    preprocessParser.doFirst {

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

    }

165
    module = "RagConnect"
166

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

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

    genDir = 'src/gen/java'

    buildInfoDir = 'src/gen-res'

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

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

181
generateAst.dependsOn relast
René Schöne's avatar
René Schöne committed
182
183
184
185
186
187

//708
publishing {
    publications {
        maven(MavenPublication) {
            artifactId = 'ragconnect'
188
189
190
191
192
            // 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
        }
    }
    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