@@ -26,16 +26,15 @@ import groovy.transform.CompileStatic
26
26
import org.apache.commons.io.IOUtils
27
27
import org.elasticsearch.gradle.info.BuildParams
28
28
import org.elasticsearch.gradle.info.GlobalBuildInfoPlugin
29
- import org.elasticsearch.gradle.info.GlobalInfoExtension
30
29
import org.elasticsearch.gradle.info.JavaHome
31
30
import org.elasticsearch.gradle.precommit.DependencyLicensesTask
32
31
import org.elasticsearch.gradle.precommit.PrecommitTasks
33
32
import org.elasticsearch.gradle.test.ErrorReportingTestListener
34
33
import org.elasticsearch.gradle.testclusters.ElasticsearchCluster
35
34
import org.elasticsearch.gradle.testclusters.TestClustersPlugin
36
- import org.gradle.api.Action
37
35
import org.elasticsearch.gradle.testclusters.TestDistribution
38
- import org.elasticsearch.gradle.tool.Boilerplate
36
+ import org.elasticsearch.gradle.util.GradleUtils
37
+ import org.gradle.api.Action
39
38
import org.gradle.api.GradleException
40
39
import org.gradle.api.InvalidUserDataException
41
40
import org.gradle.api.JavaVersion
@@ -84,7 +83,7 @@ import org.gradle.util.GradleVersion
84
83
import java.nio.charset.StandardCharsets
85
84
import java.nio.file.Files
86
85
87
- import static org.elasticsearch.gradle.tool.Boilerplate .maybeConfigure
86
+ import static org.elasticsearch.gradle.util.GradleUtils .maybeConfigure
88
87
89
88
/**
90
89
* Encapsulates build configuration for elasticsearch projects.
@@ -146,7 +145,7 @@ class BuildPlugin implements Plugin<Project> {
146
145
// Common config when running with a FIPS-140 runtime JVM
147
146
if (inFipsJvm()) {
148
147
// This configuration can be removed once system modules are available
149
- Boilerplate . maybeCreate(project. configurations, ' extraJars' ) {
148
+ GradleUtils . maybeCreate(project. configurations, ' extraJars' ) {
150
149
project. dependencies. add(' extraJars' , " org.bouncycastle:bc-fips:1.0.1" )
151
150
project. dependencies. add(' extraJars' , " org.bouncycastle:bctls-fips:1.0.9" )
152
151
}
@@ -156,7 +155,6 @@ class BuildPlugin implements Plugin<Project> {
156
155
File securityPolicy = buildResources. copy(" fips_java.policy" )
157
156
File security8Policy = buildResources. copy(" fips_java8.policy" )
158
157
File bcfksKeystore = buildResources. copy(" cacerts.bcfks" )
159
- GlobalInfoExtension globalInfo = project. rootProject. extensions. getByType(GlobalInfoExtension )
160
158
project. pluginManager. withPlugin(" elasticsearch.testclusters" ) {
161
159
NamedDomainObjectContainer<ElasticsearchCluster > testClusters = project. extensions. findByName(TestClustersPlugin . EXTENSION_NAME ) as NamedDomainObjectContainer<ElasticsearchCluster >
162
160
if (testClusters != null ) {
@@ -165,14 +163,12 @@ class BuildPlugin implements Plugin<Project> {
165
163
for (File dep : project. getConfigurations(). getByName(" extraJars" ). getFiles()) {
166
164
cluster. extraJarFile(dep)
167
165
}
168
- globalInfo. ready {
169
- if (BuildParams . runtimeJavaVersion > JavaVersion . VERSION_1_8 ) {
170
- cluster. extraConfigFile(" fips_java.security" , securityProperties)
171
- cluster. extraConfigFile(" fips_java.policy" , securityPolicy)
172
- } else {
173
- cluster. extraConfigFile(" fips_java.security" , security8Properties)
174
- cluster. extraConfigFile(" fips_java.policy" , security8Policy)
175
- }
166
+ if (BuildParams . runtimeJavaVersion > JavaVersion . VERSION_1_8 ) {
167
+ cluster. extraConfigFile(" fips_java.security" , securityProperties)
168
+ cluster. extraConfigFile(" fips_java.policy" , securityPolicy)
169
+ } else {
170
+ cluster. extraConfigFile(" fips_java.security" , security8Properties)
171
+ cluster. extraConfigFile(" fips_java.policy" , security8Policy)
176
172
}
177
173
cluster. extraConfigFile(" cacerts.bcfks" , bcfksKeystore)
178
174
cluster. systemProperty(' java.security.properties' , ' =${ES_PATH_CONF}/fips_java.security' )
@@ -188,16 +184,14 @@ class BuildPlugin implements Plugin<Project> {
188
184
}
189
185
project. tasks. withType(Test ). configureEach { Test task ->
190
186
task. dependsOn(buildResources)
191
- globalInfo. ready {
192
- // Using the key==value format to override default JVM security settings and policy
193
- // see also: https://docs.oracle.com/javase/8/docs/technotes/guides/security/PolicyFiles.html
194
- if (BuildParams . runtimeJavaVersion > JavaVersion . VERSION_1_8 ) {
195
- task. systemProperty(' java.security.properties' , String . format(Locale . ROOT , " =%s" , securityProperties. toString()))
196
- task. systemProperty(' java.security.policy' , String . format(Locale . ROOT , " =%s" , securityPolicy. toString()))
197
- } else {
198
- task. systemProperty(' java.security.properties' , String . format(Locale . ROOT , " =%s" , security8Properties. toString()))
199
- task. systemProperty(' java.security.policy' , String . format(Locale . ROOT , " =%s" , security8Policy. toString()))
200
- }
187
+ // Using the key==value format to override default JVM security settings and policy
188
+ // see also: https://docs.oracle.com/javase/8/docs/technotes/guides/security/PolicyFiles.html
189
+ if (BuildParams . runtimeJavaVersion > JavaVersion . VERSION_1_8 ) {
190
+ task. systemProperty(' java.security.properties' , String . format(Locale . ROOT , " =%s" , securityProperties. toString()))
191
+ task. systemProperty(' java.security.policy' , String . format(Locale . ROOT , " =%s" , securityPolicy. toString()))
192
+ } else {
193
+ task. systemProperty(' java.security.properties' , String . format(Locale . ROOT , " =%s" , security8Properties. toString()))
194
+ task. systemProperty(' java.security.policy' , String . format(Locale . ROOT , " =%s" , security8Policy. toString()))
201
195
}
202
196
task. systemProperty(' javax.net.ssl.trustStorePassword' , ' password' )
203
197
task. systemProperty(' javax.net.ssl.keyStorePassword' , ' password' )
@@ -258,7 +252,7 @@ class BuildPlugin implements Plugin<Project> {
258
252
static String getJavaHome (final Task task , final int version ) {
259
253
requireJavaHome(task, version)
260
254
JavaHome java = BuildParams . javaVersions. find { it. version == version }
261
- return java == null ? null : java. javaHome. absolutePath
255
+ return java == null ? null : java. javaHome. get() . absolutePath
262
256
}
263
257
264
258
/**
@@ -407,7 +401,7 @@ class BuildPlugin implements Plugin<Project> {
407
401
dependencyNode. appendNode(' groupId' , dependency. group)
408
402
dependencyNode. appendNode(' artifactId' , dependency. getDependencyProject(). convention. getPlugin(BasePluginConvention ). archivesBaseName)
409
403
dependencyNode. appendNode(' version' , dependency. version)
410
- dependencyNode. appendNode(' scope' , ' runtime ' )
404
+ dependencyNode. appendNode(' scope' , ' compile ' )
411
405
}
412
406
}
413
407
}
@@ -426,13 +420,10 @@ class BuildPlugin implements Plugin<Project> {
426
420
/* * Adds compiler settings to the project */
427
421
static void configureCompile (Project project ) {
428
422
ExtraPropertiesExtension ext = project. extensions. getByType(ExtraPropertiesExtension )
429
- GlobalInfoExtension globalBuildInfo = project. rootProject. extensions. getByType(GlobalInfoExtension )
430
- globalBuildInfo. ready {
431
- if (BuildParams . compilerJavaVersion < JavaVersion . VERSION_1_10 ) {
432
- ext. set(' compactProfile' , ' compact3' )
433
- } else {
434
- ext. set(' compactProfile' , ' full' )
435
- }
423
+ if (BuildParams . compilerJavaVersion < JavaVersion . VERSION_1_10 ) {
424
+ ext. set(' compactProfile' , ' compact3' )
425
+ } else {
426
+ ext. set(' compactProfile' , ' full' )
436
427
}
437
428
ext. set(' compactProfile' , ' full' )
438
429
@@ -450,12 +441,10 @@ class BuildPlugin implements Plugin<Project> {
450
441
compileTask. options. forkOptions. javaHome = BuildParams . compilerJavaHome
451
442
}
452
443
if (targetCompatibilityVersion == JavaVersion . VERSION_1_8 ) {
453
- globalBuildInfo. ready {
454
- // compile with compact 3 profile by default
455
- // NOTE: this is just a compile time check: does not replace testing with a compact3 JRE
456
- if (ext. get(' compactProfile' ) != ' full' ) {
457
- compileTask. options. compilerArgs << ' -profile' << ext. get(' compactProfile' ). toString()
458
- }
444
+ // compile with compact 3 profile by default
445
+ // NOTE: this is just a compile time check: does not replace testing with a compact3 JRE
446
+ if (ext. get(' compactProfile' ) != ' full' ) {
447
+ compileTask. options. compilerArgs << ' -profile' << ext. get(' compactProfile' ). toString()
459
448
}
460
449
}
461
450
/*
@@ -657,16 +646,13 @@ class BuildPlugin implements Plugin<Project> {
657
646
project. mkdir(heapdumpDir)
658
647
project. mkdir(test. workingDir)
659
648
project. mkdir(test. workingDir. toPath(). resolve(' temp' ))
660
-
661
- if (BuildParams . runtimeJavaVersion >= JavaVersion . VERSION_1_9 ) {
662
- test. jvmArgs ' --illegal-access=warn'
663
- }
664
- // TODO remove once jvm.options are added to test system properties
665
- if (BuildParams . runtimeJavaVersion == JavaVersion . VERSION_1_8 ) {
666
- test. systemProperty (' java.locale.providers' ,' SPI,JRE' )
667
- } else if (BuildParams . runtimeJavaVersion >= JavaVersion . VERSION_1_9 ) {
668
- test. systemProperty (' java.locale.providers' ,' SPI,COMPAT' )
669
- }
649
+ }
650
+ // TODO remove once jvm.options are added to test system properties
651
+ if (BuildParams . runtimeJavaVersion == JavaVersion . VERSION_1_8 ) {
652
+ test. systemProperty (' java.locale.providers' ,' SPI,JRE' )
653
+ } else if (BuildParams . runtimeJavaVersion >= JavaVersion . VERSION_1_9 ) {
654
+ test. systemProperty (' java.locale.providers' ,' SPI,COMPAT' )
655
+ test. jvmArgs ' --illegal-access=warn'
670
656
}
671
657
if (inFipsJvm()) {
672
658
project. dependencies. add(' testRuntimeOnly' , " org.bouncycastle:bc-fips:1.0.1" )
0 commit comments