Skip to content

Commit

Permalink
Update to Elasticsearch 7.17.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Ettore Elio Caprella committed Mar 10, 2022
1 parent 53c61f7 commit a419f44
Show file tree
Hide file tree
Showing 5 changed files with 267 additions and 130 deletions.
136 changes: 112 additions & 24 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
buildscript {
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask
import org.gradle.api.tasks.Input;
import org.gradle.process.CommandLineArgumentProvider;

import java.nio.file.Files
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.Supplier;
import java.util.stream.Collectors;

buildscript {
dependencies {
classpath "org.elasticsearch.gradle:build-tools:${elasticsearchVersion}"
}
repositories {
mavenCentral()
}
}

plugins {
id "co.riiid.gradle" version "0.4.2"
id "com.github.humblerookie.gradle" version "0.4.4"
id "com.github.ben-manes.versions" version '0.33.0'
}

repositories {
mavenCentral()
}

group = 'org.elasticsearch.plugin.ingest'
Expand All @@ -20,31 +32,25 @@ version = "${elasticsearchVersion}"
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'elasticsearch.esplugin'
apply plugin: 'elasticsearch.yaml-rest-test'
apply plugin: 'elasticsearch.testclusters'

// license of this project
licenseFile = rootProject.file('LICENSE.txt')
// copyright notices
noticeFile = rootProject.file('NOTICE.txt')
sourceCompatibility = '11'

esplugin {
name 'ingest-anonymize'
description 'Anonymize field using by replacing values with a consistent hash.'
classname 'org.elasticsearch.plugin.ingest.anonymize.IngestAnonymizePlugin'
name = 'ingest-anonymize'
description = 'Anonymize field using by replacing values with a consistent hash.'
classname = 'org.elasticsearch.plugin.ingest.anonymize.IngestAnonymizePlugin'
// license of the plugin, may be different than the above license
licenseFile rootProject.file('LICENSE.txt')
licenseFile = rootProject.file('LICENSE.txt')
// copyright notices, may be different than the above notice
noticeFile rootProject.file('NOTICE.txt')
noticeFile = rootProject.file('NOTICE.txt')
}

// In this section you declare the dependencies for your production and test code
// Note, the two dependencies are not really needed as the buildscript dependency gets them in already
// they are just here as an example
dependencies {
compile "org.elasticsearch:elasticsearch:${elasticsearchVersion}"

// the yaml tests require a log4j2 dependency, otherwise a dependency is thrown on startup
yamlRestTestImplementation 'org.apache.logging.log4j:log4j-core:2.11.1'
implementation "org.elasticsearch:elasticsearch:${elasticsearchVersion}"
}

githubRelease.doFirst {
Expand All @@ -65,13 +71,95 @@ githubRelease.doFirst {
}
}

// disable validation of pom creation, only needed for sonatype uploads
validateNebulaPom.enabled = false

// disable Javadoc tasks
tasks.withType(Javadoc).all { enabled = false }

// ignore javadoc linting errors for now
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}

// setup yaml rest tests
testClusters {
yamlRestTest
}

sourceSets {
yamlRestTest
}

configurations {
yamlRestTestImplementation.extendsFrom testImplementation
yamlRestTestRuntimeOnly.extendsFrom testRuntimeOnly
restTestSpecs
}

tasks.register('copyRestTestSpecs', Copy) {
from zipTree(configurations.restTestSpecs.singleFile)
into "$buildDir/restResources/restspec"
}

TaskProvider<Zip> bundle = project.getTasks().withType(Zip.class).named("bundlePlugin");

// Register rest resources with source set
sourceSets.yamlRestTest.getOutput().dir("$buildDir/restResources/restspec");

tasks.register('yamlRestTest', StandaloneRestIntegTestTask) { testTask ->
testTask.dependsOn(bundle, 'copyRestTestSpecs')

def cluster = testClusters.yamlRestTest
cluster.plugin(bundle.flatMap(AbstractArchiveTask::getArchiveFile))
testTask.useCluster(testClusters.yamlRestTest)

testTask.mustRunAfter(project.getTasks().named("test"))
testTask.setTestClassesDirs(sourceSets.yamlRestTest.getOutput().getClassesDirs())
testTask.setClasspath(sourceSets.yamlRestTest.getRuntimeClasspath())


SystemPropertyCommandLineArgumentProvider nonInputProperties = new SystemPropertyCommandLineArgumentProvider()
nonInputProperties.systemProperty("tests.rest.cluster", "${-> String.join(",", cluster.getAllHttpSocketURI())}")
nonInputProperties.systemProperty("tests.cluster", "${-> String.join(",", cluster.getAllTransportPortURI())}")
nonInputProperties.systemProperty("tests.clustername", "${-> cluster.getName()}")
testTask.getJvmArgumentProviders().add(nonInputProperties)
testTask.systemProperty("tests.rest.load_packaged", Boolean.FALSE.toString())
}

// this is a bit of a hack to make sure we run the test tests when releasing...
check.dependsOn 'yamlRestTest'

dependencies {
yamlRestTestImplementation "org.elasticsearch.test:framework:$elasticsearchVersion"
restTestSpecs "org.elasticsearch:rest-api-spec:$elasticsearchVersion"
}

// This will be available in 7.15 in build tools and not manually declared.
public class SystemPropertyCommandLineArgumentProvider implements CommandLineArgumentProvider {
private final Map<String, Object> systemProperties = new LinkedHashMap<>();

public void systemProperty(String key, Supplier<String> value) {
systemProperties.put(key, value);
}

public void systemProperty(String key, Object value) {
systemProperties.put(key, value);
}

@Override
public Iterable<String> asArguments() {
return systemProperties.entrySet()
.stream()
.map(
entry -> "-D"
+ entry.getKey()
+ "="
+ (entry.getValue() instanceof Supplier ? ((Supplier) entry.getValue()).get() : entry.getValue())
)
.collect(Collectors.toList());
}

// Track system property keys as an input so our build cache key will change if we add properties but values are still ignored
@Input
public Iterable<String> getPropertyNames() {
return systemProperties.keySet();
}
}
2 changes: 1 addition & 1 deletion gradle.properties.tmpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
elasticsearchVersion = 7.12.1
elasticsearchVersion = 7.17.1

// systemProp.http.proxyHost=xxxxxxxxxx.xxxx.xxx
// systemProp.http.proxyPort=3128
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit a419f44

Please sign in to comment.