build.gradle 3.22 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
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
buildscript {
    repositories.jcenter()
    dependencies {
        classpath 'org.jastadd:jastaddgradle:1.13.3'
    }
}

plugins {
    id 'java'
    id 'idea'
    id 'application'
}

apply plugin: 'jastadd'

mainClassName = 'de.tudresden.inf.st.mrc.MinimalMain'

repositories {
    jcenter()
}

apply plugin: 'jastadd'

configurations {
    baseRuntimeClasspath
}

File genSrc = file("src/gen/java")
sourceSets.main.java.srcDir genSrc
idea.module.generatedSourceDirs += genSrc

dependencies {
    implementation fileTree(include: ['dumpAst2uml.jar'], dir: 'libs')
    implementation group: 'org.fusesource.mqtt-client', name: 'mqtt-client', version: '1.15'
    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'

    jastadd2 "org.jastadd:jastadd:2.3.4"
}

// Input files for relast
def relastFiles = ["src/gen/jastadd/MinimalModel.relast", "src/gen/jastadd/RagConnect.relast"]

// phases: ragConnect -> RelAst -> JastAdd
// phase: ragConnect
task ragConnect(type: JavaExec) {
    group = 'Build'
    main = '-jar'

    args([
            'libs/ragconnect.jar',
            '--verbose',
            '--o=src/gen/jastadd',
            'src/main/jastadd/MinimalModel.relast',
            'src/main/jastadd/MinimalModel.connect',
            '--rootNode=MinimalModel'
    ])
}

// phase: RelAst
task relastToJastAdd(type: JavaExec) {
    group = 'Build'
    main = "-jar"

    args(["libs/relast.jar",
            "--grammarName=./src/gen/jastadd/model",
            "--useJastAddNames",
            "--listClass=java.util.ArrayList",
            "--jastAddList=JastAddList",
            "--resolverHelper",
            "--file"]
    +
            relastFiles)

    inputs.files relastFiles
    outputs.files file("./src/gen/jastadd/model.ast"), file("./src/gen/jastadd/model.jadd")
}

// phase: JastAdd
jastadd {
    configureModuleBuild()
    modules {
        //noinspection GroovyAssignabilityCheck
        module("minimal") {

            java {
                basedir "src/"
                include "main/**/*.java"
                include "gen/**/*.java"
            }

            jastadd {
                basedir "src/"
                include "main/jastadd/**/*.ast"
                include "main/jastadd/**/*.jadd"
                include "main/jastadd/**/*.jrag"
                include "gen/jastadd/**/*.ast"
                include "gen/jastadd/**/*.jadd"
                include "gen/jastadd/**/*.jrag"
            }
        }
    }

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

    preprocessParser.doFirst {

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

    }

    module = "minimal"

    astPackage = 'de.tudresden.inf.st.mrc.ast'

    genDir = 'src/gen/java'

    buildInfoDir = 'src/gen-res'

    // jastaddOptions = ["--lineColumnNumbers", "--visitCheck=true", "--rewrite=cnta", "--cache=all"]
    // default options are: '--rewrite=cnta', '--safeLazy', '--visitCheck=false', '--cacheCycle=false'
    extraJastAddOptions = ["--lineColumnNumbers", '--List=JastAddList']
}

// Workflow configuration for phases
generateAst.dependsOn relastToJastAdd
relastToJastAdd.dependsOn ragConnect