Skip to content

Commit 2c0e90f

Browse files
authored
Fix ESQL tests in IntelliJ (#107313)
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.
1 parent 648c9cb commit 2c0e90f

File tree

258 files changed

+8
-18
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

258 files changed

+8
-18
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,4 @@ testfixtures_shared/
6868

6969
# Generated
7070
checkstyle_ide.xml
71-
x-pack/plugin/esql/gen/
71+
x-pack/plugin/esql/src/main/generated-src/generated/

x-pack/plugin/esql/build.gradle

+7-17
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,10 @@ dependencies {
4040
internalClusterTestImplementation project(":modules:mapper-extras")
4141
}
4242

43-
/*
44-
* IntelliJ will always put the java files generated by the annotation processor
45-
* into src/main/java/generated so we make gradle play along. This block makes
46-
* it put the generated files into the same spot and the next block stops it from
47-
* trying to compile the generated files in the regular compile - it'll regenerate
48-
* them and *then* compile them.
49-
*/
5043
tasks.named("compileJava").configure {
51-
options.compilerArgs.addAll(["-s", "${projectDir}/src/main/java/generated"])
52-
}
53-
54-
tasks.named("javadoc").configure {
55-
include("${projectDir}/src/main/java/generated")
56-
}
57-
58-
sourceSets.main.java {
59-
exclude 'generated/**'
44+
options.compilerArgs.addAll(["-s", "${projectDir}/src/main/generated"])
45+
// IntelliJ sticks generated files here and we can't stop it....
46+
exclude { it.file.toString().startsWith("${projectDir}/src/main/generated-src/generated") }
6047
}
6148

6249
tasks.named("test").configure {
@@ -149,7 +136,8 @@ pluginManager.withPlugin('com.diffplug.spotless') {
149136
// for some reason "${outputPath}/EsqlBaseParser*.java" does not match the same files...
150137
targetExclude "src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseLexer*.java",
151138
"src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser*.java",
152-
"src/main/java/generated/**/*.java"
139+
"src/main/generated/**/*.java",
140+
"src/main/generated-src/generated/**/*.java"
153141
}
154142
}
155143
}
@@ -250,6 +238,8 @@ tasks.register("regen") {
250238
tasks.named("spotlessJava") { dependsOn stringTemplates }
251239
tasks.named('checkstyleMain').configure {
252240
excludes = [ "**/*.java.st" ]
241+
exclude { it.file.toString().startsWith("${projectDir}/src/main/generated-src/generated") }
242+
exclude { it.file.toString().startsWith("${projectDir}/src/main/generated") }
253243
}
254244

255245
def prop(Type, type, TYPE, BYTES, Array) {

0 commit comments

Comments
 (0)