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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion benchmarks/build.gradle
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -140,7 +141,6 @@ class BuildPlugin implements Plugin<Project> {
configurePrecommit(project)
configureDependenciesInfo(project)


configureFips140(project)
}

Expand All @@ -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'
Expand Down Expand Up @@ -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() }
Expand All @@ -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 {
Expand All @@ -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
}

/**
Expand Down Expand Up @@ -488,28 +484,26 @@ 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')
}
}
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 {
Expand Down Expand Up @@ -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>)
Expand All @@ -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
Expand Down Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -718,29 +711,29 @@ 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')
}
}

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'

Expand Down Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 }))
}
}

Expand All @@ -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()
}
Expand Down Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
}
Expand Down Expand Up @@ -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')
}
Expand Down
Loading