@@ -24,6 +24,7 @@ import com.github.jengelman.gradle.plugins.shadow.ShadowJavaPlugin
2424import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2525import groovy.transform.CompileStatic
2626import org.apache.commons.io.IOUtils
27+ import org.elasticsearch.gradle.info.BuildParams
2728import org.elasticsearch.gradle.info.GlobalBuildInfoPlugin
2829import org.elasticsearch.gradle.info.GlobalInfoExtension
2930import org.elasticsearch.gradle.info.JavaHome
@@ -139,7 +140,6 @@ class BuildPlugin implements Plugin<Project> {
139140 configurePrecommit(project)
140141 configureDependenciesInfo(project)
141142
142-
143143 configureFips140(project)
144144 }
145145
@@ -148,9 +148,8 @@ class BuildPlugin implements Plugin<Project> {
148148 GlobalInfoExtension globalInfo = project. rootProject. extensions. getByType(GlobalInfoExtension )
149149 // wait until global info is populated because we don't know if we are running in a fips jvm until execution time
150150 globalInfo. ready {
151- ExtraPropertiesExtension ext = project. extensions. getByType(ExtraPropertiesExtension )
152151 // Common config when running with a FIPS-140 runtime JVM
153- if (ext . has( ' inFipsJvm' ) && ext . get( ' inFipsJvm ' ) ) {
152+ if (BuildParams . inFipsJvm) {
154153 project. tasks. withType(Test ). configureEach { Test task ->
155154 task. systemProperty ' javax.net.ssl.trustStorePassword' , ' password'
156155 task. systemProperty ' javax.net.ssl.keyStorePassword' , ' password'
@@ -294,8 +293,7 @@ class BuildPlugin implements Plugin<Project> {
294293 List<String > messages = []
295294 Map<Integer , List<Task > > requiredJavaVersions = (Map<Integer , List<Task > > ) ext. get(' requiredJavaVersions' )
296295 for (Map.Entry < Integer , List<Task > > entry : requiredJavaVersions) {
297- List<JavaHome > javaVersions = ext. get(' javaVersions' ) as List<JavaHome >
298- if (javaVersions. find { it. version == entry. key } != null ) {
296+ if (BuildParams . javaVersions. find { it. version == entry. key } != null ) {
299297 continue
300298 }
301299 List<String > tasks = entry. value. findAll { taskGraph. hasTask(it) }. collect { " ${ it.path} " . toString() }
@@ -310,8 +308,7 @@ class BuildPlugin implements Plugin<Project> {
310308 })
311309 } else if (ext. has(' requiredJavaVersions' ) == false || ext. get(' requiredJavaVersions' ) == null ) {
312310 // check directly if the version is present since we are already executing
313- List<JavaHome > javaVersions = ext. get(' javaVersions' ) as List<JavaHome >
314- if (javaVersions. find { it. version == version } == null ) {
311+ if (BuildParams . javaVersions. find { it. version == version } == null ) {
315312 throw new GradleException (" JAVA${ version} _HOME required to run task:\n ${ task} " )
316313 }
317314 } else {
@@ -322,8 +319,7 @@ class BuildPlugin implements Plugin<Project> {
322319 /* * A convenience method for getting java home for a version of java and requiring that version for the given task to execute */
323320 static String getJavaHome (final Task task , final int version ) {
324321 requireJavaHome(task, version)
325- List<JavaHome > javaVersions = task. project. property(' javaVersions' ) as List<JavaHome >
326- return javaVersions. find { it. version == version }. javaHome. absolutePath
322+ return BuildParams . javaVersions. find { it. version == version }. javaHome. absolutePath
327323 }
328324
329325 /**
@@ -487,20 +483,18 @@ class BuildPlugin implements Plugin<Project> {
487483 ExtraPropertiesExtension ext = project. extensions. getByType(ExtraPropertiesExtension )
488484 ext. set(' compactProfile' , ' full' )
489485
490- project. extensions. getByType(JavaPluginExtension ). sourceCompatibility = ext . get( ' minimumRuntimeVersion' ) as JavaVersion
491- project. extensions. getByType(JavaPluginExtension ). targetCompatibility = ext . get( ' minimumRuntimeVersion' ) as JavaVersion
486+ project. extensions. getByType(JavaPluginExtension ). sourceCompatibility = BuildParams . minimumRuntimeVersion
487+ project. extensions. getByType(JavaPluginExtension ). targetCompatibility = BuildParams . minimumRuntimeVersion
492488
493489 project. afterEvaluate {
494- File compilerJavaHome = ext. get(' compilerJavaHome' ) as File
495-
496490 project. tasks. withType(JavaCompile ). configureEach({ JavaCompile compileTask ->
497491 final JavaVersion targetCompatibilityVersion = JavaVersion . toVersion(compileTask. targetCompatibility)
498492 // we only fork if the Gradle JDK is not the same as the compiler JDK
499- if (compilerJavaHome. canonicalPath == Jvm . current(). javaHome. canonicalPath) {
493+ if (BuildParams . compilerJavaHome. canonicalPath == Jvm . current(). javaHome. canonicalPath) {
500494 compileTask. options. fork = false
501495 } else {
502496 compileTask. options. fork = true
503- compileTask. options. forkOptions. javaHome = compilerJavaHome
497+ compileTask. options. forkOptions. javaHome = BuildParams . compilerJavaHome
504498 }
505499 /*
506500 * -path because gradle will send in paths that don't always exist.
@@ -525,11 +519,11 @@ class BuildPlugin implements Plugin<Project> {
525519 // also apply release flag to groovy, which is used in build-tools
526520 project. tasks. withType(GroovyCompile ). configureEach({ GroovyCompile compileTask ->
527521 // we only fork if the Gradle JDK is not the same as the compiler JDK
528- if (compilerJavaHome. canonicalPath == Jvm . current(). javaHome. canonicalPath) {
522+ if (BuildParams . compilerJavaHome. canonicalPath == Jvm . current(). javaHome. canonicalPath) {
529523 compileTask. options. fork = false
530524 } else {
531525 compileTask. options. fork = true
532- compileTask. options. forkOptions. javaHome = compilerJavaHome
526+ compileTask. options. forkOptions. javaHome = BuildParams . compilerJavaHome
533527 compileTask. options. compilerArgs << ' --release' << JavaVersion . toVersion(compileTask. targetCompatibility). majorVersion
534528 }
535529 } as Action<GroovyCompile > )
@@ -548,11 +542,10 @@ class BuildPlugin implements Plugin<Project> {
548542 classes. add(javaCompile. destinationDir)
549543 }
550544 project. tasks. withType(Javadoc ). configureEach { Javadoc javadoc ->
551- File compilerJavaHome = project. extensions. getByType(ExtraPropertiesExtension ). get(' compilerJavaHome' ) as File
552545 // only explicitly set javadoc executable if compiler JDK is different from Gradle
553546 // this ensures better cacheability as setting ths input to an absolute path breaks portability
554- if (Files . isSameFile(compilerJavaHome. toPath(), Jvm . current(). getJavaHome(). toPath()) == false ) {
555- javadoc. executable = new File (compilerJavaHome, ' bin/javadoc' )
547+ if (Files . isSameFile(BuildParams . compilerJavaHome. toPath(), Jvm . current(). getJavaHome(). toPath()) == false ) {
548+ javadoc. executable = new File (BuildParams . compilerJavaHome, ' bin/javadoc' )
556549 }
557550 javadoc. classpath = javadoc. getClasspath(). filter { f ->
558551 return classes. contains(f) == false
@@ -607,13 +600,13 @@ class BuildPlugin implements Plugin<Project> {
607600 jarTask. doFirst {
608601 // this doFirst is added before the info plugin, therefore it will run
609602 // after the doFirst added by the info plugin, and we can override attributes
610- JavaVersion compilerJavaVersion = ext . get( ' compilerJavaVersion' ) as JavaVersion
603+ JavaVersion compilerJavaVersion = BuildParams . compilerJavaVersion
611604 jarTask. manifest. attributes(
612- ' Change' : ext . get( ' gitRevision' ) ,
605+ ' Change' : BuildParams . gitRevision,
613606 ' X-Compile-Elasticsearch-Version' : VersionProperties . elasticsearch,
614607 ' X-Compile-Lucene-Version' : VersionProperties . lucene,
615608 ' X-Compile-Elasticsearch-Snapshot' : VersionProperties . isElasticsearchSnapshot(),
616- ' Build-Date' : ext . get( ' buildDate' ) ,
609+ ' Build-Date' : BuildParams . buildDate,
617610 ' Build-Java-Version' : compilerJavaVersion)
618611 }
619612 }
@@ -700,10 +693,10 @@ class BuildPlugin implements Plugin<Project> {
700693 project. mkdir(heapdumpDir)
701694 project. mkdir(test. workingDir)
702695
703- if (project . property( ' inFipsJvm' ) ) {
704- nonInputProperties. systemProperty(' runtime.java' , " ${ -> (ext.get(' runtimeJavaVersion') as JavaVersion).getMajorVersion() } FIPS" )
696+ if (BuildParams . inFipsJvm) {
697+ nonInputProperties. systemProperty(' runtime.java' , " ${ -> BuildParams. runtimeJavaVersion.majorVersion } FIPS" )
705698 } else {
706- nonInputProperties. systemProperty(' runtime.java' , " ${ -> (ext.get(' runtimeJavaVersion') as JavaVersion).getMajorVersion() } " )
699+ nonInputProperties. systemProperty(' runtime.java' , " ${ -> BuildParams. runtimeJavaVersion.majorVersion } " )
707700 }
708701 // TODO remove once jvm.options are added to test system properties
709702 test. systemProperty (' java.locale.providers' ,' SPI,COMPAT' )
@@ -712,9 +705,9 @@ class BuildPlugin implements Plugin<Project> {
712705 test. jvmArgumentProviders. add(nonInputProperties)
713706 test. extensions. add(' nonInputProperties' , nonInputProperties)
714707
715- test. executable = " ${ ext.get(' runtimeJavaHome') } /bin/java"
708+ test. executable = " ${ BuildParams. runtimeJavaHome} /bin/java"
716709 test. workingDir = project. file(" ${ project.buildDir} /testrun/${ test.name} " )
717- test. maxParallelForks = System . getProperty(' tests.jvms' , project . rootProject . extensions . extraProperties . get( ' defaultParallel' ) . toString()) as Integer
710+ test. maxParallelForks = System . getProperty(' tests.jvms' , BuildParams . defaultParallel. toString()) as Integer
718711
719712 test. exclude ' **/*$*.class'
720713
@@ -744,17 +737,17 @@ class BuildPlugin implements Plugin<Project> {
744737
745738 // ignore changing test seed when build is passed -Dignore.tests.seed for cacheability experimentation
746739 if (System . getProperty(' ignore.tests.seed' ) != null ) {
747- nonInputProperties. systemProperty(' tests.seed' , project . property( ' testSeed' ) )
740+ nonInputProperties. systemProperty(' tests.seed' , BuildParams . testSeed)
748741 } else {
749- test. systemProperty(' tests.seed' , project . property( ' testSeed' ) )
742+ test. systemProperty(' tests.seed' , BuildParams . testSeed)
750743 }
751744
752745 // don't track these as inputs since they contain absolute paths and break cache relocatability
753746 nonInputProperties. systemProperty(' gradle.dist.lib' , new File (project. class. location. toURI()). parent)
754747 nonInputProperties. systemProperty(' gradle.worker.jar' , " ${ project.gradle.getGradleUserHomeDir()} /caches/${ project.gradle.gradleVersion} /workerMain/gradle-worker.jar" )
755748 nonInputProperties. systemProperty(' gradle.user.home' , project. gradle. getGradleUserHomeDir())
756749
757- nonInputProperties. systemProperty(' compiler.java' , " ${ -> (ext.get(' compilerJavaVersion') as JavaVersion).getMajorVersion() } " )
750+ nonInputProperties. systemProperty(' compiler.java' , " ${ -> BuildParams. compilerJavaVersion.majorVersion } " )
758751
759752 // TODO: remove setting logging level via system property
760753 test. systemProperty ' tests.logger.level' , ' WARN'
0 commit comments