Eliminate Gradle task input warnings (#47538)
(cherry picked from commit e86d40ff4576fb20c64fe88f01f13e201f3b948f)
This commit is contained in:
parent
35ca3d68d7
commit
d966e5a9b9
|
@ -20,20 +20,16 @@
|
||||||
package org.elasticsearch.gradle
|
package org.elasticsearch.gradle
|
||||||
|
|
||||||
import org.elasticsearch.gradle.precommit.DependencyLicensesTask
|
import org.elasticsearch.gradle.precommit.DependencyLicensesTask
|
||||||
import org.gradle.api.DefaultTask
|
|
||||||
import org.gradle.api.artifacts.Configuration
|
import org.gradle.api.artifacts.Configuration
|
||||||
import org.gradle.api.artifacts.Dependency
|
import org.gradle.api.artifacts.Dependency
|
||||||
import org.gradle.api.artifacts.DependencyResolutionListener
|
|
||||||
import org.gradle.api.artifacts.DependencySet
|
import org.gradle.api.artifacts.DependencySet
|
||||||
import org.gradle.api.internal.ConventionTask
|
import org.gradle.api.internal.ConventionTask
|
||||||
import org.gradle.api.tasks.Input
|
import org.gradle.api.tasks.Input
|
||||||
import org.gradle.api.tasks.InputDirectory
|
import org.gradle.api.tasks.InputDirectory
|
||||||
|
import org.gradle.api.tasks.InputFiles
|
||||||
import org.gradle.api.tasks.OutputFile
|
import org.gradle.api.tasks.OutputFile
|
||||||
import org.gradle.api.tasks.TaskAction
|
import org.gradle.api.tasks.TaskAction
|
||||||
|
|
||||||
import java.util.regex.Matcher
|
|
||||||
import java.util.regex.Pattern
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A task to gather information about the dependencies and export them into a csv file.
|
* A task to gather information about the dependencies and export them into a csv file.
|
||||||
*
|
*
|
||||||
|
@ -46,31 +42,31 @@ import java.util.regex.Pattern
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DependenciesInfoTask extends ConventionTask {
|
class DependenciesInfoTask extends ConventionTask {
|
||||||
|
|
||||||
/** Dependencies to gather information from. */
|
/** Dependencies to gather information from. */
|
||||||
@Input
|
@InputFiles
|
||||||
public Configuration runtimeConfiguration
|
Configuration runtimeConfiguration
|
||||||
|
|
||||||
/** We subtract compile-only dependencies. */
|
/** We subtract compile-only dependencies. */
|
||||||
@Input
|
@InputFiles
|
||||||
public Configuration compileOnlyConfiguration
|
Configuration compileOnlyConfiguration
|
||||||
|
|
||||||
private LinkedHashMap<String, String> mappings
|
|
||||||
|
|
||||||
/** Directory to read license files */
|
/** Directory to read license files */
|
||||||
@InputDirectory
|
@InputDirectory
|
||||||
public File licensesDir = new File(project.projectDir, 'licenses')
|
File licensesDir = new File(project.projectDir, 'licenses')
|
||||||
|
|
||||||
@OutputFile
|
@OutputFile
|
||||||
File outputFile = new File(project.buildDir, "reports/dependencies/dependencies.csv")
|
File outputFile = new File(project.buildDir, "reports/dependencies/dependencies.csv")
|
||||||
|
|
||||||
public DependenciesInfoTask() {
|
private LinkedHashMap<String, String> mappings
|
||||||
|
|
||||||
|
DependenciesInfoTask() {
|
||||||
description = 'Create a CSV file with dependencies information.'
|
description = 'Create a CSV file with dependencies information.'
|
||||||
}
|
}
|
||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
public void generateDependenciesInfo() {
|
void generateDependenciesInfo() {
|
||||||
|
|
||||||
final DependencySet runtimeDependencies = runtimeConfiguration.getAllDependencies()
|
final DependencySet runtimeDependencies = runtimeConfiguration.getAllDependencies()
|
||||||
// we have to resolve the transitive dependencies and create a group:artifactId:version map
|
// we have to resolve the transitive dependencies and create a group:artifactId:version map
|
||||||
|
|
|
@ -31,7 +31,7 @@ import java.nio.file.Path
|
||||||
/**
|
/**
|
||||||
* Generates REST tests for each snippet marked // TEST.
|
* Generates REST tests for each snippet marked // TEST.
|
||||||
*/
|
*/
|
||||||
public class RestTestsFromSnippetsTask extends SnippetsTask {
|
class RestTestsFromSnippetsTask extends SnippetsTask {
|
||||||
/**
|
/**
|
||||||
* These languages aren't supported by the syntax highlighter so we
|
* These languages aren't supported by the syntax highlighter so we
|
||||||
* shouldn't use them.
|
* shouldn't use them.
|
||||||
|
@ -58,7 +58,7 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
|
||||||
@OutputDirectory
|
@OutputDirectory
|
||||||
File testRoot = project.file('build/rest')
|
File testRoot = project.file('build/rest')
|
||||||
|
|
||||||
public RestTestsFromSnippetsTask() {
|
RestTestsFromSnippetsTask() {
|
||||||
project.afterEvaluate {
|
project.afterEvaluate {
|
||||||
// Wait to set this so testRoot can be customized
|
// Wait to set this so testRoot can be customized
|
||||||
project.sourceSets.test.output.dir(testRoot, builtBy: this)
|
project.sourceSets.test.output.dir(testRoot, builtBy: this)
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.gradle.api.InvalidUserDataException
|
||||||
import org.gradle.api.file.ConfigurableFileTree
|
import org.gradle.api.file.ConfigurableFileTree
|
||||||
import org.gradle.api.tasks.Input
|
import org.gradle.api.tasks.Input
|
||||||
import org.gradle.api.tasks.InputFiles
|
import org.gradle.api.tasks.InputFiles
|
||||||
|
import org.gradle.api.tasks.Internal
|
||||||
import org.gradle.api.tasks.TaskAction
|
import org.gradle.api.tasks.TaskAction
|
||||||
|
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
|
@ -36,7 +37,7 @@ import java.util.regex.Matcher
|
||||||
/**
|
/**
|
||||||
* A task which will run a closure on each snippet in the documentation.
|
* A task which will run a closure on each snippet in the documentation.
|
||||||
*/
|
*/
|
||||||
public class SnippetsTask extends DefaultTask {
|
class SnippetsTask extends DefaultTask {
|
||||||
private static final String SCHAR = /(?:\\\/|[^\/])/
|
private static final String SCHAR = /(?:\\\/|[^\/])/
|
||||||
private static final String SUBSTITUTION = /s\/($SCHAR+)\/($SCHAR*)\//
|
private static final String SUBSTITUTION = /s\/($SCHAR+)\/($SCHAR*)\//
|
||||||
private static final String CATCH = /catch:\s*((?:\/[^\/]+\/)|[^ \]]+)/
|
private static final String CATCH = /catch:\s*((?:\/[^\/]+\/)|[^ \]]+)/
|
||||||
|
@ -51,6 +52,7 @@ public class SnippetsTask extends DefaultTask {
|
||||||
* Action to take on each snippet. Called with a single parameter, an
|
* Action to take on each snippet. Called with a single parameter, an
|
||||||
* instance of Snippet.
|
* instance of Snippet.
|
||||||
*/
|
*/
|
||||||
|
@Internal
|
||||||
Closure perSnippet
|
Closure perSnippet
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,7 +75,7 @@ public class SnippetsTask extends DefaultTask {
|
||||||
Map<String, String> defaultSubstitutions = [:]
|
Map<String, String> defaultSubstitutions = [:]
|
||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
public void executeTask() {
|
void executeTask() {
|
||||||
/*
|
/*
|
||||||
* Walks each line of each file, building snippets as it encounters
|
* Walks each line of each file, building snippets as it encounters
|
||||||
* the lines that make up the snippet.
|
* the lines that make up the snippet.
|
||||||
|
|
|
@ -26,20 +26,20 @@ import org.gradle.api.GradleException
|
||||||
import org.gradle.api.Task
|
import org.gradle.api.Task
|
||||||
import org.gradle.api.tasks.Exec
|
import org.gradle.api.tasks.Exec
|
||||||
import org.gradle.api.tasks.Input
|
import org.gradle.api.tasks.Input
|
||||||
|
import org.gradle.api.tasks.Internal
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A fixture for integration tests which runs in a separate process launched by Ant.
|
* A fixture for integration tests which runs in a separate process launched by Ant.
|
||||||
*/
|
*/
|
||||||
public class AntFixture extends AntTask implements Fixture {
|
class AntFixture extends AntTask implements Fixture {
|
||||||
|
|
||||||
/** The path to the executable that starts the fixture. */
|
/** The path to the executable that starts the fixture. */
|
||||||
@Input
|
@Internal
|
||||||
String executable
|
String executable
|
||||||
|
|
||||||
private final List<Object> arguments = new ArrayList<>()
|
private final List<Object> arguments = new ArrayList<>()
|
||||||
|
|
||||||
@Input
|
void args(Object... args) {
|
||||||
public void args(Object... args) {
|
|
||||||
arguments.addAll(args)
|
arguments.addAll(args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,16 +49,15 @@ public class AntFixture extends AntTask implements Fixture {
|
||||||
*/
|
*/
|
||||||
private final Map<String, Object> environment = new HashMap<>()
|
private final Map<String, Object> environment = new HashMap<>()
|
||||||
|
|
||||||
@Input
|
void env(String key, Object value) {
|
||||||
public void env(String key, Object value) {
|
|
||||||
environment.put(key, value)
|
environment.put(key, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A flag to indicate whether the command should be executed from a shell. */
|
/** A flag to indicate whether the command should be executed from a shell. */
|
||||||
@Input
|
@Internal
|
||||||
boolean useShell = false
|
boolean useShell = false
|
||||||
|
|
||||||
@Input
|
@Internal
|
||||||
int maxWaitInSeconds = 30
|
int maxWaitInSeconds = 30
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -72,6 +71,7 @@ public class AntFixture extends AntTask implements Fixture {
|
||||||
* as well as a groovy AntBuilder, to enable running ant condition checks. The default wait
|
* as well as a groovy AntBuilder, to enable running ant condition checks. The default wait
|
||||||
* condition is for http on the http port.
|
* condition is for http on the http port.
|
||||||
*/
|
*/
|
||||||
|
@Internal
|
||||||
Closure waitCondition = { AntFixture fixture, AntBuilder ant ->
|
Closure waitCondition = { AntFixture fixture, AntBuilder ant ->
|
||||||
File tmpFile = new File(fixture.cwd, 'wait.success')
|
File tmpFile = new File(fixture.cwd, 'wait.success')
|
||||||
ant.get(src: "http://${fixture.addressAndPort}",
|
ant.get(src: "http://${fixture.addressAndPort}",
|
||||||
|
@ -83,13 +83,14 @@ public class AntFixture extends AntTask implements Fixture {
|
||||||
|
|
||||||
private final Task stopTask
|
private final Task stopTask
|
||||||
|
|
||||||
public AntFixture() {
|
AntFixture() {
|
||||||
stopTask = createStopTask()
|
stopTask = createStopTask()
|
||||||
finalizedBy(stopTask)
|
finalizedBy(stopTask)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Task getStopTask() {
|
@Internal
|
||||||
|
Task getStopTask() {
|
||||||
return stopTask
|
return stopTask
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,6 +169,7 @@ public class AntFixture extends AntTask implements Fixture {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a debug string used to log information about how the fixture was run. */
|
/** Returns a debug string used to log information about how the fixture was run. */
|
||||||
|
@Internal
|
||||||
protected String getCommandString() {
|
protected String getCommandString() {
|
||||||
String commandString = "\n${name} configuration:\n"
|
String commandString = "\n${name} configuration:\n"
|
||||||
commandString += "-----------------------------------------\n"
|
commandString += "-----------------------------------------\n"
|
||||||
|
@ -247,46 +249,55 @@ public class AntFixture extends AntTask implements Fixture {
|
||||||
* A path relative to the build dir that all configuration and runtime files
|
* A path relative to the build dir that all configuration and runtime files
|
||||||
* will live in for this fixture
|
* will live in for this fixture
|
||||||
*/
|
*/
|
||||||
|
@Internal
|
||||||
protected File getBaseDir() {
|
protected File getBaseDir() {
|
||||||
return new File(project.buildDir, "fixtures/${name}")
|
return new File(project.buildDir, "fixtures/${name}")
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the working directory for the process. Defaults to "cwd" inside baseDir. */
|
/** Returns the working directory for the process. Defaults to "cwd" inside baseDir. */
|
||||||
|
@Internal
|
||||||
protected File getCwd() {
|
protected File getCwd() {
|
||||||
return new File(baseDir, 'cwd')
|
return new File(baseDir, 'cwd')
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the file the process writes its pid to. Defaults to "pid" inside baseDir. */
|
/** Returns the file the process writes its pid to. Defaults to "pid" inside baseDir. */
|
||||||
|
@Internal
|
||||||
protected File getPidFile() {
|
protected File getPidFile() {
|
||||||
return new File(baseDir, 'pid')
|
return new File(baseDir, 'pid')
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Reads the pid file and returns the process' pid */
|
/** Reads the pid file and returns the process' pid */
|
||||||
public int getPid() {
|
@Internal
|
||||||
|
int getPid() {
|
||||||
return Integer.parseInt(pidFile.getText('UTF-8').trim())
|
return Integer.parseInt(pidFile.getText('UTF-8').trim())
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the file the process writes its bound ports to. Defaults to "ports" inside baseDir. */
|
/** Returns the file the process writes its bound ports to. Defaults to "ports" inside baseDir. */
|
||||||
|
@Internal
|
||||||
protected File getPortsFile() {
|
protected File getPortsFile() {
|
||||||
return new File(baseDir, 'ports')
|
return new File(baseDir, 'ports')
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns an address and port suitable for a uri to connect to this node over http */
|
/** Returns an address and port suitable for a uri to connect to this node over http */
|
||||||
public String getAddressAndPort() {
|
@Internal
|
||||||
|
String getAddressAndPort() {
|
||||||
return portsFile.readLines("UTF-8").get(0)
|
return portsFile.readLines("UTF-8").get(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a file that wraps around the actual command when {@code spawn == true}. */
|
/** Returns a file that wraps around the actual command when {@code spawn == true}. */
|
||||||
|
@Internal
|
||||||
protected File getWrapperScript() {
|
protected File getWrapperScript() {
|
||||||
return new File(cwd, Os.isFamily(Os.FAMILY_WINDOWS) ? 'run.bat' : 'run')
|
return new File(cwd, Os.isFamily(Os.FAMILY_WINDOWS) ? 'run.bat' : 'run')
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a file that the wrapper script writes when the command failed. */
|
/** Returns a file that the wrapper script writes when the command failed. */
|
||||||
|
@Internal
|
||||||
protected File getFailureMarker() {
|
protected File getFailureMarker() {
|
||||||
return new File(cwd, 'run.failed')
|
return new File(cwd, 'run.failed')
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a file that the wrapper script writes when the command failed. */
|
/** Returns a file that the wrapper script writes when the command failed. */
|
||||||
|
@Internal
|
||||||
protected File getRunLog() {
|
protected File getRunLog() {
|
||||||
return new File(cwd, 'run.log')
|
return new File(cwd, 'run.log')
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,14 +2,16 @@ package org.elasticsearch.gradle.test
|
||||||
|
|
||||||
import org.gradle.api.DefaultTask
|
import org.gradle.api.DefaultTask
|
||||||
import org.gradle.api.Task
|
import org.gradle.api.Task
|
||||||
|
import org.gradle.api.tasks.Internal
|
||||||
import org.gradle.api.tasks.options.Option
|
import org.gradle.api.tasks.options.Option
|
||||||
import org.gradle.util.ConfigureUtil
|
import org.gradle.util.ConfigureUtil
|
||||||
|
|
||||||
public class RunTask extends DefaultTask {
|
class RunTask extends DefaultTask {
|
||||||
|
|
||||||
|
@Internal
|
||||||
ClusterConfiguration clusterConfig
|
ClusterConfiguration clusterConfig
|
||||||
|
|
||||||
public RunTask() {
|
RunTask() {
|
||||||
description = "Runs elasticsearch with '${project.path}'"
|
description = "Runs elasticsearch with '${project.path}'"
|
||||||
group = 'Verification'
|
group = 'Verification'
|
||||||
clusterConfig = new ClusterConfiguration(project)
|
clusterConfig = new ClusterConfiguration(project)
|
||||||
|
@ -26,13 +28,13 @@ public class RunTask extends DefaultTask {
|
||||||
option = "debug-jvm",
|
option = "debug-jvm",
|
||||||
description = "Enable debugging configuration, to allow attaching a debugger to elasticsearch."
|
description = "Enable debugging configuration, to allow attaching a debugger to elasticsearch."
|
||||||
)
|
)
|
||||||
public void setDebug(boolean enabled) {
|
void setDebug(boolean enabled) {
|
||||||
clusterConfig.debug = enabled;
|
clusterConfig.debug = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Configure the cluster that will be run. */
|
/** Configure the cluster that will be run. */
|
||||||
@Override
|
@Override
|
||||||
public Task configure(Closure closure) {
|
Task configure(Closure closure) {
|
||||||
ConfigureUtil.configure(closure, clusterConfig)
|
ConfigureUtil.configure(closure, clusterConfig)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ public abstract class AbstractLazyPropertyCollection {
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract List<? extends Object> getNormalizedCollection();
|
public abstract List<? extends Object> getNormalizedCollection();
|
||||||
|
|
||||||
void assertNotNull(Object value, String description) {
|
void assertNotNull(Object value, String description) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
|
|
|
@ -24,6 +24,7 @@ import javax.inject.Inject;
|
||||||
|
|
||||||
import org.gradle.api.DefaultTask;
|
import org.gradle.api.DefaultTask;
|
||||||
import org.gradle.api.tasks.Input;
|
import org.gradle.api.tasks.Input;
|
||||||
|
import org.gradle.api.tasks.Internal;
|
||||||
import org.gradle.api.tasks.TaskAction;
|
import org.gradle.api.tasks.TaskAction;
|
||||||
import org.gradle.internal.file.Chmod;
|
import org.gradle.internal.file.Chmod;
|
||||||
|
|
||||||
|
@ -49,11 +50,16 @@ public class EmptyDirTask extends DefaultTask {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Input
|
@Internal
|
||||||
public File getDir() {
|
public File getDir() {
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Input
|
||||||
|
public String getDirPath() {
|
||||||
|
return dir.getPath();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dir The directory to create
|
* @param dir The directory to create
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -26,7 +26,6 @@ import org.gradle.api.logging.Logging;
|
||||||
import org.gradle.api.tasks.Classpath;
|
import org.gradle.api.tasks.Classpath;
|
||||||
import org.gradle.api.tasks.Input;
|
import org.gradle.api.tasks.Input;
|
||||||
import org.gradle.api.tasks.OutputDirectory;
|
import org.gradle.api.tasks.OutputDirectory;
|
||||||
import org.gradle.api.tasks.SkipWhenEmpty;
|
|
||||||
import org.gradle.api.tasks.StopExecutionException;
|
import org.gradle.api.tasks.StopExecutionException;
|
||||||
import org.gradle.api.tasks.TaskAction;
|
import org.gradle.api.tasks.TaskAction;
|
||||||
|
|
||||||
|
@ -66,7 +65,6 @@ public class ExportElasticsearchBuildResourcesTask extends DefaultTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Input
|
@Input
|
||||||
@SkipWhenEmpty
|
|
||||||
public Set<String> getResources() {
|
public Set<String> getResources() {
|
||||||
return Collections.unmodifiableSet(resources);
|
return Collections.unmodifiableSet(resources);
|
||||||
}
|
}
|
||||||
|
@ -78,8 +76,8 @@ public class ExportElasticsearchBuildResourcesTask extends DefaultTask {
|
||||||
return System.getProperty("java.class.path");
|
return System.getProperty("java.class.path");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOutputDir(DirectoryProperty outputDir) {
|
public void setOutputDir(File outputDir) {
|
||||||
this.outputDir = outputDir;
|
this.outputDir.set(outputDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
public File copy(String resource) {
|
public File copy(String resource) {
|
||||||
|
@ -95,6 +93,7 @@ public class ExportElasticsearchBuildResourcesTask extends DefaultTask {
|
||||||
@TaskAction
|
@TaskAction
|
||||||
public void doExport() {
|
public void doExport() {
|
||||||
if (resources.isEmpty()) {
|
if (resources.isEmpty()) {
|
||||||
|
setDidWork(false);
|
||||||
throw new StopExecutionException();
|
throw new StopExecutionException();
|
||||||
}
|
}
|
||||||
resources.stream().parallel()
|
resources.stream().parallel()
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package org.elasticsearch.gradle;
|
package org.elasticsearch.gradle;
|
||||||
|
|
||||||
import org.gradle.api.tasks.Input;
|
import org.gradle.api.tasks.Input;
|
||||||
import org.gradle.api.tasks.Nested;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -171,8 +170,7 @@ public class LazyPropertyList<T> extends AbstractLazyPropertyCollection implemen
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nested
|
public List<? extends Object> getNormalizedCollection() {
|
||||||
List<? extends Object> getNormalizedCollection() {
|
|
||||||
return delegate.stream()
|
return delegate.stream()
|
||||||
.peek(this::validate)
|
.peek(this::validate)
|
||||||
.filter(entry -> entry.getNormalization() != PropertyNormalization.IGNORE_VALUE)
|
.filter(entry -> entry.getNormalization() != PropertyNormalization.IGNORE_VALUE)
|
||||||
|
|
|
@ -2,7 +2,6 @@ package org.elasticsearch.gradle;
|
||||||
|
|
||||||
import org.gradle.api.Named;
|
import org.gradle.api.Named;
|
||||||
import org.gradle.api.tasks.Input;
|
import org.gradle.api.tasks.Input;
|
||||||
import org.gradle.api.tasks.Nested;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
@ -117,8 +116,7 @@ public class LazyPropertyMap<K, V> extends AbstractLazyPropertyCollection implem
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nested
|
public List<? extends Object> getNormalizedCollection() {
|
||||||
List<? extends Object> getNormalizedCollection() {
|
|
||||||
return delegate.values().stream()
|
return delegate.values().stream()
|
||||||
.peek(this::validate)
|
.peek(this::validate)
|
||||||
.filter(entry -> entry.getNormalization() != PropertyNormalization.IGNORE_VALUE)
|
.filter(entry -> entry.getNormalization() != PropertyNormalization.IGNORE_VALUE)
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.gradle.api.logging.Logging;
|
||||||
import org.gradle.api.tasks.Input;
|
import org.gradle.api.tasks.Input;
|
||||||
import org.gradle.api.tasks.InputDirectory;
|
import org.gradle.api.tasks.InputDirectory;
|
||||||
import org.gradle.api.tasks.InputFiles;
|
import org.gradle.api.tasks.InputFiles;
|
||||||
|
import org.gradle.api.tasks.Internal;
|
||||||
import org.gradle.api.tasks.Optional;
|
import org.gradle.api.tasks.Optional;
|
||||||
import org.gradle.api.tasks.TaskAction;
|
import org.gradle.api.tasks.TaskAction;
|
||||||
|
|
||||||
|
@ -306,6 +307,7 @@ public class DependencyLicensesTask extends DefaultTask {
|
||||||
return new File(licensesDir, jarName + SHA_EXTENSION);
|
return new File(licensesDir, jarName + SHA_EXTENSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Internal
|
||||||
Set<File> getShaFiles() {
|
Set<File> getShaFiles() {
|
||||||
File[] array = licensesDir.listFiles();
|
File[] array = licensesDir.listFiles();
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class ForbiddenPatternsTask extends DefaultTask {
|
||||||
|
|
||||||
@InputFiles
|
@InputFiles
|
||||||
@SkipWhenEmpty
|
@SkipWhenEmpty
|
||||||
public FileCollection files() {
|
public FileCollection getFiles() {
|
||||||
return getProject().getConvention().getPlugin(JavaPluginConvention.class).getSourceSets()
|
return getProject().getConvention().getPlugin(JavaPluginConvention.class).getSourceSets()
|
||||||
.stream()
|
.stream()
|
||||||
.map(sourceSet -> sourceSet.getAllSource().matching(filesFilter))
|
.map(sourceSet -> sourceSet.getAllSource().matching(filesFilter))
|
||||||
|
@ -99,7 +99,7 @@ public class ForbiddenPatternsTask extends DefaultTask {
|
||||||
public void checkInvalidPatterns() throws IOException {
|
public void checkInvalidPatterns() throws IOException {
|
||||||
Pattern allPatterns = Pattern.compile("(" + String.join(")|(", getPatterns().values()) + ")");
|
Pattern allPatterns = Pattern.compile("(" + String.join(")|(", getPatterns().values()) + ")");
|
||||||
List<String> failures = new ArrayList<>();
|
List<String> failures = new ArrayList<>();
|
||||||
for (File f : files()) {
|
for (File f : getFiles()) {
|
||||||
List<String> lines;
|
List<String> lines;
|
||||||
try(Stream<String> stream = Files.lines(f.toPath(), StandardCharsets.UTF_8)) {
|
try(Stream<String> stream = Files.lines(f.toPath(), StandardCharsets.UTF_8)) {
|
||||||
lines = stream.collect(Collectors.toList());
|
lines = stream.collect(Collectors.toList());
|
||||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.gradle.precommit;
|
||||||
import org.gradle.api.DefaultTask;
|
import org.gradle.api.DefaultTask;
|
||||||
import org.gradle.api.logging.Logger;
|
import org.gradle.api.logging.Logger;
|
||||||
import org.gradle.api.logging.Logging;
|
import org.gradle.api.logging.Logging;
|
||||||
|
import org.gradle.api.tasks.Internal;
|
||||||
import org.gradle.api.tasks.TaskAction;
|
import org.gradle.api.tasks.TaskAction;
|
||||||
import org.gradle.api.tasks.TaskProvider;
|
import org.gradle.api.tasks.TaskProvider;
|
||||||
|
|
||||||
|
@ -77,6 +78,7 @@ public class UpdateShasTask extends DefaultTask {
|
||||||
Files.write(shaFile.toPath(), sha.getBytes(StandardCharsets.UTF_8), StandardOpenOption.CREATE);
|
Files.write(shaFile.toPath(), sha.getBytes(StandardCharsets.UTF_8), StandardOpenOption.CREATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Internal
|
||||||
public DependencyLicensesTask getParentTask() {
|
public DependencyLicensesTask getParentTask() {
|
||||||
return parentTask.get();
|
return parentTask.get();
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,8 @@ import org.gradle.api.GradleException;
|
||||||
import org.gradle.api.file.DirectoryProperty;
|
import org.gradle.api.file.DirectoryProperty;
|
||||||
import org.gradle.api.file.RegularFileProperty;
|
import org.gradle.api.file.RegularFileProperty;
|
||||||
import org.gradle.api.model.ObjectFactory;
|
import org.gradle.api.model.ObjectFactory;
|
||||||
import org.gradle.api.tasks.Input;
|
|
||||||
import org.gradle.api.tasks.InputFile;
|
import org.gradle.api.tasks.InputFile;
|
||||||
|
import org.gradle.api.tasks.Internal;
|
||||||
import org.gradle.api.tasks.OutputDirectory;
|
import org.gradle.api.tasks.OutputDirectory;
|
||||||
import org.gradle.api.tasks.TaskAction;
|
import org.gradle.api.tasks.TaskAction;
|
||||||
|
|
||||||
|
@ -69,13 +69,17 @@ public class SymbolicLinkPreservingUntarTask extends DefaultTask {
|
||||||
|
|
||||||
private Function<String, Path> transform;
|
private Function<String, Path> transform;
|
||||||
|
|
||||||
|
@Internal
|
||||||
|
public Function<String, Path> getTransform() {
|
||||||
|
return transform;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A transform to apply to the tar entry, to derive the relative path from the entry name. If the return value is null, the entry is
|
* A transform to apply to the tar entry, to derive the relative path from the entry name. If the return value is null, the entry is
|
||||||
* dropped from the exploded tar archive.
|
* dropped from the exploded tar archive.
|
||||||
*
|
*
|
||||||
* @param transform the transform
|
* @param transform the transform
|
||||||
*/
|
*/
|
||||||
@Input
|
|
||||||
public void setTransform(Function<String, Path> transform) {
|
public void setTransform(Function<String, Path> transform) {
|
||||||
this.transform = transform;
|
this.transform = transform;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.gradle.api.NamedDomainObjectContainer;
|
||||||
import org.gradle.api.Project;
|
import org.gradle.api.Project;
|
||||||
import org.gradle.api.logging.Logger;
|
import org.gradle.api.logging.Logger;
|
||||||
import org.gradle.api.logging.Logging;
|
import org.gradle.api.logging.Logging;
|
||||||
|
import org.gradle.api.tasks.Internal;
|
||||||
import org.gradle.api.tasks.Nested;
|
import org.gradle.api.tasks.Nested;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -107,14 +108,17 @@ public class ElasticsearchCluster implements TestClusterConfiguration, Named {
|
||||||
return nodes.getAt(clusterName + "-0");
|
return nodes.getAt(clusterName + "-0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Internal
|
||||||
public int getNumberOfNodes() {
|
public int getNumberOfNodes() {
|
||||||
return nodes.size();
|
return nodes.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Internal
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return clusterName;
|
return clusterName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Internal
|
||||||
public String getPath() {
|
public String getPath() {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
@ -383,24 +387,28 @@ public class ElasticsearchCluster implements TestClusterConfiguration, Named {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Internal
|
||||||
public String getHttpSocketURI() {
|
public String getHttpSocketURI() {
|
||||||
waitForAllConditions();
|
waitForAllConditions();
|
||||||
return getFirstNode().getHttpSocketURI();
|
return getFirstNode().getHttpSocketURI();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Internal
|
||||||
public String getTransportPortURI() {
|
public String getTransportPortURI() {
|
||||||
waitForAllConditions();
|
waitForAllConditions();
|
||||||
return getFirstNode().getTransportPortURI();
|
return getFirstNode().getTransportPortURI();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Internal
|
||||||
public List<String> getAllHttpSocketURI() {
|
public List<String> getAllHttpSocketURI() {
|
||||||
waitForAllConditions();
|
waitForAllConditions();
|
||||||
return nodes.stream().flatMap(each -> each.getAllHttpSocketURI().stream()).collect(Collectors.toList());
|
return nodes.stream().flatMap(each -> each.getAllHttpSocketURI().stream()).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Internal
|
||||||
public List<String> getAllTransportPortURI() {
|
public List<String> getAllTransportPortURI() {
|
||||||
waitForAllConditions();
|
waitForAllConditions();
|
||||||
return nodes.stream().flatMap(each -> each.getAllTransportPortURI().stream()).collect(Collectors.toList());
|
return nodes.stream().flatMap(each -> each.getAllTransportPortURI().stream()).collect(Collectors.toList());
|
||||||
|
@ -424,6 +432,7 @@ public class ElasticsearchCluster implements TestClusterConfiguration, Named {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Internal
|
||||||
public boolean isProcessAlive() {
|
public boolean isProcessAlive() {
|
||||||
return nodes.stream().noneMatch(node -> node.isProcessAlive() == false);
|
return nodes.stream().noneMatch(node -> node.isProcessAlive() == false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ import org.gradle.api.tasks.InputFile;
|
||||||
import org.gradle.api.tasks.InputFiles;
|
import org.gradle.api.tasks.InputFiles;
|
||||||
import org.gradle.api.tasks.Internal;
|
import org.gradle.api.tasks.Internal;
|
||||||
import org.gradle.api.tasks.Nested;
|
import org.gradle.api.tasks.Nested;
|
||||||
|
import org.gradle.api.tasks.Optional;
|
||||||
import org.gradle.api.tasks.PathSensitive;
|
import org.gradle.api.tasks.PathSensitive;
|
||||||
import org.gradle.api.tasks.PathSensitivity;
|
import org.gradle.api.tasks.PathSensitivity;
|
||||||
import org.gradle.api.tasks.util.PatternFilterable;
|
import org.gradle.api.tasks.util.PatternFilterable;
|
||||||
|
@ -171,6 +172,8 @@ public class ElasticsearchNode implements TestClusterConfiguration {
|
||||||
setVersion(VersionProperties.getElasticsearch());
|
setVersion(VersionProperties.getElasticsearch());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Input
|
||||||
|
@Optional
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return nameCustomization.apply(name);
|
return nameCustomization.apply(name);
|
||||||
}
|
}
|
||||||
|
@ -346,6 +349,7 @@ public class ElasticsearchNode implements TestClusterConfiguration {
|
||||||
jvmArgs.addAll(Arrays.asList(values));
|
jvmArgs.addAll(Arrays.asList(values));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Internal
|
||||||
public Path getConfigDir() {
|
public Path getConfigDir() {
|
||||||
return configFile.getParent();
|
return configFile.getParent();
|
||||||
}
|
}
|
||||||
|
@ -368,6 +372,7 @@ public class ElasticsearchNode implements TestClusterConfiguration {
|
||||||
this.javaHome = javaHome;
|
this.javaHome = javaHome;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Internal
|
||||||
public File getJavaHome() {
|
public File getJavaHome() {
|
||||||
return javaHome;
|
return javaHome;
|
||||||
}
|
}
|
||||||
|
@ -701,31 +706,37 @@ public class ElasticsearchNode implements TestClusterConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Internal
|
||||||
public String getHttpSocketURI() {
|
public String getHttpSocketURI() {
|
||||||
return getHttpPortInternal().get(0);
|
return getHttpPortInternal().get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Internal
|
||||||
public String getTransportPortURI() {
|
public String getTransportPortURI() {
|
||||||
return getTransportPortInternal().get(0);
|
return getTransportPortInternal().get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Internal
|
||||||
public List<String> getAllHttpSocketURI() {
|
public List<String> getAllHttpSocketURI() {
|
||||||
waitForAllConditions();
|
waitForAllConditions();
|
||||||
return getHttpPortInternal();
|
return getHttpPortInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Internal
|
||||||
public List<String> getAllTransportPortURI() {
|
public List<String> getAllTransportPortURI() {
|
||||||
waitForAllConditions();
|
waitForAllConditions();
|
||||||
return getTransportPortInternal();
|
return getTransportPortInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Internal
|
||||||
public File getServerLog() {
|
public File getServerLog() {
|
||||||
return confPathLogs.resolve(defaultConfig.get("cluster.name") + "_server.json").toFile();
|
return confPathLogs.resolve(defaultConfig.get("cluster.name") + "_server.json").toFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Internal
|
||||||
public File getAuditLog() {
|
public File getAuditLog() {
|
||||||
return confPathLogs.resolve(defaultConfig.get("cluster.name") + "_audit.json").toFile();
|
return confPathLogs.resolve(defaultConfig.get("cluster.name") + "_audit.json").toFile();
|
||||||
}
|
}
|
||||||
|
@ -1096,30 +1107,30 @@ public class ElasticsearchNode implements TestClusterConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Input
|
@Input
|
||||||
private Set<URI> getRemotePlugins() {
|
public Set<URI> getRemotePlugins() {
|
||||||
Set<URI> file = plugins.stream().filter(uri -> uri.getScheme().equalsIgnoreCase("file") == false).collect(Collectors.toSet());
|
Set<URI> file = plugins.stream().filter(uri -> uri.getScheme().equalsIgnoreCase("file") == false).collect(Collectors.toSet());
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Classpath
|
@Classpath
|
||||||
private List<File> getInstalledClasspath() {
|
public List<File> getInstalledClasspath() {
|
||||||
return getInstalledFileSet(filter -> filter.include("**/*.jar"));
|
return getInstalledFileSet(filter -> filter.include("**/*.jar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@InputFiles
|
@InputFiles
|
||||||
@PathSensitive(PathSensitivity.RELATIVE)
|
@PathSensitive(PathSensitivity.RELATIVE)
|
||||||
private List<File> getInstalledFiles() {
|
public List<File> getInstalledFiles() {
|
||||||
return getInstalledFileSet(filter -> filter.exclude("**/*.jar"));
|
return getInstalledFileSet(filter -> filter.exclude("**/*.jar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Classpath
|
@Classpath
|
||||||
private Set<File> getDistributionClasspath() {
|
public Set<File> getDistributionClasspath() {
|
||||||
return getDistributionFiles(filter -> filter.include("**/*.jar"));
|
return getDistributionFiles(filter -> filter.include("**/*.jar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@InputFiles
|
@InputFiles
|
||||||
@PathSensitive(PathSensitivity.RELATIVE)
|
@PathSensitive(PathSensitivity.RELATIVE)
|
||||||
private Set<File> getDistributionFiles() {
|
public Set<File> getDistributionFiles() {
|
||||||
return getDistributionFiles(filter -> filter.exclude("**/*.jar"));
|
return getDistributionFiles(filter -> filter.exclude("**/*.jar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1136,41 +1147,42 @@ public class ElasticsearchNode implements TestClusterConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
private Map<String, CharSequence> getKeystoreSettings() {
|
public List<?> getKeystoreSettings() {
|
||||||
return keystoreSettings;
|
return keystoreSettings.getNormalizedCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
private Map<String, File> getKeystoreFiles() {
|
public List<?> getKeystoreFiles() {
|
||||||
return keystoreFiles;
|
return keystoreFiles.getNormalizedCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
private Map<String, CharSequence> getSettings() {
|
public List<?> getSettings() {
|
||||||
return settings;
|
return settings.getNormalizedCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
private Map<String, CharSequence> getSystemProperties() {
|
public List<?> getSystemProperties() {
|
||||||
return systemProperties;
|
return systemProperties.getNormalizedCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
private Map<String, CharSequence> getEnvironment() {
|
public List<?> getEnvironment() {
|
||||||
return environment;
|
return environment.getNormalizedCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
private List<CharSequence> getJvmArgs() {
|
public List<?> getJvmArgs() {
|
||||||
return jvmArgs;
|
return jvmArgs.getNormalizedCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
private Map<String, File> getExtraConfigFiles() {
|
public List<?> getExtraConfigFiles() {
|
||||||
return extraConfigFiles;
|
return extraConfigFiles.getNormalizedCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Internal
|
||||||
public boolean isProcessAlive() {
|
public boolean isProcessAlive() {
|
||||||
requireNonNull(
|
requireNonNull(
|
||||||
esProcess,
|
esProcess,
|
||||||
|
@ -1236,6 +1248,7 @@ public class ElasticsearchNode implements TestClusterConfiguration {
|
||||||
return Files.exists(httpPortsFile) && Files.exists(transportPortFile);
|
return Files.exists(httpPortsFile) && Files.exists(transportPortFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Internal
|
||||||
public boolean isHttpSslEnabled() {
|
public boolean isHttpSslEnabled() {
|
||||||
return Boolean.valueOf(
|
return Boolean.valueOf(
|
||||||
settings.getOrDefault("xpack.security.http.ssl.enabled", "false").toString()
|
settings.getOrDefault("xpack.security.http.ssl.enabled", "false").toString()
|
||||||
|
|
Loading…
Reference in New Issue