Skip to content

Commit c8bfd21

Browse files
committed
Create gradle task to compile logstash-bridge module and add jar file to the plugin to make Stable API interfaces available.
1 parent a9d7625 commit c8bfd21

File tree

1 file changed

+58
-1
lines changed

1 file changed

+58
-1
lines changed

build.gradle

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ dependencies {
7272
elasticsearchClient('co.elastic.clients:elasticsearch-java') {
7373
// brings latest version available for 8.x branch
7474
version {
75-
strictly('[8.0, 9.0[')
75+
strictly('[8.0, 9.0]')
7676
}
7777
}
7878
elasticsearchMinimalCore fileTree(dir: { importMinimalElasticsearch.jars }, include: ["*.jar"])
@@ -257,6 +257,45 @@ task buildElasticsearchLocalDistro(dependsOn: unzipDownloadedElasticsearchSource
257257
}
258258
}
259259

260+
task buildElasticsearchLogstashBridge(type: Exec) {
261+
description "builds logstash-bridge lib module"
262+
263+
dependsOn buildElasticsearchLocalDistro
264+
mustRunAfter buildElasticsearchLocalDistro
265+
266+
def logFile = project.file("${buildDir}/logstash-bridge-build.log")
267+
doFirst {
268+
def funneler = new OutputStreamFunneler(new LazyFileOutputStream(logFile))
269+
standardOutput = funneler.funnelInstance
270+
errorOutput = funneler.funnelInstance
271+
}
272+
273+
def esSource = "${buildDir}/elasticsearch-source/"
274+
def esBuildDir = "${esSource}/build"
275+
276+
inputs.dir esSource
277+
outputs.dir "${esBuildDir}/libs/logstash-bridge"
278+
279+
ext.buildRoot = esBuildDir
280+
workingDir esSource
281+
commandLine "./gradlew", ":lib:logstash-bridge:build"
282+
283+
ignoreExitValue true // handled in doLast
284+
doLast {
285+
def exitValue = executionResult.get().exitValue
286+
if (exitValue != 0) {
287+
if (logFile.exists()) {
288+
println "\n===== Elasticsearch logstash-bridge build Log ====="
289+
println logFile.text
290+
println "===== End of Elasticsearch logstash-bridge build Log =====\n"
291+
} else {
292+
"Elasticsearch logstash-bridge build failed and ${logFile.path} log does not exist"
293+
}
294+
throw new GradleException("Elasticsearch logstash-bridge build failed, see the logs for details.")
295+
}
296+
}
297+
}
298+
260299
task shadeElasticsearchIngestGeoIpModule(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
261300
description "Shades embedded dependencies of the Elasticsearch Ingest GeoIP module"
262301

@@ -316,13 +355,30 @@ task shadeElasticsearchRedactPlugin(type: com.github.jengelman.gradle.plugins.sh
316355
exclude '**/module-info.class'
317356
}
318357

358+
task shadeElasticsearchLogstashBridge(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
359+
description "Shades the Elasticsearch logstash-bridge jar"
360+
361+
dependsOn buildElasticsearchLogstashBridge
362+
363+
from("${buildDir}/elasticsearch-source/libs/logstash-bridge/build/distributions") {
364+
include "elasticsearch-logstash-bridge-*.jar"
365+
}
366+
367+
archiveFileName = "elasticsearch-logstash-bridge-shaded.jar"
368+
destinationDirectory = file("${buildDir}/shaded")
369+
370+
exclude '**/module-info.class'
371+
}
372+
319373
task importMinimalElasticsearch() {
320374
description "Imports minimal portions of Elasticsearch localDistro"
321375

322376
dependsOn buildElasticsearchLocalDistro
377+
dependsOn buildElasticsearchLogstashBridge
323378
dependsOn shadeElasticsearchIngestGeoIpModule
324379
dependsOn shadeElasticsearchGrokImplementation
325380
dependsOn shadeElasticsearchRedactPlugin
381+
dependsOn shadeElasticsearchLogstashBridge
326382

327383
ext.jars = "${buildDir}/elasticsearch-minimal-jars"
328384

@@ -341,6 +397,7 @@ task importMinimalElasticsearch() {
341397
include jarPackageNamed("lucene-core")
342398
include jarPackageNamed("lucene-analysis-common")
343399
}
400+
from(shadeElasticsearchLogstashBridge)
344401
from(shadeElasticsearchGrokImplementation)
345402
from(buildElasticsearchLocalDistro.module("x-pack-core"))
346403

0 commit comments

Comments
 (0)