Skip to content

Commit

Permalink
fixed generate antlr code from Axiom package grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
domko17 committed Sep 27, 2023
1 parent 90f9944 commit c7958ca
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion studio-idea-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ tasks {

generateGrammarSource {
// include("**/antlr4/**/*.g4")
// outputDirectory = file("${project.buildDir}/generated-src/")
// arguments.addAll(listOf(
// "-package", "com.evolveum.midpoint.studio.lang.properties"
// ))
Expand All @@ -266,4 +267,32 @@ tasks {
}
}

tasks.getByName("compileKotlin").dependsOn("generateGrammarSource")
tasks.register("copyGrammarFromAxiom") {
val compileClasspath: FileCollection = configurations["compileClasspath"]
val grammarFolder = file("${project.buildDir}/generated-src/com/evolveum/midpoint/studio/lang/antlr")
dependsOn(compileClasspath)

doLast {
if (!grammarFolder.isDirectory) {
project.mkdir(grammarFolder.toString())
}

compileClasspath.map {
lib: File -> lib
if (lib.name == "axiom-${libs.versions.midpoint.get()}.jar") {
zipTree(lib).forEach{
if (it.name.endsWith(".g4")) {
print(it.absolutePath.toString())
copy {
from(layout.buildDirectory.file(it.absolutePath.toString()))
into(layout.buildDirectory.dir(grammarFolder.absolutePath.toString()))
}
}
}
}
}
}
}

tasks.getByName("generateGrammarSource").dependsOn("copyGrammarFromAxiom")
tasks.getByName("compileKotlin").dependsOn("copyGrammarFromAxiom")

0 comments on commit c7958ca

Please sign in to comment.