nkiesel
08/17/2022, 1:52 AMbuild/generated-src/antlr/main
and have a package com.example.antlr
first line (i.e. there is a mismatch between the directory path and the package path, but AFAIK the Koltin compiler does not care about that). I tried to fix the compile error using
val antlrGeneratedFilesDirectory = file("${buildDir}/generated-src/antlr/main")
idea {
module {
generatedSourceDirs.add(antlrGeneratedFilesDirectory)
sourceDirs.add(antlrGeneratedFilesDirectory)
}
}
but that did not help either. Anyone has an idea what I could try to fix this?
BTW: I can navigate in IntelliJ to the generated sources from the import statement, so IntelliJ does somehow find the files.Vampire
08/17/2022, 2:04 AMg4
file from src/main/antlr
to src/main/antlr/com/example/antlr/
, the files should also land in the proper subdirectory tree.
but AFAIK the Koltin compiler does not care about thatDoes ANTLR now also support generating Kotlin files? If not, which I assume, then this statement is irrelevant, as you are compiling Java files there, not Kotlin files, and afaik Kotlin compiler does not do joint compilation. And regarding having the files marked as generated sources in IntelliJ, this should suffice:
val generateGrammarSource by tasks.existing(AntlrTask::class)
idea.module {
generatedSourceDirs.add(generateGrammarSource.get().outputDirectory)
}
nkiesel
08/17/2022, 2:10 AMnkiesel
08/17/2022, 2:11 AMnkiesel
08/17/2022, 2:12 AMVampire
08/17/2022, 2:13 AMnkiesel
08/17/2022, 5:14 AMkotlin {
sourceSets.main.get().kotlin.srcDirs += tasks.generateGrammarSource.get().outputDirectory
}
ephemient
08/17/2022, 2:02 PM.srcDir(tasks.generateGrammarSource)
instead, it'll get the task dependencies rightnkiesel
08/17/2022, 10:07 PMsrcDir
method.ephemient
08/17/2022, 10:15 PM.srcDirs += tasks.generateGrammarSource.get().outputDirectory
, should work as .srcDir(tasks.generateGrammarSource)
(or something like tasks.generateGrammarSource.flatMap { it.outputDirectory }
if it has multiple outputs and you need to specify which one)nkiesel
08/18/2022, 12:08 AMkotlin {
sourceSets.main.get().kotlin.srcDir(tasks.generateGrammarSource)
}