@@ -24,6 +24,7 @@ import com.github.jengelman.gradle.plugins.shadow.ShadowJavaPlugin
24
24
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
25
25
import groovy.transform.CompileStatic
26
26
import org.apache.commons.io.IOUtils
27
+ import org.elasticsearch.gradle.info.BuildParams
27
28
import org.elasticsearch.gradle.info.GlobalBuildInfoPlugin
28
29
import org.elasticsearch.gradle.info.GlobalInfoExtension
29
30
import org.elasticsearch.gradle.info.JavaHome
@@ -139,7 +140,6 @@ class BuildPlugin implements Plugin<Project> {
139
140
configurePrecommit(project)
140
141
configureDependenciesInfo(project)
141
142
142
-
143
143
configureFips140(project)
144
144
}
145
145
@@ -148,9 +148,8 @@ class BuildPlugin implements Plugin<Project> {
148
148
GlobalInfoExtension globalInfo = project. rootProject. extensions. getByType(GlobalInfoExtension )
149
149
// wait until global info is populated because we don't know if we are running in a fips jvm until execution time
150
150
globalInfo. ready {
151
- ExtraPropertiesExtension ext = project. extensions. getByType(ExtraPropertiesExtension )
152
151
// Common config when running with a FIPS-140 runtime JVM
153
- if (ext . has( ' inFipsJvm' ) && ext . get( ' inFipsJvm ' ) ) {
152
+ if (BuildParams . inFipsJvm) {
154
153
project. tasks. withType(Test ). configureEach { Test task ->
155
154
task. systemProperty ' javax.net.ssl.trustStorePassword' , ' password'
156
155
task. systemProperty ' javax.net.ssl.keyStorePassword' , ' password'
@@ -294,8 +293,7 @@ class BuildPlugin implements Plugin<Project> {
294
293
List<String > messages = []
295
294
Map<Integer , List<Task > > requiredJavaVersions = (Map<Integer , List<Task > > ) ext. get(' requiredJavaVersions' )
296
295
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 ) {
299
297
continue
300
298
}
301
299
List<String > tasks = entry. value. findAll { taskGraph. hasTask(it) }. collect { " ${ it.path} " . toString() }
@@ -310,8 +308,7 @@ class BuildPlugin implements Plugin<Project> {
310
308
})
311
309
} else if (ext. has(' requiredJavaVersions' ) == false || ext. get(' requiredJavaVersions' ) == null ) {
312
310
// 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 ) {
315
312
throw new GradleException (" JAVA${ version} _HOME required to run task:\n ${ task} " )
316
313
}
317
314
} else {
@@ -322,8 +319,7 @@ class BuildPlugin implements Plugin<Project> {
322
319
/* * A convenience method for getting java home for a version of java and requiring that version for the given task to execute */
323
320
static String getJavaHome (final Task task , final int version ) {
324
321
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
327
323
}
328
324
329
325
/**
@@ -487,20 +483,18 @@ class BuildPlugin implements Plugin<Project> {
487
483
ExtraPropertiesExtension ext = project. extensions. getByType(ExtraPropertiesExtension )
488
484
ext. set(' compactProfile' , ' full' )
489
485
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
492
488
493
489
project. afterEvaluate {
494
- File compilerJavaHome = ext. get(' compilerJavaHome' ) as File
495
-
496
490
project. tasks. withType(JavaCompile ). configureEach({ JavaCompile compileTask ->
497
491
final JavaVersion targetCompatibilityVersion = JavaVersion . toVersion(compileTask. targetCompatibility)
498
492
// 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) {
500
494
compileTask. options. fork = false
501
495
} else {
502
496
compileTask. options. fork = true
503
- compileTask. options. forkOptions. javaHome = compilerJavaHome
497
+ compileTask. options. forkOptions. javaHome = BuildParams . compilerJavaHome
504
498
}
505
499
/*
506
500
* -path because gradle will send in paths that don't always exist.
@@ -525,11 +519,11 @@ class BuildPlugin implements Plugin<Project> {
525
519
// also apply release flag to groovy, which is used in build-tools
526
520
project. tasks. withType(GroovyCompile ). configureEach({ GroovyCompile compileTask ->
527
521
// 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) {
529
523
compileTask. options. fork = false
530
524
} else {
531
525
compileTask. options. fork = true
532
- compileTask. options. forkOptions. javaHome = compilerJavaHome
526
+ compileTask. options. forkOptions. javaHome = BuildParams . compilerJavaHome
533
527
compileTask. options. compilerArgs << ' --release' << JavaVersion . toVersion(compileTask. targetCompatibility). majorVersion
534
528
}
535
529
} as Action<GroovyCompile > )
@@ -548,11 +542,10 @@ class BuildPlugin implements Plugin<Project> {
548
542
classes. add(javaCompile. destinationDir)
549
543
}
550
544
project. tasks. withType(Javadoc ). configureEach { Javadoc javadoc ->
551
- File compilerJavaHome = project. extensions. getByType(ExtraPropertiesExtension ). get(' compilerJavaHome' ) as File
552
545
// only explicitly set javadoc executable if compiler JDK is different from Gradle
553
546
// 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' )
556
549
}
557
550
javadoc. classpath = javadoc. getClasspath(). filter { f ->
558
551
return classes. contains(f) == false
@@ -607,13 +600,13 @@ class BuildPlugin implements Plugin<Project> {
607
600
jarTask. doFirst {
608
601
// this doFirst is added before the info plugin, therefore it will run
609
602
// 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
611
604
jarTask. manifest. attributes(
612
- ' Change' : ext . get( ' gitRevision' ) ,
605
+ ' Change' : BuildParams . gitRevision,
613
606
' X-Compile-Elasticsearch-Version' : VersionProperties . elasticsearch,
614
607
' X-Compile-Lucene-Version' : VersionProperties . lucene,
615
608
' X-Compile-Elasticsearch-Snapshot' : VersionProperties . isElasticsearchSnapshot(),
616
- ' Build-Date' : ext . get( ' buildDate' ) ,
609
+ ' Build-Date' : BuildParams . buildDate,
617
610
' Build-Java-Version' : compilerJavaVersion)
618
611
}
619
612
}
@@ -700,10 +693,10 @@ class BuildPlugin implements Plugin<Project> {
700
693
project. mkdir(heapdumpDir)
701
694
project. mkdir(test. workingDir)
702
695
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" )
705
698
} else {
706
- nonInputProperties. systemProperty(' runtime.java' , " ${ -> (ext.get(' runtimeJavaVersion') as JavaVersion).getMajorVersion() } " )
699
+ nonInputProperties. systemProperty(' runtime.java' , " ${ -> BuildParams. runtimeJavaVersion.majorVersion } " )
707
700
}
708
701
// TODO remove once jvm.options are added to test system properties
709
702
test. systemProperty (' java.locale.providers' ,' SPI,COMPAT' )
@@ -712,9 +705,9 @@ class BuildPlugin implements Plugin<Project> {
712
705
test. jvmArgumentProviders. add(nonInputProperties)
713
706
test. extensions. add(' nonInputProperties' , nonInputProperties)
714
707
715
- test. executable = " ${ ext.get(' runtimeJavaHome') } /bin/java"
708
+ test. executable = " ${ BuildParams. runtimeJavaHome} /bin/java"
716
709
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
718
711
719
712
test. exclude ' **/*$*.class'
720
713
@@ -744,17 +737,17 @@ class BuildPlugin implements Plugin<Project> {
744
737
745
738
// ignore changing test seed when build is passed -Dignore.tests.seed for cacheability experimentation
746
739
if (System . getProperty(' ignore.tests.seed' ) != null ) {
747
- nonInputProperties. systemProperty(' tests.seed' , project . property( ' testSeed' ) )
740
+ nonInputProperties. systemProperty(' tests.seed' , BuildParams . testSeed)
748
741
} else {
749
- test. systemProperty(' tests.seed' , project . property( ' testSeed' ) )
742
+ test. systemProperty(' tests.seed' , BuildParams . testSeed)
750
743
}
751
744
752
745
// don't track these as inputs since they contain absolute paths and break cache relocatability
753
746
nonInputProperties. systemProperty(' gradle.dist.lib' , new File (project. class. location. toURI()). parent)
754
747
nonInputProperties. systemProperty(' gradle.worker.jar' , " ${ project.gradle.getGradleUserHomeDir()} /caches/${ project.gradle.gradleVersion} /workerMain/gradle-worker.jar" )
755
748
nonInputProperties. systemProperty(' gradle.user.home' , project. gradle. getGradleUserHomeDir())
756
749
757
- nonInputProperties. systemProperty(' compiler.java' , " ${ -> (ext.get(' compilerJavaVersion') as JavaVersion).getMajorVersion() } " )
750
+ nonInputProperties. systemProperty(' compiler.java' , " ${ -> BuildParams. compilerJavaVersion.majorVersion } " )
758
751
759
752
// TODO: remove setting logging level via system property
760
753
test. systemProperty ' tests.logger.level' , ' WARN'
0 commit comments