// Copied and adapted from plugin "Graph Database Support"
// by Neueda Technologies, Ltd.
// Modified by Alberto Venturini, 2022

import org.jetbrains.grammarkit.tasks.GenerateLexerTask
import org.jetbrains.grammarkit.tasks.GenerateParserTask

apply plugin: "org.jetbrains.intellij"
apply plugin: "org.jetbrains.grammarkit"

intellij {
    version = intellijSdkVersion
    plugins = ['java']
}

tasks.register("generateCypherLexer", GenerateLexerTask.class) {
    sourceFile = new File("src/main/java/com/albertoventurini/graphdbplugin/language/cypher/lexer/CypherLexer.flex")
    targetDir = "src/main/gen/com/albertoventurini/graphdbplugin/language/cypher/lexer/"
    targetClass = "CypherLexer"
    purgeOldFiles = true
}

tasks.register("generateCypherParser", GenerateParserTask.class) {
    sourceFile = new File("src/main/java/com/albertoventurini/graphdbplugin/language/cypher/lexer/Cypher.bnf")
    targetRoot = "src/main/gen"
    pathToParser = "com/albertoventurini/graphdbplugin/language/cypher/CypherParser.java"
    pathToPsiRoot = "com/albertoventurini/graphdbplugin/language/cypher/psi"
    purgeOldFiles = true
}

compileJava {
    dependsOn generateCypherLexer
    dependsOn generateCypherParser
}

sourceSets {
    main {
        java {
            // Add sources generated by Grammar-Kit for parser to build.
            srcDirs 'src/main/java', 'src/main/gen'
        }
    }
}

dependencies {
    implementation project(":platform")

    testImplementation "org.mockito:mockito-core:$versionMockito"
    testImplementation "org.assertj:assertj-core:$versionAssertj"
}
