mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-09 14:34:43 +00:00
[7.x] Introduce type-safe and consistent pattern for handling build globals (#48818)
This commit introduces a consistent, and type-safe manner for handling global build parameters through out our build logic. Primarily this replaces the existing usages of extra properties with static accessors. It also introduces and explicit API for initialization and mutation of any such parameters, as well as better error handling for uninitialized or eager access of parameter values. Closes #42042
This commit is contained in:
parent
700a316bb3
commit
6ab4645f4e
@ -1,3 +1,5 @@
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
|
||||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
@ -44,7 +46,7 @@ compileJava.options.compilerArgs << "-Xlint:-cast,-rawtypes,-unchecked,-processi
|
||||
// needs to be added separately otherwise Gradle will quote it and javac will fail
|
||||
compileJava.options.compilerArgs.addAll(["-processor", "org.openjdk.jmh.generators.BenchmarkProcessor"])
|
||||
|
||||
run.executable = new File(project.runtimeJavaHome, 'bin/java')
|
||||
run.executable = "${BuildParams.runtimeJavaHome}/bin/java"
|
||||
|
||||
// classes generated by JMH can use all sorts of forbidden APIs but we have no influence at all and cannot exclude these classes
|
||||
forbiddenApisMain.enabled = false
|
||||
|
@ -220,8 +220,8 @@ if (project != rootProject) {
|
||||
task integTest(type: Test) {
|
||||
inputs.dir(file("src/testKit")).withPropertyName("testkit dir").withPathSensitivity(PathSensitivity.RELATIVE)
|
||||
systemProperty 'test.version_under_test', version
|
||||
onlyIf { project.inFipsJvm == false }
|
||||
maxParallelForks = System.getProperty('tests.jvms', project.rootProject.ext.defaultParallel.toString()) as Integer
|
||||
onlyIf { org.elasticsearch.gradle.info.BuildParams.inFipsJvm == false }
|
||||
maxParallelForks = System.getProperty('tests.jvms', org.elasticsearch.gradle.info.BuildParams.defaultParallel.toString()) as Integer
|
||||
}
|
||||
check.dependsOn(integTest)
|
||||
|
||||
|
@ -25,6 +25,7 @@ import com.github.jengelman.gradle.plugins.shadow.ShadowJavaPlugin
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import groovy.transform.CompileStatic
|
||||
import org.apache.commons.io.IOUtils
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
import org.elasticsearch.gradle.info.GlobalBuildInfoPlugin
|
||||
import org.elasticsearch.gradle.info.GlobalInfoExtension
|
||||
import org.elasticsearch.gradle.info.JavaHome
|
||||
@ -140,7 +141,6 @@ class BuildPlugin implements Plugin<Project> {
|
||||
configurePrecommit(project)
|
||||
configureDependenciesInfo(project)
|
||||
|
||||
|
||||
configureFips140(project)
|
||||
}
|
||||
|
||||
@ -149,9 +149,8 @@ class BuildPlugin implements Plugin<Project> {
|
||||
GlobalInfoExtension globalInfo = project.rootProject.extensions.getByType(GlobalInfoExtension)
|
||||
// wait until global info is populated because we don't know if we are running in a fips jvm until execution time
|
||||
globalInfo.ready {
|
||||
ExtraPropertiesExtension ext = project.extensions.getByType(ExtraPropertiesExtension)
|
||||
// Common config when running with a FIPS-140 runtime JVM
|
||||
if (ext.has('inFipsJvm') && ext.get('inFipsJvm')) {
|
||||
if (BuildParams.inFipsJvm) {
|
||||
project.tasks.withType(Test).configureEach { Test task ->
|
||||
task.systemProperty 'javax.net.ssl.trustStorePassword', 'password'
|
||||
task.systemProperty 'javax.net.ssl.keyStorePassword', 'password'
|
||||
@ -295,8 +294,7 @@ class BuildPlugin implements Plugin<Project> {
|
||||
List<String> messages = []
|
||||
Map<Integer, List<Task>> requiredJavaVersions = (Map<Integer, List<Task>>) ext.get('requiredJavaVersions')
|
||||
for (Map.Entry<Integer, List<Task>> entry : requiredJavaVersions) {
|
||||
List<JavaHome> javaVersions = ext.get('javaVersions') as List<JavaHome>
|
||||
if (javaVersions.find { it.version == entry.key } != null) {
|
||||
if (BuildParams.javaVersions.find { it.version == entry.key } != null) {
|
||||
continue
|
||||
}
|
||||
List<String> tasks = entry.value.findAll { taskGraph.hasTask(it) }.collect { " ${it.path}".toString() }
|
||||
@ -311,8 +309,7 @@ class BuildPlugin implements Plugin<Project> {
|
||||
})
|
||||
} else if (ext.has('requiredJavaVersions') == false || ext.get('requiredJavaVersions') == null) {
|
||||
// check directly if the version is present since we are already executing
|
||||
List<JavaHome> javaVersions = ext.get('javaVersions') as List<JavaHome>
|
||||
if (javaVersions.find { it.version == version } == null) {
|
||||
if (BuildParams.javaVersions.find { it.version == version } == null) {
|
||||
throw new GradleException("JAVA${version}_HOME required to run task:\n${task}")
|
||||
}
|
||||
} else {
|
||||
@ -323,8 +320,7 @@ class BuildPlugin implements Plugin<Project> {
|
||||
/** A convenience method for getting java home for a version of java and requiring that version for the given task to execute */
|
||||
static String getJavaHome(final Task task, final int version) {
|
||||
requireJavaHome(task, version)
|
||||
List<JavaHome> javaVersions = task.project.property('javaVersions') as List<JavaHome>
|
||||
return javaVersions.find { it.version == version }.javaHome.absolutePath
|
||||
return BuildParams.javaVersions.find { it.version == version }.javaHome.absolutePath
|
||||
}
|
||||
|
||||
/**
|
||||
@ -488,7 +484,7 @@ class BuildPlugin implements Plugin<Project> {
|
||||
ExtraPropertiesExtension ext = project.extensions.getByType(ExtraPropertiesExtension)
|
||||
GlobalInfoExtension globalBuildInfo = project.rootProject.extensions.getByType(GlobalInfoExtension)
|
||||
globalBuildInfo.ready {
|
||||
if ((ext.get('compilerJavaVersion') as JavaVersion) < JavaVersion.VERSION_1_10) {
|
||||
if (BuildParams.compilerJavaVersion < JavaVersion.VERSION_1_10) {
|
||||
ext.set('compactProfile', 'compact3')
|
||||
} else {
|
||||
ext.set('compactProfile', 'full')
|
||||
@ -496,20 +492,18 @@ class BuildPlugin implements Plugin<Project> {
|
||||
}
|
||||
ext.set('compactProfile', 'full')
|
||||
|
||||
project.extensions.getByType(JavaPluginExtension).sourceCompatibility = ext.get('minimumRuntimeVersion') as JavaVersion
|
||||
project.extensions.getByType(JavaPluginExtension).targetCompatibility = ext.get('minimumRuntimeVersion') as JavaVersion
|
||||
project.extensions.getByType(JavaPluginExtension).sourceCompatibility = BuildParams.minimumRuntimeVersion
|
||||
project.extensions.getByType(JavaPluginExtension).targetCompatibility = BuildParams.minimumRuntimeVersion
|
||||
|
||||
project.afterEvaluate {
|
||||
File compilerJavaHome = ext.get('compilerJavaHome') as File
|
||||
|
||||
project.tasks.withType(JavaCompile).configureEach({ JavaCompile compileTask ->
|
||||
final JavaVersion targetCompatibilityVersion = JavaVersion.toVersion(compileTask.targetCompatibility)
|
||||
// we only fork if the Gradle JDK is not the same as the compiler JDK
|
||||
if (compilerJavaHome.canonicalPath == Jvm.current().javaHome.canonicalPath) {
|
||||
if (BuildParams.compilerJavaHome.canonicalPath == Jvm.current().javaHome.canonicalPath) {
|
||||
compileTask.options.fork = false
|
||||
} else {
|
||||
compileTask.options.fork = true
|
||||
compileTask.options.forkOptions.javaHome = compilerJavaHome
|
||||
compileTask.options.forkOptions.javaHome = BuildParams.compilerJavaHome
|
||||
}
|
||||
if (targetCompatibilityVersion == JavaVersion.VERSION_1_8) {
|
||||
globalBuildInfo.ready {
|
||||
@ -543,11 +537,11 @@ class BuildPlugin implements Plugin<Project> {
|
||||
// also apply release flag to groovy, which is used in build-tools
|
||||
project.tasks.withType(GroovyCompile).configureEach({ GroovyCompile compileTask ->
|
||||
// we only fork if the Gradle JDK is not the same as the compiler JDK
|
||||
if (compilerJavaHome.canonicalPath == Jvm.current().javaHome.canonicalPath) {
|
||||
if (BuildParams.compilerJavaHome.canonicalPath == Jvm.current().javaHome.canonicalPath) {
|
||||
compileTask.options.fork = false
|
||||
} else {
|
||||
compileTask.options.fork = true
|
||||
compileTask.options.forkOptions.javaHome = compilerJavaHome
|
||||
compileTask.options.forkOptions.javaHome = BuildParams.compilerJavaHome
|
||||
compileTask.options.compilerArgs << '--release' << JavaVersion.toVersion(compileTask.targetCompatibility).majorVersion
|
||||
}
|
||||
} as Action<GroovyCompile>)
|
||||
@ -566,11 +560,10 @@ class BuildPlugin implements Plugin<Project> {
|
||||
classes.add(javaCompile.destinationDir)
|
||||
}
|
||||
project.tasks.withType(Javadoc).configureEach { Javadoc javadoc ->
|
||||
File compilerJavaHome = project.extensions.getByType(ExtraPropertiesExtension).get('compilerJavaHome') as File
|
||||
// only explicitly set javadoc executable if compiler JDK is different from Gradle
|
||||
// this ensures better cacheability as setting ths input to an absolute path breaks portability
|
||||
if (Files.isSameFile(compilerJavaHome.toPath(), Jvm.current().getJavaHome().toPath()) == false) {
|
||||
javadoc.executable = new File(compilerJavaHome, 'bin/javadoc')
|
||||
if (Files.isSameFile(BuildParams.compilerJavaHome.toPath(), Jvm.current().getJavaHome().toPath()) == false) {
|
||||
javadoc.executable = new File(BuildParams.compilerJavaHome, 'bin/javadoc')
|
||||
}
|
||||
javadoc.classpath = javadoc.getClasspath().filter { f ->
|
||||
return classes.contains(f) == false
|
||||
@ -625,13 +618,13 @@ class BuildPlugin implements Plugin<Project> {
|
||||
jarTask.doFirst {
|
||||
// this doFirst is added before the info plugin, therefore it will run
|
||||
// after the doFirst added by the info plugin, and we can override attributes
|
||||
JavaVersion compilerJavaVersion = ext.get('compilerJavaVersion') as JavaVersion
|
||||
JavaVersion compilerJavaVersion = BuildParams.compilerJavaVersion
|
||||
jarTask.manifest.attributes(
|
||||
'Change': ext.get('gitRevision'),
|
||||
'Change': BuildParams.gitRevision,
|
||||
'X-Compile-Elasticsearch-Version': VersionProperties.elasticsearch,
|
||||
'X-Compile-Lucene-Version': VersionProperties.lucene,
|
||||
'X-Compile-Elasticsearch-Snapshot': VersionProperties.isElasticsearchSnapshot(),
|
||||
'Build-Date': ext.get('buildDate'),
|
||||
'Build-Date': BuildParams.buildDate,
|
||||
'Build-Java-Version': compilerJavaVersion)
|
||||
}
|
||||
}
|
||||
@ -718,19 +711,19 @@ class BuildPlugin implements Plugin<Project> {
|
||||
project.mkdir(heapdumpDir)
|
||||
project.mkdir(test.workingDir)
|
||||
|
||||
if (project.property('inFipsJvm')) {
|
||||
nonInputProperties.systemProperty('runtime.java', "${-> (ext.get('runtimeJavaVersion') as JavaVersion).getMajorVersion()}FIPS")
|
||||
if (BuildParams.inFipsJvm) {
|
||||
nonInputProperties.systemProperty('runtime.java', "${-> BuildParams.runtimeJavaVersion.majorVersion}FIPS")
|
||||
} else {
|
||||
nonInputProperties.systemProperty('runtime.java', "${-> (ext.get('runtimeJavaVersion') as JavaVersion).getMajorVersion()}")
|
||||
nonInputProperties.systemProperty('runtime.java', "${-> BuildParams.runtimeJavaVersion.majorVersion}")
|
||||
}
|
||||
|
||||
if ((ext.get('runtimeJavaVersion') as JavaVersion) >= JavaVersion.VERSION_1_9) {
|
||||
if (BuildParams.runtimeJavaVersion >= JavaVersion.VERSION_1_9) {
|
||||
test.jvmArgs '--illegal-access=warn'
|
||||
}
|
||||
//TODO remove once jvm.options are added to test system properties
|
||||
if ((ext.get('runtimeJavaVersion') as JavaVersion) == JavaVersion.VERSION_1_8) {
|
||||
if (BuildParams.runtimeJavaVersion == JavaVersion.VERSION_1_8) {
|
||||
test.systemProperty ('java.locale.providers','SPI,JRE')
|
||||
} else if ((ext.get('runtimeJavaVersion') as JavaVersion) >= JavaVersion.VERSION_1_9) {
|
||||
} else if (BuildParams.runtimeJavaVersion >= JavaVersion.VERSION_1_9) {
|
||||
test.systemProperty ('java.locale.providers','SPI,COMPAT')
|
||||
}
|
||||
}
|
||||
@ -738,9 +731,9 @@ class BuildPlugin implements Plugin<Project> {
|
||||
test.jvmArgumentProviders.add(nonInputProperties)
|
||||
test.extensions.add('nonInputProperties', nonInputProperties)
|
||||
|
||||
test.executable = "${ext.get('runtimeJavaHome')}/bin/java"
|
||||
test.executable = "${BuildParams.runtimeJavaHome}/bin/java"
|
||||
test.workingDir = project.file("${project.buildDir}/testrun/${test.name}")
|
||||
test.maxParallelForks = System.getProperty('tests.jvms', project.rootProject.extensions.extraProperties.get('defaultParallel').toString()) as Integer
|
||||
test.maxParallelForks = System.getProperty('tests.jvms', BuildParams.defaultParallel.toString()) as Integer
|
||||
|
||||
test.exclude '**/*$*.class'
|
||||
|
||||
@ -770,16 +763,16 @@ class BuildPlugin implements Plugin<Project> {
|
||||
|
||||
// ignore changing test seed when build is passed -Dignore.tests.seed for cacheability experimentation
|
||||
if (System.getProperty('ignore.tests.seed') != null) {
|
||||
nonInputProperties.systemProperty('tests.seed', project.property('testSeed'))
|
||||
nonInputProperties.systemProperty('tests.seed', BuildParams.testSeed)
|
||||
} else {
|
||||
test.systemProperty('tests.seed', project.property('testSeed'))
|
||||
test.systemProperty('tests.seed', BuildParams.testSeed)
|
||||
}
|
||||
|
||||
// don't track these as inputs since they contain absolute paths and break cache relocatability
|
||||
nonInputProperties.systemProperty('gradle.worker.jar', "${project.gradle.getGradleUserHomeDir()}/caches/${project.gradle.gradleVersion}/workerMain/gradle-worker.jar")
|
||||
nonInputProperties.systemProperty('gradle.user.home', project.gradle.getGradleUserHomeDir())
|
||||
|
||||
nonInputProperties.systemProperty('compiler.java', "${-> (ext.get('compilerJavaVersion') as JavaVersion).getMajorVersion()}")
|
||||
nonInputProperties.systemProperty('compiler.java', "${-> BuildParams.compilerJavaVersion.majorVersion}")
|
||||
|
||||
// TODO: remove setting logging level via system property
|
||||
test.systemProperty 'tests.logger.level', 'WARN'
|
||||
|
@ -24,10 +24,10 @@ import org.elasticsearch.gradle.BuildPlugin
|
||||
import org.elasticsearch.gradle.NoticeTask
|
||||
import org.elasticsearch.gradle.Version
|
||||
import org.elasticsearch.gradle.VersionProperties
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
import org.elasticsearch.gradle.test.RestIntegTestTask
|
||||
import org.elasticsearch.gradle.testclusters.RunTask
|
||||
import org.elasticsearch.gradle.testclusters.TestClustersPlugin
|
||||
import org.elasticsearch.gradle.tool.ClasspathUtils
|
||||
import org.gradle.api.InvalidUserDataException
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
@ -163,7 +163,7 @@ class PluginBuildPlugin implements Plugin<Project> {
|
||||
|
||||
private static void configureDependencies(Project project) {
|
||||
project.dependencies {
|
||||
if (ClasspathUtils.isElasticsearchProject(project)) {
|
||||
if (BuildParams.internal) {
|
||||
compileOnly project.project(':server')
|
||||
testCompile project.project(':test:framework')
|
||||
} else {
|
||||
|
@ -23,7 +23,7 @@ import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis
|
||||
import de.thetaphi.forbiddenapis.gradle.ForbiddenApisPlugin
|
||||
import org.elasticsearch.gradle.ExportElasticsearchBuildResourcesTask
|
||||
import org.elasticsearch.gradle.VersionProperties
|
||||
import org.elasticsearch.gradle.tool.ClasspathUtils
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.artifacts.Configuration
|
||||
import org.gradle.api.plugins.JavaBasePlugin
|
||||
@ -46,7 +46,7 @@ class PrecommitTasks {
|
||||
}
|
||||
|
||||
Configuration jarHellConfig = project.configurations.create("jarHell")
|
||||
if (ClasspathUtils.isElasticsearchProject(project) && project.path.equals(":libs:elasticsearch-core") == false) {
|
||||
if (BuildParams.internal && project.path.equals(":libs:elasticsearch-core") == false) {
|
||||
// External plugins will depend on this already via transitive dependencies.
|
||||
// Internal projects are not all plugins, so make sure the check is available
|
||||
// we are not doing this for this project itself to avoid jar hell with itself
|
||||
@ -132,8 +132,8 @@ class PrecommitTasks {
|
||||
return project.tasks.register('thirdPartyAudit', ThirdPartyAuditTask) { task ->
|
||||
task.dependsOn(buildResources)
|
||||
task.signatureFile = buildResources.copy("forbidden/third-party-audit.txt")
|
||||
task.javaHome = project.runtimeJavaHome
|
||||
task.targetCompatibility.set(project.provider({ project.runtimeJavaVersion }))
|
||||
task.javaHome = BuildParams.runtimeJavaHome
|
||||
task.targetCompatibility.set(project.provider({ BuildParams.runtimeJavaVersion }))
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,13 +144,13 @@ class PrecommitTasks {
|
||||
dependsOn(buildResources)
|
||||
doFirst {
|
||||
// we need to defer this configuration since we don't know the runtime java version until execution time
|
||||
targetCompatibility = project.runtimeJavaVersion.getMajorVersion()
|
||||
targetCompatibility = BuildParams.runtimeJavaVersion.majorVersion
|
||||
/*
|
||||
TODO: Reenable once Gradle supports Java 13 or later!
|
||||
if (project.runtimeJavaVersion > JavaVersion.VERSION_13) {
|
||||
if (BuildParams.runtimeJavaVersion > JavaVersion.VERSION_13) {
|
||||
project.logger.info(
|
||||
"Forbidden APIs does not support java version past 13. Will use the signatures from 13 for ",
|
||||
project.runtimeJavaVersion
|
||||
BuildParams.runtimeJavaVersion`
|
||||
)
|
||||
targetCompatibility = JavaVersion.VERSION_13.getMajorVersion()
|
||||
}
|
||||
@ -251,7 +251,7 @@ class PrecommitTasks {
|
||||
}
|
||||
|
||||
private static TaskProvider configureLoggerUsage(Project project) {
|
||||
Object dependency = ClasspathUtils.isElasticsearchProject(project) ? project.project(':test:logger-usage') :
|
||||
Object dependency = BuildParams.internal ? project.project(':test:logger-usage') :
|
||||
"org.elasticsearch.test:logger-usage:${VersionProperties.elasticsearch}"
|
||||
|
||||
project.configurations.create('loggerUsagePlugin')
|
||||
|
@ -25,6 +25,7 @@ import org.elasticsearch.gradle.BwcVersions
|
||||
import org.elasticsearch.gradle.LoggedExec
|
||||
import org.elasticsearch.gradle.Version
|
||||
import org.elasticsearch.gradle.VersionProperties
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
import org.elasticsearch.gradle.plugin.PluginBuildPlugin
|
||||
import org.elasticsearch.gradle.plugin.PluginPropertiesExtension
|
||||
import org.gradle.api.AntBuilder
|
||||
@ -706,7 +707,7 @@ class ClusterFormationTasks {
|
||||
}
|
||||
|
||||
public static boolean useRuntimeJava(Project project, NodeInfo node) {
|
||||
return (project.isRuntimeJavaHomeSet ||
|
||||
return (BuildParams.isRuntimeJavaHomeSet ||
|
||||
(node.isBwcNode == false && node.nodeVersion.before(Version.fromString("7.0.0"))) ||
|
||||
node.config.distribution == 'integ-test-zip')
|
||||
}
|
||||
@ -762,7 +763,7 @@ class ClusterFormationTasks {
|
||||
start.doLast(elasticsearchRunner)
|
||||
start.doFirst {
|
||||
// If the node runs in a FIPS 140-2 JVM, the BCFKS default keystore will be password protected
|
||||
if (project.inFipsJvm){
|
||||
if (BuildParams.inFipsJvm) {
|
||||
node.config.systemProperties.put('javax.net.ssl.trustStorePassword', 'password')
|
||||
node.config.systemProperties.put('javax.net.ssl.keyStorePassword', 'password')
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ import org.elasticsearch.gradle.Jdk;
|
||||
import org.elasticsearch.gradle.JdkDownloadPlugin;
|
||||
import org.elasticsearch.gradle.Version;
|
||||
import org.elasticsearch.gradle.VersionProperties;
|
||||
import org.elasticsearch.gradle.info.BuildParams;
|
||||
import org.elasticsearch.gradle.vagrant.BatsProgressLogger;
|
||||
import org.elasticsearch.gradle.vagrant.VagrantBasePlugin;
|
||||
import org.elasticsearch.gradle.vagrant.VagrantExtension;
|
||||
@ -163,8 +164,7 @@ public class DistroTestPlugin implements Plugin<Project> {
|
||||
return Version.fromString(project.getVersion().toString());
|
||||
}
|
||||
|
||||
ExtraPropertiesExtension rootExtraProperties = project.getRootProject().getExtensions().getByType(ExtraPropertiesExtension.class);
|
||||
String firstPartOfSeed = rootExtraProperties.get("testSeed").toString().split(":")[0];
|
||||
String firstPartOfSeed = BuildParams.getTestSeed().split(":")[0];
|
||||
final long seed = Long.parseUnsignedLong(firstPartOfSeed, 16);
|
||||
BwcVersions bwcVersions = (BwcVersions) extraProperties.get("bwcVersions");
|
||||
final List<Version> indexCompatVersions = bwcVersions.getIndexCompatible();
|
||||
|
@ -19,10 +19,10 @@
|
||||
package org.elasticsearch.gradle.test
|
||||
|
||||
import org.elasticsearch.gradle.VersionProperties
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
import org.elasticsearch.gradle.testclusters.ElasticsearchCluster
|
||||
import org.elasticsearch.gradle.testclusters.RestTestRunnerTask
|
||||
import org.elasticsearch.gradle.tool.Boilerplate
|
||||
import org.elasticsearch.gradle.tool.ClasspathUtils
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.file.FileCopyDetails
|
||||
@ -47,7 +47,7 @@ class RestIntegTestTask extends DefaultTask {
|
||||
|
||||
project.testClusters {
|
||||
"$name" {
|
||||
javaHome = project.file(project.ext.runtimeJavaHome)
|
||||
javaHome = BuildParams.runtimeJavaHome
|
||||
}
|
||||
}
|
||||
runner.useCluster project.testClusters."$name"
|
||||
@ -120,7 +120,7 @@ class RestIntegTestTask extends DefaultTask {
|
||||
Boilerplate.maybeCreate(project.configurations, 'restSpec') {
|
||||
project.dependencies.add(
|
||||
'restSpec',
|
||||
ClasspathUtils.isElasticsearchProject(project) ? project.project(':rest-api-spec') :
|
||||
BuildParams.internal ? project.project(':rest-api-spec') :
|
||||
"org.elasticsearch:rest-api-spec:${VersionProperties.elasticsearch}"
|
||||
)
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ package org.elasticsearch.gradle.test
|
||||
import groovy.transform.CompileStatic
|
||||
import org.elasticsearch.gradle.BuildPlugin
|
||||
import org.elasticsearch.gradle.ExportElasticsearchBuildResourcesTask
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
import org.elasticsearch.gradle.info.GlobalBuildInfoPlugin
|
||||
import org.elasticsearch.gradle.precommit.PrecommitTasks
|
||||
import org.elasticsearch.gradle.testclusters.TestClustersPlugin
|
||||
@ -67,8 +68,8 @@ class StandaloneRestTestPlugin implements Plugin<Project> {
|
||||
BuildPlugin.configureFips140(project)
|
||||
|
||||
ExtraPropertiesExtension ext = project.extensions.getByType(ExtraPropertiesExtension)
|
||||
project.extensions.getByType(JavaPluginExtension).sourceCompatibility = ext.get('minimumRuntimeVersion') as JavaVersion
|
||||
project.extensions.getByType(JavaPluginExtension).targetCompatibility = ext.get('minimumRuntimeVersion') as JavaVersion
|
||||
project.extensions.getByType(JavaPluginExtension).sourceCompatibility = BuildParams.minimumRuntimeVersion
|
||||
project.extensions.getByType(JavaPluginExtension).targetCompatibility = BuildParams.minimumRuntimeVersion
|
||||
|
||||
// only setup tests to build
|
||||
SourceSetContainer sourceSets = project.extensions.getByType(SourceSetContainer)
|
||||
|
@ -22,7 +22,7 @@ package org.elasticsearch.gradle;
|
||||
import org.elasticsearch.gradle.ElasticsearchDistribution.Flavor;
|
||||
import org.elasticsearch.gradle.ElasticsearchDistribution.Platform;
|
||||
import org.elasticsearch.gradle.ElasticsearchDistribution.Type;
|
||||
import org.elasticsearch.gradle.tool.ClasspathUtils;
|
||||
import org.elasticsearch.gradle.info.BuildParams;
|
||||
import org.gradle.api.GradleException;
|
||||
import org.gradle.api.NamedDomainObjectContainer;
|
||||
import org.gradle.api.Plugin;
|
||||
@ -75,7 +75,7 @@ public class DistributionDownloadPlugin implements Plugin<Project> {
|
||||
|
||||
setupDownloadServiceRepo(project);
|
||||
|
||||
if (ClasspathUtils.isElasticsearchProject(project)) {
|
||||
if (BuildParams.isInternal()) {
|
||||
ExtraPropertiesExtension extraProperties = project.getExtensions().getExtraProperties();
|
||||
this.bwcVersions = (BwcVersions) extraProperties.get("bwcVersions");
|
||||
}
|
||||
@ -179,7 +179,7 @@ public class DistributionDownloadPlugin implements Plugin<Project> {
|
||||
return;
|
||||
}
|
||||
addIvyRepo(project, DOWNLOAD_REPO_NAME, "https://artifacts.elastic.co", FAKE_IVY_GROUP);
|
||||
if (ClasspathUtils.isElasticsearchProject(project) == false) {
|
||||
if (BuildParams.isInternal() == false) {
|
||||
// external, so add snapshot repo as well
|
||||
addIvyRepo(project, SNAPSHOT_REPO_NAME, "https://snapshots.elastic.co", FAKE_SNAPSHOT_IVY_GROUP);
|
||||
}
|
||||
@ -198,7 +198,7 @@ public class DistributionDownloadPlugin implements Plugin<Project> {
|
||||
*/
|
||||
private Object dependencyNotation(Project project, ElasticsearchDistribution distribution) {
|
||||
|
||||
if (ClasspathUtils.isElasticsearchProject(project)) {
|
||||
if (BuildParams.isInternal()) {
|
||||
// non-external project, so depend on local build
|
||||
|
||||
if (VersionProperties.getElasticsearch().equals(distribution.getVersion())) {
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.gradle;
|
||||
|
||||
import org.elasticsearch.gradle.tool.ClasspathUtils;
|
||||
import org.elasticsearch.gradle.info.BuildParams;
|
||||
import org.gradle.api.GradleException;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.logging.Logger;
|
||||
@ -50,7 +50,7 @@ public class ReaperService {
|
||||
|
||||
public ReaperService(Project project, Path buildDir, Path inputDir) {
|
||||
this.logger = project.getLogger();
|
||||
this.isInternal = ClasspathUtils.isElasticsearchProject(project);
|
||||
this.isInternal = BuildParams.isInternal();
|
||||
this.buildDir = buildDir;
|
||||
this.inputDir = inputDir;
|
||||
this.logFile = inputDir.resolve("reaper.log");
|
||||
|
@ -0,0 +1,239 @@
|
||||
package org.elasticsearch.gradle.info;
|
||||
|
||||
import org.gradle.api.JavaVersion;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
public class BuildParams {
|
||||
private static File compilerJavaHome;
|
||||
private static File runtimeJavaHome;
|
||||
private static Boolean isRuntimeJavaHomeSet;
|
||||
private static List<JavaHome> javaVersions;
|
||||
private static JavaVersion minimumCompilerVersion;
|
||||
private static JavaVersion minimumRuntimeVersion;
|
||||
private static JavaVersion gradleJavaVersion;
|
||||
private static JavaVersion compilerJavaVersion;
|
||||
private static JavaVersion runtimeJavaVersion;
|
||||
private static Boolean inFipsJvm;
|
||||
private static String gitRevision;
|
||||
private static ZonedDateTime buildDate;
|
||||
private static String testSeed;
|
||||
private static Boolean isCi;
|
||||
private static Boolean isInternal;
|
||||
private static Integer defaultParallel;
|
||||
|
||||
/**
|
||||
* Initialize global build parameters. This method accepts and a initialization function which in turn accepts a
|
||||
* {@link MutableBuildParams}. Initialization can be done in "stages", therefore changes override existing values, and values from
|
||||
* previous calls to {@link #init(Consumer)} carry forward. In cases where you want to clear existing values
|
||||
* {@link MutableBuildParams#reset()} may be used.
|
||||
*
|
||||
* @param initializer Build parameter initializer
|
||||
*/
|
||||
public static void init(Consumer<MutableBuildParams> initializer) {
|
||||
initializer.accept(MutableBuildParams.INSTANCE);
|
||||
}
|
||||
|
||||
public static File getCompilerJavaHome() {
|
||||
return value(compilerJavaHome);
|
||||
}
|
||||
|
||||
public static File getRuntimeJavaHome() {
|
||||
return value(runtimeJavaHome);
|
||||
}
|
||||
|
||||
public static Boolean getIsRuntimeJavaHomeSet() {
|
||||
return value(isRuntimeJavaHomeSet);
|
||||
}
|
||||
|
||||
public static List<JavaHome> getJavaVersions() {
|
||||
return value(javaVersions);
|
||||
}
|
||||
|
||||
public static JavaVersion getMinimumCompilerVersion() {
|
||||
return value(minimumCompilerVersion);
|
||||
}
|
||||
|
||||
public static JavaVersion getMinimumRuntimeVersion() {
|
||||
return value(minimumRuntimeVersion);
|
||||
}
|
||||
|
||||
public static JavaVersion getGradleJavaVersion() {
|
||||
return value(gradleJavaVersion);
|
||||
}
|
||||
|
||||
@ExecutionTime
|
||||
public static JavaVersion getCompilerJavaVersion() {
|
||||
return value(compilerJavaVersion);
|
||||
}
|
||||
|
||||
@ExecutionTime
|
||||
public static JavaVersion getRuntimeJavaVersion() {
|
||||
return value(runtimeJavaVersion);
|
||||
}
|
||||
|
||||
@ExecutionTime
|
||||
public static Boolean isInFipsJvm() {
|
||||
return value(inFipsJvm);
|
||||
}
|
||||
|
||||
public static String getGitRevision() {
|
||||
return value(gitRevision);
|
||||
}
|
||||
|
||||
public static ZonedDateTime getBuildDate() {
|
||||
return value(buildDate);
|
||||
}
|
||||
|
||||
public static String getTestSeed() {
|
||||
return value(testSeed);
|
||||
}
|
||||
|
||||
public static Boolean isCi() {
|
||||
return value(isCi);
|
||||
}
|
||||
|
||||
public static Boolean isInternal() {
|
||||
return value(isInternal);
|
||||
}
|
||||
|
||||
public static Integer getDefaultParallel() {
|
||||
return value(defaultParallel);
|
||||
}
|
||||
|
||||
private static <T> T value(T object) {
|
||||
if (object == null) {
|
||||
String callingMethod = Thread.currentThread().getStackTrace()[2].getMethodName();
|
||||
boolean executionTime;
|
||||
try {
|
||||
executionTime = BuildParams.class.getMethod(callingMethod).getAnnotation(ExecutionTime.class) != null;
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
String message = "Build parameter '" + propertyName(callingMethod) + "' has not been initialized. ";
|
||||
if (executionTime) {
|
||||
message += "This property is initialized at execution time, " +
|
||||
"please ensure you are not attempting to access it during project configuration.";
|
||||
} else {
|
||||
message += "Perhaps the plugin responsible for initializing this property has not been applied.";
|
||||
}
|
||||
|
||||
throw new IllegalStateException(message);
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
private static String propertyName(String methodName) {
|
||||
String propertyName = methodName.substring("get".length());
|
||||
return propertyName.substring(0, 1).toLowerCase() + propertyName.substring(1);
|
||||
}
|
||||
|
||||
public static class MutableBuildParams {
|
||||
private static MutableBuildParams INSTANCE = new MutableBuildParams();
|
||||
|
||||
private MutableBuildParams() { }
|
||||
|
||||
/**
|
||||
* Resets any existing values from previous initializations.
|
||||
*/
|
||||
public void reset() {
|
||||
Arrays.stream(BuildParams.class.getDeclaredFields())
|
||||
.filter(f -> Modifier.isStatic(f.getModifiers()))
|
||||
.forEach(f -> {
|
||||
try {
|
||||
f.setAccessible(true);
|
||||
f.set(null, null);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setCompilerJavaHome(File compilerJavaHome) {
|
||||
BuildParams.compilerJavaHome = requireNonNull(compilerJavaHome);
|
||||
}
|
||||
|
||||
public void setRuntimeJavaHome(File runtimeJavaHome) {
|
||||
BuildParams.runtimeJavaHome = requireNonNull(runtimeJavaHome);
|
||||
}
|
||||
|
||||
public void setIsRutimeJavaHomeSet(boolean isRutimeJavaHomeSet) {
|
||||
BuildParams.isRuntimeJavaHomeSet = isRutimeJavaHomeSet;
|
||||
}
|
||||
|
||||
public void setJavaVersions(List<JavaHome> javaVersions) {
|
||||
BuildParams.javaVersions = requireNonNull(javaVersions);
|
||||
}
|
||||
|
||||
public void setMinimumCompilerVersion(JavaVersion minimumCompilerVersion) {
|
||||
BuildParams.minimumCompilerVersion = requireNonNull(minimumCompilerVersion);
|
||||
}
|
||||
|
||||
public void setMinimumRuntimeVersion(JavaVersion minimumRuntimeVersion) {
|
||||
BuildParams.minimumRuntimeVersion = requireNonNull(minimumRuntimeVersion);
|
||||
}
|
||||
|
||||
public void setGradleJavaVersion(JavaVersion gradleJavaVersion) {
|
||||
BuildParams.gradleJavaVersion = requireNonNull(gradleJavaVersion);
|
||||
}
|
||||
|
||||
public void setCompilerJavaVersion(JavaVersion compilerJavaVersion) {
|
||||
BuildParams.compilerJavaVersion = requireNonNull(compilerJavaVersion);
|
||||
}
|
||||
|
||||
public void setRuntimeJavaVersion(JavaVersion runtimeJavaVersion) {
|
||||
BuildParams.runtimeJavaVersion = requireNonNull(runtimeJavaVersion);
|
||||
}
|
||||
|
||||
public void setInFipsJvm(boolean inFipsJvm) {
|
||||
BuildParams.inFipsJvm = inFipsJvm;
|
||||
}
|
||||
|
||||
public void setGitRevision(String gitRevision) {
|
||||
BuildParams.gitRevision = requireNonNull(gitRevision);
|
||||
}
|
||||
|
||||
public void setBuildDate(ZonedDateTime buildDate) {
|
||||
BuildParams.buildDate = requireNonNull(buildDate);
|
||||
}
|
||||
|
||||
public void setTestSeed(String testSeed) {
|
||||
BuildParams.testSeed = requireNonNull(testSeed);
|
||||
}
|
||||
|
||||
public void setIsCi(boolean isCi) {
|
||||
BuildParams.isCi = isCi;
|
||||
}
|
||||
|
||||
public void setIsInternal(Boolean isInternal) {
|
||||
BuildParams.isInternal = requireNonNull(isInternal);
|
||||
}
|
||||
|
||||
public void setDefaultParallel(int defaultParallel) {
|
||||
BuildParams.defaultParallel = defaultParallel;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates that a build parameter is initialized at task execution time and is not available at project configuration time.
|
||||
* Attempts to read an uninitialized parameter wil result in an {@link IllegalStateException}.
|
||||
*/
|
||||
@Target({ElementType.METHOD, ElementType.FIELD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface ExecutionTime {}
|
||||
}
|
@ -5,7 +5,6 @@ import org.gradle.api.GradleException;
|
||||
import org.gradle.api.JavaVersion;
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.plugins.ExtraPropertiesExtension;
|
||||
import org.gradle.internal.jvm.Jvm;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@ -88,7 +87,23 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
|
||||
task.setGlobalInfoListeners(extension.listeners);
|
||||
});
|
||||
|
||||
project.getExtensions().getByType(ExtraPropertiesExtension.class).set("defaultParallel", findDefaultParallel(project));
|
||||
// Initialize global build parameters
|
||||
BuildParams.init(params -> {
|
||||
params.reset();
|
||||
params.setCompilerJavaHome(compilerJavaHome);
|
||||
params.setRuntimeJavaHome(runtimeJavaHome);
|
||||
params.setIsRutimeJavaHomeSet(compilerJavaHome.equals(runtimeJavaHome) == false);
|
||||
params.setJavaVersions(javaVersions);
|
||||
params.setMinimumCompilerVersion(minimumCompilerVersion);
|
||||
params.setMinimumRuntimeVersion(minimumRuntimeVersion);
|
||||
params.setGradleJavaVersion(Jvm.current().getJavaVersion());
|
||||
params.setGitRevision(gitRevision(project.getRootProject().getRootDir()));
|
||||
params.setBuildDate(ZonedDateTime.now(ZoneOffset.UTC));
|
||||
params.setTestSeed(testSeed);
|
||||
params.setIsCi(System.getenv("JENKINS_URL") != null);
|
||||
params.setIsInternal(GlobalBuildInfoPlugin.class.getResource("/buildSrc.marker") != null);
|
||||
params.setDefaultParallel(findDefaultParallel(project));
|
||||
});
|
||||
|
||||
project.allprojects(p -> {
|
||||
// Make sure than any task execution generates and prints build info
|
||||
@ -97,21 +112,6 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
|
||||
task.dependsOn(printTask);
|
||||
}
|
||||
});
|
||||
|
||||
ExtraPropertiesExtension ext = p.getExtensions().getByType(ExtraPropertiesExtension.class);
|
||||
|
||||
ext.set("compilerJavaHome", compilerJavaHome);
|
||||
ext.set("runtimeJavaHome", runtimeJavaHome);
|
||||
ext.set("isRuntimeJavaHomeSet", compilerJavaHome.equals(runtimeJavaHome) == false);
|
||||
ext.set("javaVersions", javaVersions);
|
||||
ext.set("minimumCompilerVersion", minimumCompilerVersion);
|
||||
ext.set("minimumRuntimeVersion", minimumRuntimeVersion);
|
||||
ext.set("gradleJavaVersion", Jvm.current().getJavaVersion());
|
||||
ext.set("gitRevision", gitRevision(project.getRootProject().getRootDir()));
|
||||
ext.set("buildDate", ZonedDateTime.now(ZoneOffset.UTC));
|
||||
ext.set("testSeed", testSeed);
|
||||
ext.set("isCi", System.getenv("JENKINS_URL") != null);
|
||||
ext.set("isInternal", GlobalBuildInfoPlugin.class.getResource("/buildSrc.marker") != null);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@ import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.JavaVersion;
|
||||
import org.gradle.api.file.RegularFileProperty;
|
||||
import org.gradle.api.model.ObjectFactory;
|
||||
import org.gradle.api.plugins.ExtraPropertiesExtension;
|
||||
import org.gradle.api.resources.TextResource;
|
||||
import org.gradle.api.tasks.InputFile;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
@ -57,7 +56,7 @@ public class PrintGlobalBuildInfoTask extends DefaultTask {
|
||||
getLogger().quiet("=======================================");
|
||||
getLogger().quiet("Elasticsearch Build Hamster says Hello!");
|
||||
getLogger().quiet(getFileText(getBuildInfoFile()).asString());
|
||||
getLogger().quiet(" Random Testing Seed : " + getProject().property("testSeed"));
|
||||
getLogger().quiet(" Random Testing Seed : " + BuildParams.getTestSeed());
|
||||
getLogger().quiet("=======================================");
|
||||
|
||||
setGlobalProperties();
|
||||
@ -74,11 +73,10 @@ public class PrintGlobalBuildInfoTask extends DefaultTask {
|
||||
}
|
||||
|
||||
private void setGlobalProperties() {
|
||||
getProject().getRootProject().allprojects(p -> {
|
||||
ExtraPropertiesExtension ext = p.getExtensions().getByType(ExtraPropertiesExtension.class);
|
||||
ext.set("compilerJavaVersion", JavaVersion.valueOf(getFileText(getCompilerVersionFile()).asString()));
|
||||
ext.set("runtimeJavaVersion", JavaVersion.valueOf(getFileText(getRuntimeVersionFile()).asString()));
|
||||
ext.set("inFipsJvm", Boolean.valueOf(getFileText(getFipsJvmFile()).asString()));
|
||||
BuildParams.init(params -> {
|
||||
params.setCompilerJavaVersion(JavaVersion.valueOf(getFileText(getCompilerVersionFile()).asString()));
|
||||
params.setRuntimeJavaVersion(JavaVersion.valueOf(getFileText(getRuntimeVersionFile()).asString()));
|
||||
params.setInFipsJvm(Boolean.parseBoolean(getFileText(getFipsJvmFile()).asString()));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ package org.elasticsearch.gradle;
|
||||
import org.elasticsearch.gradle.ElasticsearchDistribution.Flavor;
|
||||
import org.elasticsearch.gradle.ElasticsearchDistribution.Platform;
|
||||
import org.elasticsearch.gradle.ElasticsearchDistribution.Type;
|
||||
import org.elasticsearch.gradle.info.BuildParams;
|
||||
import org.elasticsearch.gradle.test.GradleUnitTestCase;
|
||||
import org.gradle.api.NamedDomainObjectContainer;
|
||||
import org.gradle.api.Project;
|
||||
@ -234,7 +235,7 @@ public class DistributionDownloadPluginTests extends GradleUnitTestCase {
|
||||
|
||||
private Project createProject(BwcVersions bwcVersions, boolean isInternal) {
|
||||
rootProject = ProjectBuilder.builder().build();
|
||||
rootProject.getExtensions().getExtraProperties().set("isInternal", isInternal);
|
||||
BuildParams.init(params -> params.setIsInternal(isInternal));
|
||||
Project distributionProject = ProjectBuilder.builder().withParent(rootProject).withName("distribution").build();
|
||||
archivesProject = ProjectBuilder.builder().withParent(distributionProject).withName("archives").build();
|
||||
packagesProject = ProjectBuilder.builder().withParent(distributionProject).withName("packages").build();
|
||||
@ -243,7 +244,6 @@ public class DistributionDownloadPluginTests extends GradleUnitTestCase {
|
||||
if (bwcVersions != null) {
|
||||
project.getExtensions().getExtraProperties().set("bwcVersions", bwcVersions);
|
||||
}
|
||||
project.getExtensions().getExtraProperties().set("isInternal", isInternal);
|
||||
project.getPlugins().apply("elasticsearch.distribution-download");
|
||||
return project;
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
import org.elasticsearch.gradle.BwcVersions
|
||||
import org.elasticsearch.gradle.Version
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
|
||||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
@ -23,6 +25,7 @@ plugins {
|
||||
id 'elasticsearch.global-build-info'
|
||||
}
|
||||
boolean internal = Boolean.parseBoolean(System.getProperty("tests.internal", "true"))
|
||||
BuildParams.init { it.setIsInternal(internal) }
|
||||
|
||||
project.gradle.projectsEvaluated {
|
||||
// wire the download service url to wiremock
|
||||
@ -41,10 +44,6 @@ project.gradle.projectsEvaluated {
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
ext.isInternal = internal
|
||||
}
|
||||
|
||||
if (internal) {
|
||||
Version currentVersion = Version.fromString("9.0.0")
|
||||
BwcVersions versions = new BwcVersions(new TreeSet<>(
|
||||
|
@ -21,6 +21,7 @@ import org.apache.tools.ant.taskdefs.condition.Os
|
||||
import org.elasticsearch.gradle.LoggedExec
|
||||
import org.elasticsearch.gradle.Version
|
||||
import org.elasticsearch.gradle.BwcVersions
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
import org.elasticsearch.gradle.info.GlobalBuildInfoPlugin
|
||||
|
||||
import java.nio.charset.StandardCharsets
|
||||
@ -225,7 +226,7 @@ bwcVersions.forPreviousUnreleased { BwcVersions.UnreleasedVersionInfo unreleased
|
||||
outputs.files(projectArtifact)
|
||||
outputs.cacheIf("BWC distribution caching is disabled on 'master' branch") {
|
||||
// Don't bother caching in 'master' since the BWC branches move too quickly to make this cost worthwhile
|
||||
project.ext.isCi && System.getenv('GIT_BRANCH')?.endsWith("master") == false
|
||||
BuildParams.ci && System.getenv('GIT_BRANCH')?.endsWith("master") == false
|
||||
}
|
||||
args ":${projectDir.replace('/', ':')}:assemble"
|
||||
if (project.gradle.startParameter.buildCacheEnabled) {
|
||||
|
@ -1,7 +1,8 @@
|
||||
import org.elasticsearch.gradle.BuildPlugin
|
||||
import org.elasticsearch.gradle.LoggedExec
|
||||
import org.elasticsearch.gradle.VersionProperties
|
||||
import org.elasticsearch.gradle.testfixtures.TestFixturesPlugin
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
import org.elasticsearch.gradle.testfixtures.TestFixturesPlugin
|
||||
|
||||
apply plugin: 'elasticsearch.standalone-rest-test'
|
||||
apply plugin: 'elasticsearch.test.fixtures'
|
||||
@ -26,9 +27,9 @@ ext.expansions = { oss, ubi, local ->
|
||||
final String elasticsearch = oss ? "elasticsearch-oss-${VersionProperties.elasticsearch}-${classifier}.tar.gz" : "elasticsearch-${VersionProperties.elasticsearch}-${classifier}.tar.gz"
|
||||
return [
|
||||
'base_image' : ubi ? 'registry.access.redhat.com/ubi7/ubi-minimal:7.7' : 'centos:7',
|
||||
'build_date' : project.ext.buildDate,
|
||||
'build_date' : BuildParams.buildDate,
|
||||
'elasticsearch' : elasticsearch,
|
||||
'git_revision' : project.ext.gitRevision,
|
||||
'git_revision' : BuildParams.gitRevision,
|
||||
'license' : oss ? 'Apache-2.0' : 'Elastic-License',
|
||||
'package_manager' : ubi ? 'microdnf' : 'yum',
|
||||
'source_elasticsearch': local ? "COPY $elasticsearch /opt/" : "RUN cd /opt && curl --retry 8 -s -L -O https://artifacts.elastic.co/downloads/elasticsearch/${elasticsearch} && cd -",
|
||||
|
@ -1,3 +1,5 @@
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
|
||||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
@ -43,7 +45,7 @@ test {
|
||||
thirdPartyAudit.onlyIf {
|
||||
// FIPS JVM includes manny classes from bouncycastle which count as jar hell for the third party audit,
|
||||
// rather than provide a long list of exclusions, disable the check on FIPS.
|
||||
project.inFipsJvm == false
|
||||
BuildParams.inFipsJvm
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,3 +1,5 @@
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
|
||||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
@ -48,7 +50,7 @@ if (!isEclipse && !isIdea) {
|
||||
|
||||
forbiddenApisJava9 {
|
||||
rootProject.globalInfo.ready {
|
||||
if (project.runtimeJavaVersion < JavaVersion.VERSION_1_9) {
|
||||
if (BuildParams.runtimeJavaVersion < JavaVersion.VERSION_1_9) {
|
||||
targetCompatibility = JavaVersion.VERSION_1_9.getMajorVersion()
|
||||
}
|
||||
replaceSignatureFiles 'jdk-signatures'
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
import org.apache.tools.ant.taskdefs.condition.Os
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
|
||||
import static org.elasticsearch.gradle.BuildPlugin.getJavaHome
|
||||
|
||||
@ -115,7 +116,7 @@ if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
||||
Task fixture = task("oldEs${version}Fixture", type: org.elasticsearch.gradle.test.AntFixture) {
|
||||
dependsOn project.configurations.oldesFixture
|
||||
dependsOn unzip
|
||||
executable = new File(project.runtimeJavaHome, 'bin/java')
|
||||
executable = "${BuildParams.runtimeJavaHome}/bin/java"
|
||||
env 'CLASSPATH', "${ -> project.configurations.oldesFixture.asPath }"
|
||||
env 'JAVA_HOME', "${ -> getJavaHome(it, 8)}"
|
||||
args 'oldes.OldElasticsearch',
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
import org.elasticsearch.gradle.PropertyNormalization
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
import org.elasticsearch.gradle.test.AntFixture
|
||||
|
||||
esplugin {
|
||||
@ -35,7 +36,7 @@ task urlFixture(type: AntFixture) {
|
||||
repositoryDir.mkdirs()
|
||||
}
|
||||
env 'CLASSPATH', "${ -> project.sourceSets.test.runtimeClasspath.asPath }"
|
||||
executable = new File(project.runtimeJavaHome, 'bin/java')
|
||||
executable = "${BuildParams.runtimeJavaHome}/bin/java"
|
||||
args 'org.elasticsearch.repositories.url.URLFixture', baseDir, "${repositoryDir.absolutePath}"
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,8 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
import org.elasticsearch.gradle.test.RestIntegTestTask
|
||||
|
||||
/*
|
||||
@ -196,7 +198,7 @@ thirdPartyAudit {
|
||||
}
|
||||
|
||||
rootProject.globalInfo.ready {
|
||||
if (project.inFipsJvm == false) {
|
||||
if (BuildParams.inFipsJvm == false) {
|
||||
// BouncyCastleFIPS provides this class, so the exclusion is invalid when running CI in
|
||||
// a FIPS JVM with BouncyCastleFIPS Provider
|
||||
thirdPartyAudit.ignoreMissingClasses(
|
||||
|
@ -1,4 +1,5 @@
|
||||
import org.elasticsearch.gradle.LoggedExec
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
|
||||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
@ -69,7 +70,7 @@ task createKey(type: LoggedExec) {
|
||||
keystore.parentFile.mkdirs()
|
||||
}
|
||||
outputs.file(keystore).withPropertyName('keystoreFile')
|
||||
executable = new File(project.runtimeJavaHome, 'bin/keytool')
|
||||
executable = "${BuildParams.runtimeJavaHome}/bin/keytool"
|
||||
standardInput = new ByteArrayInputStream('FirstName LastName\nUnit\nOrganization\nCity\nState\nNL\nyes\n\n'.getBytes('UTF-8'))
|
||||
args '-genkey',
|
||||
'-alias', 'test-node',
|
||||
@ -137,7 +138,7 @@ thirdPartyAudit.ignoreMissingClasses (
|
||||
|
||||
// jarhell with jdk (intentionally, because jaxb was removed from default modules in java 9)
|
||||
rootProject.globalInfo.ready {
|
||||
if (project.runtimeJavaVersion <= JavaVersion.VERSION_1_8) {
|
||||
if (BuildParams.runtimeJavaVersion <= JavaVersion.VERSION_1_8) {
|
||||
thirdPartyAudit.ignoreJarHellWithJDK(
|
||||
'javax.xml.bind.Binder',
|
||||
'javax.xml.bind.ContextFinder$1',
|
||||
|
@ -1,3 +1,5 @@
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
|
||||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
@ -110,7 +112,7 @@ thirdPartyAudit.ignoreMissingClasses (
|
||||
)
|
||||
|
||||
rootProject.globalInfo.ready {
|
||||
if (project.runtimeJavaVersion > JavaVersion.VERSION_1_8) {
|
||||
if (BuildParams.runtimeJavaVersion > JavaVersion.VERSION_1_8) {
|
||||
thirdPartyAudit.ignoreMissingClasses(
|
||||
'javax.xml.bind.DatatypeConverter',
|
||||
'javax.xml.bind.JAXBContext'
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
|
||||
import org.elasticsearch.gradle.MavenFilteringHack
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
import org.elasticsearch.gradle.test.AntFixture
|
||||
import org.elasticsearch.gradle.test.RestIntegTestTask
|
||||
|
||||
@ -60,7 +61,7 @@ integTest.enabled = false
|
||||
AntFixture fixture = tasks.create(name: "ec2Fixture${action}", type: AntFixture) {
|
||||
dependsOn compileTestJava
|
||||
env 'CLASSPATH', "${ -> project.sourceSets.test.runtimeClasspath.asPath }"
|
||||
executable = new File(project.runtimeJavaHome, 'bin/java')
|
||||
executable = "${BuildParams.runtimeJavaHome}/bin/java"
|
||||
args 'org.elasticsearch.discovery.ec2.AmazonEC2Fixture', baseDir, "${buildDir}/testclusters/integTest${action}-1/config/unicast_hosts.txt"
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
|
||||
import org.elasticsearch.gradle.MavenFilteringHack
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
import org.elasticsearch.gradle.test.AntFixture
|
||||
|
||||
import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE
|
||||
@ -36,7 +37,7 @@ dependencies {
|
||||
task gceFixture(type: AntFixture) {
|
||||
dependsOn compileTestJava
|
||||
env 'CLASSPATH', "${ -> project.sourceSets.test.runtimeClasspath.asPath }"
|
||||
executable = new File(project.runtimeJavaHome, 'bin/java')
|
||||
executable = "${BuildParams.runtimeJavaHome}/bin/java"
|
||||
args 'org.elasticsearch.cloud.gce.GCEFixture', baseDir, "${buildDir}/testclusters/integTest-1/config/unicast_hosts.txt"
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
|
||||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
@ -33,7 +35,7 @@ test.enabled = false
|
||||
task exampleFixture(type: org.elasticsearch.gradle.test.AntFixture) {
|
||||
dependsOn testClasses
|
||||
env 'CLASSPATH', "${ -> project.sourceSets.test.runtimeClasspath.asPath }"
|
||||
executable = new File(project.runtimeJavaHome, 'bin/java')
|
||||
executable = "${BuildParams.runtimeJavaHome}/bin/java"
|
||||
args 'org.elasticsearch.example.resthandler.ExampleFixture', baseDir, 'TEST'
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
|
||||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
@ -89,5 +91,5 @@ thirdPartyAudit{
|
||||
thirdPartyAudit.onlyIf {
|
||||
// FIPS JVM includes manny classes from bouncycastle which count as jar hell for the third party audit,
|
||||
// rather than provide a long list of exclusions, disable the check on FIPS.
|
||||
project.inFipsJvm == false
|
||||
BuildParams.inFipsJvm == false
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
|
||||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
@ -89,7 +91,7 @@ task thirdPartyTest(type: Test) {
|
||||
systemProperty 'test.azure.key', azureKey ? azureKey : ""
|
||||
systemProperty 'test.azure.sas_token', azureSasToken ? azureSasToken : ""
|
||||
systemProperty 'test.azure.container', azureContainer ? azureContainer : ""
|
||||
systemProperty 'test.azure.base', (azureBasePath ? azureBasePath : "") + "_third_party_tests_" + project.testSeed
|
||||
systemProperty 'test.azure.base', (azureBasePath ? azureBasePath : "") + "_third_party_tests_" + BuildParams.testSeed
|
||||
}
|
||||
|
||||
if (azureAccount || azureKey || azureContainer || azureBasePath || azureSasToken) {
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
|
||||
import org.elasticsearch.gradle.MavenFilteringHack
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
import org.elasticsearch.gradle.test.AntFixture
|
||||
|
||||
import static org.elasticsearch.gradle.PropertyNormalization.DEFAULT
|
||||
@ -81,7 +82,7 @@ testClusters.integTest {
|
||||
// in a hacky way to change the protocol and endpoint. We must fix that.
|
||||
setting 'azure.client.integration_test.endpoint_suffix',
|
||||
{ "ignored;DefaultEndpointsProtocol=http;BlobEndpoint=${ -> azureAddress() }" }, IGNORE_VALUE
|
||||
String firstPartOfSeed = project.rootProject.testSeed.tokenize(':').get(0)
|
||||
String firstPartOfSeed = BuildParams.testSeed.tokenize(':').get(0)
|
||||
setting 'thread_pool.repository_azure.max', (Math.abs(Long.parseUnsignedLong(firstPartOfSeed, 16) % 10) + 1).toString(), System.getProperty('ignore.tests.seed') == null ? DEFAULT : IGNORE_VALUE
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
|
||||
import org.elasticsearch.gradle.MavenFilteringHack
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
import org.elasticsearch.gradle.test.AntFixture
|
||||
|
||||
import java.nio.file.Files
|
||||
@ -61,7 +62,7 @@ def encodedCredentials = {
|
||||
task googleCloudStorageFixture(type: AntFixture) {
|
||||
dependsOn testClasses
|
||||
env 'CLASSPATH', "${ -> project.sourceSets.test.runtimeClasspath.asPath }"
|
||||
executable = new File(project.runtimeJavaHome, 'bin/java')
|
||||
executable = "${BuildParams.runtimeJavaHome}/bin/java"
|
||||
args 'org.elasticsearch.repositories.gcs.GoogleCloudStorageFixture', baseDir, 'bucket_test'
|
||||
}
|
||||
|
||||
@ -89,7 +90,7 @@ task thirdPartyTest (type: Test) {
|
||||
include '**/GoogleCloudStorageThirdPartyTests.class'
|
||||
systemProperty 'tests.security.manager', false
|
||||
systemProperty 'test.google.bucket', gcsBucket
|
||||
systemProperty 'test.google.base', gcsBasePath + "_third_party_tests_" + project.testSeed
|
||||
systemProperty 'test.google.base', gcsBasePath + "_third_party_tests_" + BuildParams.testSeed
|
||||
nonInputProperties.systemProperty 'test.google.account', "${ -> encodedCredentials.call() }"
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
import org.apache.tools.ant.taskdefs.condition.Os
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
import org.elasticsearch.gradle.test.RestIntegTestTask
|
||||
|
||||
import java.nio.file.Files
|
||||
@ -93,10 +94,10 @@ String krb5conf = project(':test:fixtures:krb5kdc-fixture').ext.krb5Conf("hdfs")
|
||||
for (String fixtureName : ['hdfsFixture', 'haHdfsFixture', 'secureHdfsFixture', 'secureHaHdfsFixture']) {
|
||||
project.tasks.create(fixtureName, org.elasticsearch.gradle.test.AntFixture) {
|
||||
dependsOn project.configurations.hdfsFixture, project(':test:fixtures:krb5kdc-fixture').tasks.postProcessFixture
|
||||
executable = new File(project.runtimeJavaHome, 'bin/java')
|
||||
executable = "${BuildParams.runtimeJavaHome}/bin/java"
|
||||
env 'CLASSPATH', "${ -> project.configurations.hdfsFixture.asPath }"
|
||||
maxWaitInSeconds 60
|
||||
onlyIf { project(':test:fixtures:krb5kdc-fixture').buildFixture.enabled && project.inFipsJvm == false }
|
||||
onlyIf { project(':test:fixtures:krb5kdc-fixture').buildFixture.enabled && BuildParams.inFipsJvm == false }
|
||||
waitCondition = { fixture, ant ->
|
||||
// the hdfs.MiniHDFS fixture writes the ports file when
|
||||
// it's ready, so we can just wait for the file to exist
|
||||
@ -108,7 +109,7 @@ for (String fixtureName : ['hdfsFixture', 'haHdfsFixture', 'secureHdfsFixture',
|
||||
if (fixtureName.equals('secureHdfsFixture') || fixtureName.equals('secureHaHdfsFixture')) {
|
||||
miniHDFSArgs.add("-Djava.security.krb5.conf=${project(':test:fixtures:krb5kdc-fixture').ext.krb5Conf("hdfs")}");
|
||||
rootProject.globalInfo.ready {
|
||||
if (project.runtimeJavaVersion == JavaVersion.VERSION_1_9) {
|
||||
if (BuildParams.runtimeJavaVersion == JavaVersion.VERSION_1_9) {
|
||||
miniHDFSArgs.add('--add-opens=java.security.jgss/sun.security.krb5=ALL-UNNAMED')
|
||||
}
|
||||
}
|
||||
@ -154,7 +155,7 @@ for (String integTestTaskName : ['integTestHa', 'integTestSecure', 'integTestSec
|
||||
}
|
||||
|
||||
runner {
|
||||
onlyIf { project.inFipsJvm == false }
|
||||
onlyIf { BuildParams.inFipsJvm == false }
|
||||
if (integTestTaskName.contains("Ha")) {
|
||||
if (integTestTaskName.contains("Secure")) {
|
||||
Path path = buildDir.toPath()
|
||||
@ -226,7 +227,7 @@ if (legalPath == false) {
|
||||
// Always ignore HA integration tests in the normal integration test runner, they are included below as
|
||||
// part of their own HA-specific integration test tasks.
|
||||
integTest.runner {
|
||||
onlyIf { project.inFipsJvm == false }
|
||||
onlyIf { BuildParams.inFipsJvm == false }
|
||||
exclude('**/Ha*TestSuiteIT.class')
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import org.elasticsearch.gradle.MavenFilteringHack
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
import org.elasticsearch.gradle.test.AntFixture
|
||||
import org.elasticsearch.gradle.test.RestIntegTestTask
|
||||
|
||||
@ -99,7 +100,7 @@ String s3EC2BasePath = System.getenv("amazon_s3_base_path_ec2")
|
||||
String s3ECSBucket = System.getenv("amazon_s3_bucket_ecs")
|
||||
String s3ECSBasePath = System.getenv("amazon_s3_base_path_ecs")
|
||||
|
||||
boolean s3DisableChunkedEncoding = (new Random(Long.parseUnsignedLong(project.rootProject.testSeed.tokenize(':').get(0), 16))).nextBoolean()
|
||||
boolean s3DisableChunkedEncoding = (new Random(Long.parseUnsignedLong(BuildParams.testSeed.tokenize(':').get(0), 16))).nextBoolean()
|
||||
|
||||
// If all these variables are missing then we are testing against the internal fixture instead, which has the following
|
||||
// credentials hard-coded in.
|
||||
@ -141,7 +142,7 @@ task thirdPartyTest(type: Test) {
|
||||
systemProperty 'test.s3.account', s3PermanentAccessKey
|
||||
systemProperty 'test.s3.key', s3PermanentSecretKey
|
||||
systemProperty 'test.s3.bucket', s3PermanentBucket
|
||||
systemProperty 'test.s3.base', s3PermanentBasePath + "_third_party_tests_" + project.testSeed
|
||||
systemProperty 'test.s3.base', s3PermanentBasePath + "_third_party_tests_" + BuildParams.testSeed
|
||||
}
|
||||
|
||||
if (useFixture) {
|
||||
@ -225,7 +226,7 @@ File s3FixtureFile = new File(parentFixtures, 's3Fixture.properties')
|
||||
task s3FixtureProperties {
|
||||
outputs.file(s3FixtureFile)
|
||||
def s3FixtureOptions = [
|
||||
"tests.seed" : project.testSeed,
|
||||
"tests.seed" : BuildParams.testSeed,
|
||||
"s3Fixture.permanent_bucket_name" : s3PermanentBucket,
|
||||
"s3Fixture.permanent_key" : s3PermanentAccessKey,
|
||||
"s3Fixture.temporary_bucket_name" : s3TemporaryBucket,
|
||||
@ -248,7 +249,7 @@ task s3Fixture(type: AntFixture) {
|
||||
inputs.file(s3FixtureFile)
|
||||
|
||||
env 'CLASSPATH', "${ -> project.sourceSets.test.runtimeClasspath.asPath }"
|
||||
executable = new File(project.runtimeJavaHome, 'bin/java')
|
||||
executable = "${BuildParams.runtimeJavaHome}/bin/java"
|
||||
args 'org.elasticsearch.repositories.s3.AmazonS3Fixture', baseDir, s3FixtureFile.getAbsolutePath()
|
||||
}
|
||||
|
||||
@ -354,7 +355,7 @@ thirdPartyAudit.ignoreMissingClasses (
|
||||
|
||||
// jarhell with jdk (intentionally, because jaxb was removed from default modules in java 9)
|
||||
rootProject.globalInfo.ready {
|
||||
if (project.runtimeJavaVersion <= JavaVersion.VERSION_1_8) {
|
||||
if (BuildParams.runtimeJavaVersion <= JavaVersion.VERSION_1_8) {
|
||||
thirdPartyAudit.ignoreJarHellWithJDK(
|
||||
'javax.xml.bind.Binder',
|
||||
'javax.xml.bind.ContextFinder$1',
|
||||
|
@ -1,3 +1,5 @@
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
|
||||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
@ -154,7 +156,7 @@ thirdPartyAudit {
|
||||
)
|
||||
}
|
||||
rootProject.globalInfo.ready {
|
||||
if (project.inFipsJvm == false) {
|
||||
if (BuildParams.inFipsJvm == false) {
|
||||
// BouncyCastleFIPS provides this class, so the exclusion is invalid when running CI in
|
||||
// a FIPS JVM with BouncyCastleFIPS Provider
|
||||
thirdPartyAudit.ignoreMissingClasses(
|
||||
|
@ -1,3 +1,5 @@
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
|
||||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
@ -29,7 +31,7 @@ integTest.runner {
|
||||
systemProperty 'tests.security.manager', 'false'
|
||||
systemProperty 'tests.system_call_filter', 'false'
|
||||
nonInputProperties.systemProperty 'log', "${-> testClusters.integTest.singleNode().getServerLog()}"
|
||||
systemProperty 'runtime.java.home', "${project.runtimeJavaHome}"
|
||||
systemProperty 'runtime.java.home', BuildParams.runtimeJavaHome
|
||||
}
|
||||
|
||||
testClusters.integTest {
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
|
||||
import org.elasticsearch.gradle.Version
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
import org.elasticsearch.gradle.testclusters.RestTestRunnerTask
|
||||
import org.elasticsearch.gradle.testclusters.TestDistribution
|
||||
|
||||
@ -41,7 +42,7 @@ for (Version bwcVersion : bwcVersions.indexCompatible) {
|
||||
setting 'indices.memory.shard_inactive_time', '20m'
|
||||
setting 'http.content_type.required', 'true'
|
||||
setting 'path.repo', "${buildDir}/cluster/shared/repo/${baseName}"
|
||||
javaHome = project.file(project.ext.runtimeJavaHome)
|
||||
javaHome = BuildParams.runtimeJavaHome
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
import org.elasticsearch.gradle.Version
|
||||
import org.elasticsearch.gradle.VersionProperties
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
import org.elasticsearch.gradle.testclusters.RestTestRunnerTask
|
||||
|
||||
apply plugin: 'elasticsearch.testclusters'
|
||||
@ -58,7 +59,7 @@ for (Version bwcVersion : bwcVersions.wireCompatible) {
|
||||
numberOfNodes = 4
|
||||
|
||||
setting 'path.repo', "${buildDir}/cluster/shared/repo/${baseName}"
|
||||
javaHome = project.file(project.ext.runtimeJavaHome)
|
||||
javaHome = BuildParams.runtimeJavaHome
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
import org.elasticsearch.gradle.Version
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
import org.elasticsearch.gradle.testclusters.RestTestRunnerTask
|
||||
|
||||
apply plugin: 'elasticsearch.testclusters'
|
||||
@ -69,7 +70,7 @@ for (Version bwcVersion : bwcVersions.wireCompatible) {
|
||||
setting 'repositories.url.allowed_urls', 'http://snapshot.test*'
|
||||
setting 'path.repo', "${buildDir}/cluster/shared/repo/${baseName}"
|
||||
setting 'http.content_type.required', 'true'
|
||||
javaHome = project.file(project.ext.runtimeJavaHome)
|
||||
javaHome = BuildParams.runtimeJavaHome
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
import org.elasticsearch.gradle.Version
|
||||
import org.elasticsearch.gradle.VersionProperties
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
import org.elasticsearch.gradle.testclusters.RestTestRunnerTask
|
||||
|
||||
apply plugin: 'elasticsearch.testclusters'
|
||||
@ -36,7 +37,7 @@ for (Version bwcVersion : bwcVersions.indexCompatible) {
|
||||
"${baseName}" {
|
||||
version = bwcVersion.toString()
|
||||
setting 'http.content_type.required', 'true'
|
||||
javaHome = project.file(project.ext.runtimeJavaHome)
|
||||
javaHome = BuildParams.runtimeJavaHome
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
|
||||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
@ -57,7 +59,7 @@ if (!isEclipse && !isIdea) {
|
||||
|
||||
forbiddenApisJava9 {
|
||||
doFirst {
|
||||
if (project.runtimeJavaVersion < JavaVersion.VERSION_1_9) {
|
||||
if (BuildParams.runtimeJavaVersion < JavaVersion.VERSION_1_9) {
|
||||
targetCompatibility = JavaVersion.VERSION_1_9.getMajorVersion()
|
||||
}
|
||||
}
|
||||
@ -301,7 +303,7 @@ thirdPartyAudit.ignoreMissingClasses (
|
||||
)
|
||||
|
||||
rootProject.globalInfo.ready {
|
||||
if (project.runtimeJavaVersion > JavaVersion.VERSION_1_8) {
|
||||
if (BuildParams.runtimeJavaVersion > JavaVersion.VERSION_1_8) {
|
||||
thirdPartyAudit.ignoreMissingClasses 'javax.xml.bind.DatatypeConverter'
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import org.elasticsearch.gradle.LoggedExec
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
import org.elasticsearch.gradle.plugin.PluginBuildPlugin
|
||||
|
||||
import java.nio.charset.StandardCharsets
|
||||
@ -28,7 +29,7 @@ subprojects {
|
||||
dependsOn project.configurations.featureAwarePlugin
|
||||
outputs.file(successMarker)
|
||||
|
||||
executable = "${project.runtimeJavaHome}/bin/java"
|
||||
executable = "${BuildParams.runtimeJavaHome}/bin/java"
|
||||
|
||||
// default to main class files if such a source set exists
|
||||
final List files = []
|
||||
@ -45,7 +46,7 @@ subprojects {
|
||||
* anything above JDK 12 as JDK 13). So, to exclude JDK 14 until a newer version of ASM is available, we also have to exclude JDK
|
||||
* 13. See https://github.com/elastic/elasticsearch/issues/45927.
|
||||
*/
|
||||
Integer.parseInt(project.runtimeJavaVersion.getMajorVersion()) < 13
|
||||
Integer.parseInt(BuildParams.runtimeJavaVersion.majorVersion) < 13
|
||||
}
|
||||
doFirst {
|
||||
args('-cp', project.configurations.featureAwarePlugin.asPath, 'org.elasticsearch.xpack.test.feature_aware.FeatureAwareCheck')
|
||||
|
@ -1,3 +1,5 @@
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
|
||||
evaluationDependsOn(xpackModule('core'))
|
||||
|
||||
apply plugin: 'elasticsearch.esplugin'
|
||||
@ -292,7 +294,7 @@ thirdPartyAudit {
|
||||
}
|
||||
|
||||
rootProject.globalInfo.ready {
|
||||
if (project.runtimeJavaVersion > JavaVersion.VERSION_1_8) {
|
||||
if (BuildParams.runtimeJavaVersion > JavaVersion.VERSION_1_8) {
|
||||
thirdPartyAudit.ignoreMissingClasses(
|
||||
'javax.xml.bind.JAXBContext',
|
||||
'javax.xml.bind.JAXBElement',
|
||||
|
@ -1,4 +1,5 @@
|
||||
import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
|
||||
apply plugin: 'elasticsearch.build'
|
||||
|
||||
@ -19,7 +20,7 @@ dependencyLicenses {
|
||||
}
|
||||
|
||||
rootProject.globalInfo.ready {
|
||||
if (project.inFipsJvm) {
|
||||
if (BuildParams.inFipsJvm) {
|
||||
test.enabled = false
|
||||
testingConventions.enabled = false
|
||||
// Forbiden APIs non-portable checks fail because bouncy castle classes being used from the FIPS JDK since those are
|
||||
|
@ -1,5 +1,6 @@
|
||||
import org.elasticsearch.gradle.BuildPlugin
|
||||
import org.elasticsearch.gradle.LoggedExec
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection
|
||||
import javax.net.ssl.KeyManagerFactory
|
||||
@ -31,7 +32,7 @@ task createNodeKeyStore(type: LoggedExec) {
|
||||
delete nodeKeystore
|
||||
}
|
||||
}
|
||||
executable = new File(project.runtimeJavaHome, 'bin/keytool')
|
||||
executable = "${BuildParams.runtimeJavaHome}/bin/keytool"
|
||||
standardInput = new ByteArrayInputStream('FirstName LastName\nUnit\nOrganization\nCity\nState\nNL\nyes\n\n'.getBytes('UTF-8'))
|
||||
args '-genkey',
|
||||
'-alias', 'test-node',
|
||||
@ -56,7 +57,7 @@ task createClientKeyStore(type: LoggedExec) {
|
||||
delete clientKeyStore
|
||||
}
|
||||
}
|
||||
executable = new File(project.runtimeJavaHome, 'bin/keytool')
|
||||
executable = "${BuildParams.runtimeJavaHome}/bin/keytool"
|
||||
standardInput = new ByteArrayInputStream('FirstName LastName\nUnit\nOrganization\nCity\nState\nNL\nyes\n\n'.getBytes('UTF-8'))
|
||||
args '-genkey',
|
||||
'-alias', 'test-client',
|
||||
@ -82,7 +83,7 @@ task exportNodeCertificate(type: LoggedExec) {
|
||||
delete nodeCertificate
|
||||
}
|
||||
}
|
||||
executable = new File(project.runtimeJavaHome, 'bin/keytool')
|
||||
executable = "${BuildParams.runtimeJavaHome}/bin/keytool"
|
||||
args '-export',
|
||||
'-alias', 'test-node',
|
||||
'-keystore', nodeKeystore,
|
||||
@ -93,7 +94,7 @@ task exportNodeCertificate(type: LoggedExec) {
|
||||
// Import the node certificate in the client's keystore
|
||||
task importNodeCertificateInClientKeyStore(type: LoggedExec) {
|
||||
dependsOn createClientKeyStore, exportNodeCertificate
|
||||
executable = new File(project.runtimeJavaHome, 'bin/keytool')
|
||||
executable = "${BuildParams.runtimeJavaHome}/bin/keytool"
|
||||
args '-import',
|
||||
'-alias', 'test-node',
|
||||
'-keystore', clientKeyStore,
|
||||
@ -114,7 +115,7 @@ task exportClientCertificate(type: LoggedExec) {
|
||||
delete clientCertificate
|
||||
}
|
||||
}
|
||||
executable = new File(project.runtimeJavaHome, 'bin/keytool')
|
||||
executable = "${BuildParams.runtimeJavaHome}/bin/keytool"
|
||||
args '-export',
|
||||
'-alias', 'test-client',
|
||||
'-keystore', clientKeyStore,
|
||||
@ -125,7 +126,7 @@ task exportClientCertificate(type: LoggedExec) {
|
||||
// Import the client certificate in the node's keystore
|
||||
task importClientCertificateInNodeKeyStore(type: LoggedExec) {
|
||||
dependsOn createNodeKeyStore, exportClientCertificate
|
||||
executable = new File(project.runtimeJavaHome, 'bin/keytool')
|
||||
executable = "${BuildParams.runtimeJavaHome}/bin/keytool"
|
||||
args '-import',
|
||||
'-alias', 'test-client',
|
||||
'-keystore', nodeKeystore,
|
||||
@ -148,7 +149,7 @@ integTest.runner {
|
||||
// Do not attempt to form a cluster in a FIPS JVM, as doing so with a JKS keystore will fail.
|
||||
// TODO Revisit this when SQL CLI client can handle key/certificate instead of only Keystores.
|
||||
// https://github.com/elastic/elasticsearch/issues/32306
|
||||
project.inFipsJvm == false
|
||||
BuildParams.inFipsJvm == false
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
|
||||
/*
|
||||
* This project is named sql-cli because it is in the "org.elasticsearch.plugin"
|
||||
* group and it'd be super confusing for it to just be called "cli" there.
|
||||
@ -63,7 +65,7 @@ task runcli {
|
||||
description = 'Run the CLI and connect to elasticsearch running on 9200'
|
||||
dependsOn shadowJar
|
||||
doLast {
|
||||
List command = [new File(project.runtimeJavaHome, 'bin/java').absolutePath]
|
||||
List command = ["${BuildParams.runtimeJavaHome}/bin/java"]
|
||||
if ('true'.equals(System.getProperty('debug', 'false'))) {
|
||||
command += '-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000'
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
|
||||
evaluationDependsOn(xpackModule('core'))
|
||||
|
||||
apply plugin: 'elasticsearch.esplugin'
|
||||
@ -73,7 +75,7 @@ forbiddenPatterns {
|
||||
|
||||
// pulled in as external dependency to work on java 9
|
||||
rootProject.globalInfo.ready {
|
||||
if (project.runtimeJavaVersion <= JavaVersion.VERSION_1_8) {
|
||||
if (BuildParams.runtimeJavaVersion <= JavaVersion.VERSION_1_8) {
|
||||
thirdPartyAudit.ignoreJarHellWithJDK(
|
||||
// pulled in as external dependency to work on java 9
|
||||
'com.sun.activation.registries.LineTokenizer',
|
||||
|
@ -1,4 +1,5 @@
|
||||
import org.elasticsearch.gradle.Version
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
import org.elasticsearch.gradle.testclusters.RestTestRunnerTask
|
||||
|
||||
|
||||
@ -65,7 +66,7 @@ for (Version bwcVersion : bwcVersions.indexCompatible) {
|
||||
versions = [bwcVersion.toString(), project.version]
|
||||
numberOfNodes = 2
|
||||
setting 'path.repo', "${buildDir}/cluster/shared/repo/${baseName}"
|
||||
javaHome = project.file(project.ext.runtimeJavaHome)
|
||||
javaHome = BuildParams.runtimeJavaHome
|
||||
user username: "test_user", password: "x-pack-test-password"
|
||||
|
||||
setting 'path.repo', "${buildDir}/cluster/shared/repo/${baseName}"
|
||||
|
@ -1,3 +1,5 @@
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
|
||||
apply plugin: 'elasticsearch.testclusters'
|
||||
apply plugin: 'elasticsearch.standalone-rest-test'
|
||||
apply plugin: 'elasticsearch.rest-test'
|
||||
@ -38,7 +40,7 @@ testClusters.integTest {
|
||||
|
||||
// Workaround for JDK-8212885
|
||||
rootProject.globalInfo.ready {
|
||||
if (project.ext.runtimeJavaVersion.isJava12Compatible() == false) {
|
||||
if (BuildParams.runtimeJavaVersion.isJava12Compatible() == false) {
|
||||
setting 'reindex.ssl.supported_protocols', 'TLSv1.2'
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import org.elasticsearch.gradle.Version
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
import org.elasticsearch.gradle.testclusters.RestTestRunnerTask
|
||||
|
||||
apply plugin: 'elasticsearch.testclusters'
|
||||
@ -47,7 +48,7 @@ for (Version bwcVersion : bwcVersions.wireCompatible) {
|
||||
setting 'xpack.ml.enabled', 'false'
|
||||
setting 'xpack.watcher.enabled', 'false'
|
||||
setting 'xpack.license.self_generated.type', 'basic'
|
||||
javaHome = project.file(project.ext.runtimeJavaHome)
|
||||
javaHome = BuildParams.runtimeJavaHome
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import org.elasticsearch.gradle.Version
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
import org.elasticsearch.gradle.testclusters.RestTestRunnerTask
|
||||
|
||||
apply plugin: 'elasticsearch.testclusters'
|
||||
@ -53,7 +54,7 @@ for (Version bwcVersion : bwcVersions.wireCompatible) {
|
||||
setting 'xpack.watcher.enabled', 'false'
|
||||
setting 'xpack.license.self_generated.type', 'trial'
|
||||
|
||||
javaHome = project.file(project.ext.runtimeJavaHome)
|
||||
javaHome = BuildParams.runtimeJavaHome
|
||||
}
|
||||
|
||||
tasks.withType(RestTestRunnerTask).matching{it.name.startsWith(baseName)}.configureEach {
|
||||
|
@ -1,4 +1,5 @@
|
||||
import org.elasticsearch.gradle.Version
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
import org.elasticsearch.gradle.testclusters.RestTestRunnerTask
|
||||
|
||||
apply plugin: 'elasticsearch.testclusters'
|
||||
@ -100,7 +101,7 @@ for (Version bwcVersion : bwcVersions.wireCompatible) {
|
||||
jvmArgs '-da:org.elasticsearch.xpack.monitoring.exporter.http.HttpExportBulk'
|
||||
}
|
||||
|
||||
javaHome = project.file(project.ext.runtimeJavaHome)
|
||||
javaHome = BuildParams.runtimeJavaHome
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,9 @@
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import org.elasticsearch.gradle.info.BuildParams
|
||||
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Paths
|
||||
import org.elasticsearch.gradle.ElasticsearchDistribution
|
||||
@ -179,7 +182,7 @@ thirdPartyAudit.ignoreMissingClasses(
|
||||
)
|
||||
|
||||
rootProject.globalInfo.ready {
|
||||
if (project.runtimeJavaVersion <= JavaVersion.VERSION_1_8) {
|
||||
if (BuildParams.runtimeJavaVersion <= JavaVersion.VERSION_1_8) {
|
||||
thirdPartyAudit.ignoreJarHellWithJDK(
|
||||
'javax.xml.bind.Binder',
|
||||
'javax.xml.bind.ContextFinder$1',
|
||||
|
Loading…
x
Reference in New Issue
Block a user