Skip to content

Commit 765286c

Browse files
craigtaverneromricohenn
authored andcommitted
Fix ES|QL build.gradle for configuration-cache (elastic#125097)
Earlier work on the ES|QL port of docs to V3 introduced an issue in the build.gradle file making it fail with --configuration-cache. This fixes that, as well as one other broken link and removes some unused files. In addition we bring back partial support for deleting unused files. It is tricky to have full support for this due to the mix of static and generated content, particularly in the operators snippets.
1 parent 0660cf7 commit 765286c

File tree

4 files changed

+32
-34
lines changed

4 files changed

+32
-34
lines changed

docs/reference/query-languages/esql/_snippets/operators/types/not_like.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

docs/reference/query-languages/esql/_snippets/operators/types/not_rlike.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

x-pack/plugin/esql/build.gradle

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,18 @@ tasks.named("test").configure {
9999
def imagesDocFolder = file("${rootDir}/docs/reference/query-languages/esql/images")
100100
def snippetsDocFolder = file("${rootDir}/docs/reference/query-languages/esql/_snippets")
101101
def kibanaDocFolder = file("${rootDir}/docs/reference/query-languages/esql/kibana")
102+
def snippetsTree = fileTree(snippetsFolder).matching {
103+
include "**/types/*.md" // Recursively include all types/*.md files (effectively counting functions and operators)
104+
}
105+
def imagesTree = fileTree(imagesFolder).matching {
106+
include "**/*.svg" // Recursively include all SVG files
107+
}
108+
def kibanaTree = fileTree(kibanaFolder).matching {
109+
include "**/*.json" // Recursively include all JSON files
110+
}
102111

103112
doLast {
104-
List snippets = fileTree(snippetsFolder).matching {
105-
include "**/types/*.md" // Recursively include all types/*.md files (effectively counting functions and operators)
106-
}.files.collect { it.name }
113+
def snippets = snippetsTree.files.collect { it.name }
107114
int countSnippets = snippets.size()
108115
if (countSnippets == 0) {
109116
logger.quiet("ESQL Docs: No function/operator snippets created. Skipping sync.")
@@ -113,19 +120,27 @@ tasks.named("test").configure {
113120
from snippetsFolder
114121
into snippetsDocFolder
115122
include '**/*.md'
116-
preserve {
117-
// The snippets directory contains generated and static content, so we must preserve all MD files.
118-
include '**/*.md'
123+
if (countSnippets <= 100) {
124+
// If we do not run the full test of tests, do not attempt to remove potentially unused files
125+
preserve {
126+
// The snippets directory contains generated and static content, so we must preserve all MD files.
127+
include '**/*.md'
128+
}
129+
} else {
130+
// If we do run the full test of tests, be careful about what we need to preserve
131+
preserve {
132+
// The lists are static, and the operators are a mix of generated and static content
133+
include '*.md', '**/operators/*.md', '**/operators/**/*.md', '**/lists/*.md'
134+
}
119135
}
120136
}
121137
}
122138

123-
List images = fileTree(imagesFolder).matching {
124-
include "**/*.svg" // Recursively include all SVG files
125-
}.files.collect { it.name }
139+
List images = imagesTree.files.collect { it.name }
126140
int countImages = images.size()
127141
Closure replaceFont = line -> {
128142
// The es-docs team has a recommended set of fonts for use with code, and they size similarly to the previous Roboto Mono, which is no longer available in the docs webpage
143+
// We do not change the original SVG generator to use these because it requires the fonts to exist in the JVM running the code
129144
line.replaceAll(
130145
/font-family:\s*Roboto Mono[^;]*;/,
131146
'font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;'
@@ -139,17 +154,18 @@ tasks.named("test").configure {
139154
from imagesFolder
140155
into imagesDocFolder
141156
include '**/*.svg'
142-
preserve {
143-
// Some operator files are currently static, so we must preserve them all
144-
include '**/*.svg'
157+
if (countImages <= 100) {
158+
// If we do not run the full test of tests, do not attempt to remove potentially unused files
159+
preserve {
160+
// Some operator files are currently static, so we must preserve them all
161+
include '**/*.svg'
162+
}
145163
}
146164
filter replaceFont
147165
}
148166
}
149167

150-
List kibana = fileTree(kibanaFolder).matching {
151-
include "**/*.json" // Recursively include all JSON files
152-
}.files.collect { it.name }
168+
List kibana = kibanaTree.files.collect { it.name }
153169
int countKibana = kibana.size()
154170
if (countKibana == 0) {
155171
logger.quiet("ESQL Docs: No function/operator kibana docs created. Skipping sync.")

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/DocsV3Support.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ private String getLink(String key) {
310310
// Various other remaining old asciidoc links
311311
// <<match-field-params,match query parameters>>
312312
return switch (parts[0]) {
313-
case "match-field-params" -> makeLink(key, "", "/reference/query-languages/query-dsl-match-query.md");
313+
case "match-field-params" -> makeLink(key, "", "/reference/query-languages/query-dsl/query-dsl-match-query.md");
314314
case "search-aggregations-bucket-histogram-aggregation" -> makeLink(
315315
key,
316316
"",

0 commit comments

Comments
 (0)