Ошибка Gradle в build.gradle. Проект IntelliJ Kotlin + JAVA + ANTLR. "Не удалось получить неизвестное свойство 'sourceFile'" - PullRequest
0 голосов
/ 08 апреля 2020

Я пытаюсь построить проект Kotlin + ANTLR, используя Gradle 5.6.2 в IntelliJ. У меня есть структура: enter image description here

build.gradle всегда вызывает эту спецификацию c error "Не удалось получить неизвестное свойство 'sourceFile' для задачи ': compileSandyFile 'типа org.gradle.api.tasks.JavaExe c. " build.gradle:

   ext.kotlin_version = '1.3.61'//'1.0.3'

   repositories {
     mavenCentral()
     maven {
        name 'JFrog OSS snapshot repo'
        url  'https://oss.jfrog.org/oss-snapshot-local/'
     }
     jcenter()
   }

   dependencies {
     classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
   }
}

apply plugin: 'kotlin'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'antlr'

repositories {
  mavenLocal()
  mavenCentral()
  jcenter()
}

dependencies {
  antlr "org.antlr:antlr4:4.5.1"
  compile "org.antlr:antlr4-runtime:4.5.1"
  compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
  compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
  compile 'org.ow2.asm:asm-all:5.1'
  testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
  testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
  testCompile 'junit:junit:4.12'
}

generateGrammarSource {
    maxHeapSize = "64m"
    arguments += ['-package', 'me.tomassetti.langsandbox']
    outputDirectory = new File("generated-src/antlr/main/me/tomassetti/langsandbox".toString())
}
compileJava.dependsOn generateGrammarSource
sourceSets {
    generated {
        java.srcDir 'generated-src/antlr/main/'
    }
}
compileJava.source sourceSets.generated.java, sourceSets.main.java
compileKotlin.source sourceSets.generated.java, sourceSets.main.java, sourceSets.main.kotlin

clean{
    delete "generated-src"
}

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

task compileSandyFile(type:JavaExec) {
    main = "me.tomassetti.sandy.compiling.JvmKt"
    args = "$sourceFile"
    classpath = sourceSets.main.runtimeClasspath
}
...