Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ task buildElasticsearchLogstashBridge(type: Exec) {
}
}

def ingestGeoipPluginShadeNamespace = "org.elasticsearch.ingest.geoip.shaded"
def ipLocationModuleShadeNamespace = "org.elasticsearch.iplocation.shaded"

/**
* The StableBridge exposes GeoIP plugin internals, so it needs to relocate references to
Expand All @@ -360,24 +360,24 @@ task shadeElasticsearchStableBridge(type: com.github.jengelman.gradle.plugins.sh
archiveFileName = "logstash-stable-bridge-shaded.jar"
destinationDirectory = file("${buildDir}/shaded")

relocate('com.fasterxml.jackson', "${ingestGeoipPluginShadeNamespace}.com.fasterxml.jackson")
relocate('com.maxmind', "${ingestGeoipPluginShadeNamespace}.com.maxmind")
relocate('com.fasterxml.jackson', "${ipLocationModuleShadeNamespace}.com.fasterxml.jackson")
relocate('com.maxmind', "${ipLocationModuleShadeNamespace}.com.maxmind")

mergeServiceFiles()
}

task shadeElasticsearchIngestGeoIpModule(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
description "Shades embedded dependencies of the Elasticsearch Ingest GeoIP module"
task shadeElasticsearchIpLocationModule(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
description "Shades embedded dependencies of the Elasticsearch IP location module"

dependsOn buildElasticsearchLocalDistro

from(buildElasticsearchLocalDistro.module("ingest-geoip").orElse(objects.fileCollection()))
from(buildElasticsearchLocalDistro.module("ip-location").orElse(objects.fileCollection()))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need everything, or can we get only the geoip dependencies?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, as per my analysis (correct me if I am wrong), we need all (ip-location, ip-location-api and ingest-ip-location) need to exist in the JARs but we have to only shade the ip-location since others are references by the logstash-bridge:

  • IpLocationServiceAdapter from ingest-ip-location
  • no-op IpLocationService from ip-location-api


archiveFileName = 'ingest-geoip-shaded.jar'
archiveFileName = 'ip-location-shaded.jar'
destinationDirectory = file("${buildDir}/shaded")

relocate('com.fasterxml.jackson', "${ingestGeoipPluginShadeNamespace}.com.fasterxml.jackson")
relocate('com.maxmind', "${ingestGeoipPluginShadeNamespace}.com.maxmind")
relocate('com.fasterxml.jackson', "${ipLocationModuleShadeNamespace}.com.fasterxml.jackson")
relocate('com.maxmind', "${ipLocationModuleShadeNamespace}.com.maxmind")

mergeServiceFiles()

Expand Down Expand Up @@ -433,7 +433,7 @@ task importMinimalElasticsearch() {

dependsOn buildElasticsearchLocalDistro
dependsOn shadeElasticsearchStableBridge
dependsOn shadeElasticsearchIngestGeoIpModule
dependsOn shadeElasticsearchIpLocationModule
dependsOn shadeElasticsearchGrokImplementation
dependsOn shadeElasticsearchRedactPlugin

Expand All @@ -453,6 +453,7 @@ task importMinimalElasticsearch() {
include jarPackageNamed("elasticsearch-x-content")
include jarPackageNamed("elasticsearch-geo")
include jarPackageNamed("elasticsearch-user-agent-api")
include jarPackageNamed("elasticsearch-ip-location-api")
include jarPackageNamed("lucene-core")
include jarPackageNamed("lucene-analysis-common")
include jarPackageNamed("hppc")
Expand All @@ -471,7 +472,11 @@ task importMinimalElasticsearch() {
include jarPackageNamed("user-agent")
}

from(shadeElasticsearchIngestGeoIpModule)
from(shadeElasticsearchIpLocationModule)
from(buildElasticsearchLocalDistro.module("ingest-ip-location")) {
include jarPackageNamed("ingest-ip-location")
}

from(shadeElasticsearchRedactPlugin)

from(buildElasticsearchLocalDistro.module("lang-mustache")) {
Expand Down Expand Up @@ -1008,4 +1013,5 @@ task unitSpecs(dependsOn: bundleInstall) {
clean {
delete "${projectDir}/*.gem"
delete "build"
delete "vendor/jar-dependencies"
}
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
LOGSTASH_PATH=../../logstash
ELASTICSEARCH_TREEISH=main
ELASTICSEARCH_REPO=eyalkoren/elasticsearch
ELASTICSEARCH_TREEISH=refactor-geoip
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
import org.apache.logging.log4j.Logger;
import org.elasticsearch.logstashbridge.core.CheckedBiFunctionBridge;
import org.elasticsearch.logstashbridge.geoip.AbstractExternalIpDatabaseBridge;
import org.elasticsearch.logstashbridge.geoip.IpDatabaseBridge;
import org.elasticsearch.ingest.geoip.shaded.com.maxmind.db.CHMCache;
import org.elasticsearch.ingest.geoip.shaded.com.maxmind.db.NoCache;
import org.elasticsearch.ingest.geoip.shaded.com.maxmind.db.NodeCache;
import org.elasticsearch.ingest.geoip.shaded.com.maxmind.db.Reader;
import org.elasticsearch.iplocation.shaded.com.maxmind.db.CHMCache;
import org.elasticsearch.iplocation.shaded.com.maxmind.db.NoCache;
import org.elasticsearch.iplocation.shaded.com.maxmind.db.NodeCache;
import org.elasticsearch.iplocation.shaded.com.maxmind.db.Reader;

import java.io.File;
import java.io.IOException;
Expand Down
Loading