Skip to content
Snippets Groups Projects
Select Git revision
  • 06a0e6848f2d46344f179dc44f74d7889bae55e0
  • dev default protected
  • main protected
  • chore/using-handlebars
4 results

build.gradle

Blame
  • build.gradle 4.42 KiB
    apply plugin: 'jastadd'
    apply plugin: 'application'
    apply plugin: 'idea'
    
    sourceCompatibility = 1.8
    
    mainClassName = 'org.jastadd.dumpAst2uml.compiler.Compiler'
    
    repositories {
        jcenter()
    }
    
    buildscript {
        repositories.jcenter()
        dependencies {
            classpath 'org.jastadd:jastaddgradle:1.13.3'
        }
    }
    
    dependencies {
        implementation project(':grammar2uml')  // just to test SimpleMain
        implementation fileTree(include: ['plantuml.jar'], dir: '../libs')
    //    implementation project(':relast.preprocessor')
    
        implementation group: 'com.github.spullara.mustache.java', name: 'compiler', version: '0.9.6'
        implementation group: 'org.apache.logging.log4j', name: 'log4j-jul', version: '2.11.2'
        runtime group: 'org.jastadd', name: 'jastadd', version: '2.3.4'
        api group: 'net.sf.beaver', name: 'beaver-rt', version: '0.9.11'
    
        testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.4.0'
        testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.4.0'
        testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.12.1'
    }
    
    def versionFile = 'src/main/resources/dumpAst2umlVersion.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)
        }
    }
    
    jar {
        manifest {
            attributes "Main-Class": mainClassName
        }
    
        from {
            configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
            configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
        }
    
        archiveBaseName = 'dumpAst2uml'
    }
    
    File genSrc = file("src/gen/java")
    sourceSets.main.java.srcDir genSrc
    idea.module.generatedSourceDirs += genSrc
    
    test {
        useJUnitPlatform()
    
        maxHeapSize = '1G'
    }
    
    File dumpAstGrammar = file('./src/main/jastadd/DumpAst.relast')
    
    task relast(type: JavaExec) {
        group = 'Build'
        main = "-jar"
    
        doFirst {
            delete "src/gen/jastadd/*.ast"
            delete "src/gen/jastadd/DumpAst2.jadd"
            delete "src/gen/jastadd/DumpAstlRefResolver.jadd"
            delete "src/gen/jastadd/DumpAstlResolverStubs.jrag"
            mkdir  "src/gen/jastadd/"
        }
    
        args = [
                "../libs/relast.jar",
                dumpAstGrammar,
    //            "./src/main/jastadd/MustacheNodes.relast",
                "--listClass=java.util.ArrayList",
                "--jastAddList=JastAddList",
                "--useJastAddNames",
                "--file",
                "--resolverHelper",
                "--grammarName=./src/gen/jastadd/DumpAst2"
        ]
    
        inputs.files(file("../libs/relast.jar"),
                dumpAstGrammar)
        outputs.files(file("./src/gen/jastadd/DumpAst2.ast"),
                file("./src/gen/jastadd/DumpAst.jadd"),
                file("./src/gen/jastadd/DumpAstRefResolver.jadd"),
                file('./src/gen/jastadd/DumpAstResolverStubs.jrag'))
    }
    
    jastadd {
        configureModuleBuild()
        modules {
            //noinspection GroovyAssignabilityCheck
            module("DumpAst2Uml") {
    
                java {
                    basedir ".."
                    include "dumpAst2uml/src/main/**/*.java"
                    include "dumpAst2uml/src/gen/**/*.java"
                }
    
                jastadd {
                    basedir ".."
                    include "dumpAst2uml/src/main/jastadd/**/*.ast"
                    include "dumpAst2uml/src/main/jastadd/**/*.jadd"
                    include "dumpAst2uml/src/main/jastadd/**/*.jrag"
                    include "dumpAst2uml/src/gen/jastadd/**/*.ast"
                    include "dumpAst2uml/src/gen/jastadd/**/*.jadd"
                    include "dumpAst2uml/src/gen/jastadd/**/*.jrag"
                }
            }
        }
    
        cleanGen.doFirst {
            delete "src/gen/java/org"
            delete "src/gen-res/BuildInfo.properties"
        }
    
        preprocessParser.doFirst {
    
            args += ["--no-beaver-symbol"]
    
        }
    
        module = "DumpAst2Uml"
        astPackage = 'org.jastadd.dumpAst2uml.ast'
        genDir = 'src/gen/java'
        buildInfoDir = 'src/gen-res'
        jastaddOptions = ["--lineColumnNumbers", "--List=JastAddList", "--safeLazy", "--visitCheck=true", "--rewrite=cnta", "--cache=all"]
    }
    
    generateAst.dependsOn relast