-
Notifications
You must be signed in to change notification settings - Fork 24.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 6.x: (96 commits) Introduce global checkpoint listeners (#32696) Use JDK 10 for 6.4 BWC builds (#32866) Remove unused imports - follow up to removal of test in issue 32855 Removed flaky test. Looks like randomisation makes these assertions unreliable. This test is superfluous - it was added to address #32770 but it later turned out there was an existing test that just required a fix to provide the missing test coverage. [test] mute IndexShardTests.testDocStats Test: Fix forbidden uses in test framework (#32824) Security: remove password hash bootstrap check (#32440) Move validation to server for put user requests (#32471) [ML] Add high level REST client docs for ML put job endpoint (#32843) Painless: Change fqn_only to no_import (#32817) [test] mute testSearchWithSignificantTermsAgg Backport: CompletableContext class to avoid throwable (#32829) [TEST] Select free port for Minio (#32837) SCRIPTING: Support BucketAggScript return null (#32811) (#32833) HLRC: Add Delete License API (#32586) Aggregations/HL Rest client fix: missing scores (#32774) HLRC: migration get assistance API (#32744) Fix NOOP bulk updates (#32819) Increase logging testRetentionPolicyChangeDuringRecovery AwaitsFix case-functions.sql-spec ...
- Loading branch information
Showing
503 changed files
with
14,196 additions
and
5,558 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
buildSrc/src/main/java/org/elasticsearch/gradle/ExportElasticsearchBuildResourcesTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.elasticsearch.gradle; | ||
|
||
import org.gradle.api.DefaultTask; | ||
import org.gradle.api.GradleException; | ||
import org.gradle.api.file.DirectoryProperty; | ||
import org.gradle.api.file.RegularFileProperty; | ||
import org.gradle.api.logging.Logger; | ||
import org.gradle.api.logging.Logging; | ||
import org.gradle.api.tasks.Classpath; | ||
import org.gradle.api.tasks.Input; | ||
import org.gradle.api.tasks.OutputDirectory; | ||
import org.gradle.api.tasks.SkipWhenEmpty; | ||
import org.gradle.api.tasks.StopExecutionException; | ||
import org.gradle.api.tasks.TaskAction; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.Collections; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
/** | ||
* Export Elasticsearch build resources to configurable paths | ||
* <p> | ||
* Wil overwrite existing files and create missing directories. | ||
* Useful for resources that that need to be passed to other processes trough the filesystem or otherwise can't be | ||
* consumed from the classpath. | ||
*/ | ||
public class ExportElasticsearchBuildResourcesTask extends DefaultTask { | ||
|
||
private final Logger logger = Logging.getLogger(ExportElasticsearchBuildResourcesTask.class); | ||
|
||
private final Set<String> resources = new HashSet<>(); | ||
|
||
private DirectoryProperty outputDir; | ||
|
||
public ExportElasticsearchBuildResourcesTask() { | ||
outputDir = getProject().getLayout().directoryProperty( | ||
getProject().getLayout().getBuildDirectory().dir("build-tools-exported") | ||
); | ||
} | ||
|
||
@OutputDirectory | ||
public DirectoryProperty getOutputDir() { | ||
return outputDir; | ||
} | ||
|
||
@Input | ||
@SkipWhenEmpty | ||
public Set<String> getResources() { | ||
return Collections.unmodifiableSet(resources); | ||
} | ||
|
||
@Classpath | ||
public String getResourcesClasspath() { | ||
// This will make sure the task is not considered up to date if the resources are changed. | ||
logger.info("Classpath: {}", System.getProperty("java.class.path")); | ||
return System.getProperty("java.class.path"); | ||
} | ||
|
||
public void setOutputDir(DirectoryProperty outputDir) { | ||
this.outputDir = outputDir; | ||
} | ||
|
||
public RegularFileProperty take(String resource) { | ||
if (getState().getExecuted() || getState().getExecuting()) { | ||
throw new GradleException("buildResources can't be configured after the task ran. " + | ||
"Make sure task is not used after configuration time" | ||
); | ||
} | ||
resources.add(resource); | ||
return getProject().getLayout().fileProperty(outputDir.file(resource)); | ||
} | ||
|
||
@TaskAction | ||
public void doExport() { | ||
if (resources.isEmpty()) { | ||
throw new StopExecutionException(); | ||
} | ||
resources.stream().parallel() | ||
.forEach(resourcePath -> { | ||
Path destination = outputDir.get().file(resourcePath).getAsFile().toPath(); | ||
try (InputStream is = getClass().getClassLoader().getResourceAsStream(resourcePath)) { | ||
if (is == null) { | ||
throw new GradleException("Can't export `" + resourcePath + "` from build-tools: not found"); | ||
} | ||
Files.copy(is, destination); | ||
} catch (IOException e) { | ||
throw new GradleException("Can't write resource `" + resourcePath + "` to " + destination); | ||
} | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.