Fix deprecation warning in fips.gradle (#60802)

This commit is contained in:
Rene Groeschke 2020-08-06 10:08:26 +02:00
parent d593c963f3
commit f8a63bbdb5
No known key found for this signature in database
GPG Key ID: B1782D97CBC64567
1 changed files with 17 additions and 10 deletions

View File

@ -5,13 +5,15 @@ import org.elasticsearch.gradle.testclusters.ElasticsearchCluster
// Common config when running with a FIPS-140 runtime JVM // Common config when running with a FIPS-140 runtime JVM
if (BuildParams.inFipsJvm) { if (BuildParams.inFipsJvm) {
allprojects { allprojects {
File fipsResourcesDir = new File(project.buildDir, 'fips-resources') File fipsResourcesDir = new File(project.buildDir, 'fips-resources')
boolean java8 = BuildParams.runtimeJavaVersion == JavaVersion.VERSION_1_8 boolean java8 = BuildParams.runtimeJavaVersion == JavaVersion.VERSION_1_8
File fipsSecurity = new File(fipsResourcesDir, "fips_java${java8 ? '8' : ''}.security") File fipsSecurity = new File(fipsResourcesDir, "fips_java${java8 ? '8' : ''}.security")
File fipsPolicy = new File(fipsResourcesDir, "fips_java${java8 ? '8' : ''}.policy") File fipsPolicy = new File(fipsResourcesDir, "fips_java${java8 ? '8' : ''}.policy")
File fipsTrustStore = new File(fipsResourcesDir, 'cacerts.bcfks') File fipsTrustStore = new File(fipsResourcesDir, 'cacerts.bcfks')
project.pluginManager.withPlugin('elasticsearch.java') { pluginManager.withPlugin('elasticsearch.java') {
TaskProvider<ExportElasticsearchBuildResourcesTask> fipsResourcesTask = project.tasks.register('fipsResources', ExportElasticsearchBuildResourcesTask) TaskProvider<ExportElasticsearchBuildResourcesTask> fipsResourcesTask = project.tasks.register('fipsResources', ExportElasticsearchBuildResourcesTask)
fipsResourcesTask.configure { fipsResourcesTask.configure {
outputDir = fipsResourcesDir outputDir = fipsResourcesDir
@ -19,17 +21,22 @@ if (BuildParams.inFipsJvm) {
copy fipsPolicy.name copy fipsPolicy.name
copy 'cacerts.bcfks' copy 'cacerts.bcfks'
} }
// This configuration can be removed once system modules are available
configurations.create('extraFipsJars')
dependencies {
extraFipsJars 'org.bouncycastle:bc-fips:1.0.1'
extraFipsJars 'org.bouncycastle:bctls-fips:1.0.9'
}
pluginManager.withPlugin("elasticsearch.testclusters") { pluginManager.withPlugin("elasticsearch.testclusters") {
testClusters.all { afterEvaluate {
for (File dep : project.configurations.extraFipsJars.files) { // This afterEvaluate hooks is required to avoid deprecated configuration resolution
extraJarFile dep // This configuration can be removed once system modules are available
def extraFipsJars = configurations.detachedConfiguration(dependencies.create('org.bouncycastle:bc-fips:1.0.1'),
dependencies.create('org.bouncycastle:bctls-fips:1.0.9'),
)
testClusters.all {
extraFipsJars.files.each {
extraJarFile it
}
} }
}
testClusters.all {
extraConfigFile "fips_java.security", fipsSecurity extraConfigFile "fips_java.security", fipsSecurity
extraConfigFile "fips_java.policy", fipsPolicy extraConfigFile "fips_java.policy", fipsPolicy
extraConfigFile "cacerts.bcfks", fipsTrustStore extraConfigFile "cacerts.bcfks", fipsTrustStore