Skip to content

Commit

Permalink
Fix ESQL tests in IntelliJ (#107313)
Browse files Browse the repository at this point in the history
Landing #107018 broke running ESQL unit tests in IntelliJ. It has
*something* to do with turning on the stringtemplate plugin in the esql
project but I don't really know what. After that PR we'd often get
errors about trying to regenerate evaluators twice. I dunno. This fixes
it. But I don't really know why.

The way this fixes it is by making the `esql` project more like the
`copmute` project. It makes sense that that would help - they both have
the same code generation configuration. Anyway, the operative change is
landing the generated files in the same place as the `compute` project.
Thus all of the file moves.

Again, I have no idea why this works. It's build black magic and I just
shook it until it worked. Most of the credit goes to git-bisect for
finding the commit that broke this.
  • Loading branch information
nik9000 authored Apr 11, 2024
1 parent 648c9cb commit 2c0e90f
Show file tree
Hide file tree
Showing 258 changed files with 8 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ testfixtures_shared/

# Generated
checkstyle_ide.xml
x-pack/plugin/esql/gen/
x-pack/plugin/esql/src/main/generated-src/generated/
24 changes: 7 additions & 17 deletions x-pack/plugin/esql/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,10 @@ dependencies {
internalClusterTestImplementation project(":modules:mapper-extras")
}

/*
* IntelliJ will always put the java files generated by the annotation processor
* into src/main/java/generated so we make gradle play along. This block makes
* it put the generated files into the same spot and the next block stops it from
* trying to compile the generated files in the regular compile - it'll regenerate
* them and *then* compile them.
*/
tasks.named("compileJava").configure {
options.compilerArgs.addAll(["-s", "${projectDir}/src/main/java/generated"])
}

tasks.named("javadoc").configure {
include("${projectDir}/src/main/java/generated")
}

sourceSets.main.java {
exclude 'generated/**'
options.compilerArgs.addAll(["-s", "${projectDir}/src/main/generated"])
// IntelliJ sticks generated files here and we can't stop it....
exclude { it.file.toString().startsWith("${projectDir}/src/main/generated-src/generated") }
}

tasks.named("test").configure {
Expand Down Expand Up @@ -149,7 +136,8 @@ pluginManager.withPlugin('com.diffplug.spotless') {
// for some reason "${outputPath}/EsqlBaseParser*.java" does not match the same files...
targetExclude "src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseLexer*.java",
"src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser*.java",
"src/main/java/generated/**/*.java"
"src/main/generated/**/*.java",
"src/main/generated-src/generated/**/*.java"
}
}
}
Expand Down Expand Up @@ -250,6 +238,8 @@ tasks.register("regen") {
tasks.named("spotlessJava") { dependsOn stringTemplates }
tasks.named('checkstyleMain').configure {
excludes = [ "**/*.java.st" ]
exclude { it.file.toString().startsWith("${projectDir}/src/main/generated-src/generated") }
exclude { it.file.toString().startsWith("${projectDir}/src/main/generated") }
}

def prop(Type, type, TYPE, BYTES, Array) {
Expand Down

0 comments on commit 2c0e90f

Please sign in to comment.