apply plugin: 'application'

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
  antlr "org.antlr:antlr4:$antlr_version"
  compile "org.antlr:antlr4-runtime:$antlr_version"
  compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
  compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
  compile 'com.fifesoft:rsyntaxtextarea:2.5.8'
  compile 'com.fifesoft:autocomplete:2.5.8'
  compile "com.github.strumenta:kolasu:$kolasu_version"
  implementation 'com.github.ftomassetti:antlr4-c3-kotlin:v0.2.0'
  compile group: 'org.javassist', name: 'javassist', version: '3.21.0-GA'
  testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
  testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
  testCompile 'junit:junit:4.12'
}

mainClassName = "me.tomassetti.kanvas.KanvasKt"

generateGrammarSource {
    maxHeapSize = "64m"
    arguments += ['-package', 'me.tomassetti.antlr']
    outputDirectory = new File("generated-src/antlr/main/me/tomassetti/antlr".toString())
}

generateTestGrammarSource {
    maxHeapSize = "64m"
    arguments += ['-package', 'me.tomassetti.antlr']
    outputDirectory = new File("generated-src/antlr/test/me/tomassetti/antlr".toString())
}

compileJava.dependsOn generateGrammarSource
compileKotlin.dependsOn generateGrammarSource
compileTestJava.dependsOn generateTestGrammarSource
compileTestKotlin.dependsOn generateTestGrammarSource
sourceSets {
    generated {
        java.srcDir 'generated-src/antlr/main/'
    }
    testGenerated {
        java.srcDir 'generated-src/antlr/test/'  
    }
}
compileJava.source sourceSets.generated.java, sourceSets.main.java
compileTestJava.source sourceSets.testGenerated.java, sourceSets.test.java

clean{
    delete "generated-src"
}

idea {
    module {
        sourceDirs += file("generated-src/antlr/main")
        testSourceDirs += file("generated-src/antlr/test")        
    }
}

sourceSets {
    main {
        java {
            srcDirs 'generated-src/antlr/main'
        }
        kotlin {
            srcDirs 'src/main/kotlin'
        }
    }
    test {
        java {
            srcDirs 'generated-src/antlr/test'
        }
        kotlin {
            srcDirs 'src/test/kotlin'
        }   
    }
}
