@@ -115,8 +115,7 @@ class BuildPlugin implements Plugin<Project> {
115115 " Gradle ${ minimumGradleVersion} + is required to use elasticsearch.build plugin"
116116 )
117117 }
118- project. pluginManager. apply(' java' )
119- configureConfigurations(project)
118+ project. pluginManager. apply(' elasticsearch.java' )
120119 configureJars(project)
121120 configureJarManifest(project)
122121
@@ -127,12 +126,9 @@ class BuildPlugin implements Plugin<Project> {
127126
128127 configureRepositories(project)
129128 project. extensions. getByType(ExtraPropertiesExtension ). set(' versions' , VersionProperties . versions)
130- configureInputNormalization(project)
131- configureCompile(project)
132129 configureJavadoc(project)
133130 configureSourcesJar(project)
134131 configurePomGeneration(project)
135- configureTestTasks(project)
136132 configurePrecommit(project)
137133 configureDependenciesInfo(project)
138134 configureFips140(project)
@@ -356,72 +352,6 @@ class BuildPlugin implements Plugin<Project> {
356352 scmNode. appendNode(' url' , BuildParams . gitOrigin)
357353 }
358354
359- /**
360- * Apply runtime classpath input normalization so that changes in JAR manifests don't break build cacheability
361- */
362- static void configureInputNormalization (Project project ) {
363- project. normalization. runtimeClasspath. ignore(' META-INF/MANIFEST.MF' )
364- }
365-
366- /* * Adds compiler settings to the project */
367- static void configureCompile (Project project ) {
368- ExtraPropertiesExtension ext = project. extensions. getByType(ExtraPropertiesExtension )
369- ext. set(' compactProfile' , ' full' )
370-
371- project. extensions. getByType(JavaPluginExtension ). sourceCompatibility = BuildParams . minimumRuntimeVersion
372- project. extensions. getByType(JavaPluginExtension ). targetCompatibility = BuildParams . minimumRuntimeVersion
373-
374- project. afterEvaluate {
375- project. tasks. withType(JavaCompile ). configureEach({ JavaCompile compileTask ->
376- final JavaVersion targetCompatibilityVersion = JavaVersion . toVersion(compileTask. targetCompatibility)
377- // we only fork if the Gradle JDK is not the same as the compiler JDK
378- if (BuildParams . compilerJavaHome. canonicalPath == Jvm . current(). javaHome. canonicalPath) {
379- compileTask. options. fork = false
380- } else {
381- compileTask. options. fork = true
382- compileTask. options. forkOptions. javaHome = BuildParams . compilerJavaHome
383- }
384- /*
385- * -path because gradle will send in paths that don't always exist.
386- * -missing because we have tons of missing @returns and @param.
387- * -serial because we don't use java serialization.
388- */
389- // don't even think about passing args with -J-xxx, oracle will ask you to submit a bug report :)
390- // fail on all javac warnings
391- compileTask. options. compilerArgs << ' -Werror' << ' -Xlint:all,-path,-serial,-options,-deprecation,-try' << ' -Xdoclint:all' << ' -Xdoclint:-missing'
392-
393- // either disable annotation processor completely (default) or allow to enable them if an annotation processor is explicitly defined
394- if (compileTask. options. compilerArgs. contains(" -processor" ) == false ) {
395- compileTask. options. compilerArgs << ' -proc:none'
396- }
397-
398- compileTask. options. encoding = ' UTF-8'
399- compileTask. options. incremental = true
400-
401- // TODO: use native Gradle support for --release when available (cf. https://github.com/gradle/gradle/issues/2510)
402- compileTask. options. compilerArgs << ' --release' << targetCompatibilityVersion. majorVersion
403- } as Action<JavaCompile > )
404- // also apply release flag to groovy, which is used in build-tools
405- project. tasks. withType(GroovyCompile ). configureEach({ GroovyCompile compileTask ->
406- // we only fork if the Gradle JDK is not the same as the compiler JDK
407- if (BuildParams . compilerJavaHome. canonicalPath == Jvm . current(). javaHome. canonicalPath) {
408- compileTask. options. fork = false
409- } else {
410- compileTask. options. fork = true
411- compileTask. options. forkOptions. javaHome = BuildParams . compilerJavaHome
412- compileTask. options. compilerArgs << ' --release' << JavaVersion . toVersion(compileTask. targetCompatibility). majorVersion
413- }
414- } as Action<GroovyCompile > )
415- }
416-
417- project. pluginManager. withPlugin(' com.github.johnrengelman.shadow' ) {
418- // Ensure that when we are compiling against the "original" JAR that we also include any "shadow" dependencies on the compile classpath
419- project. configurations. getByName(ShadowBasePlugin . CONFIGURATION_NAME ). dependencies. all { Dependency dependency ->
420- project. configurations. getByName(JavaPlugin . API_ELEMENTS_CONFIGURATION_NAME ). dependencies. add(dependency)
421- }
422- }
423- }
424-
425355 static void configureJavadoc (Project project ) {
426356 // remove compiled classes from the Javadoc classpath: http://mail.openjdk.java.net/pipermail/javadoc-dev/2018-January/000400.html
427357 final List<File > classes = new ArrayList<> ()
@@ -554,145 +484,6 @@ class BuildPlugin implements Plugin<Project> {
554484 }
555485 }
556486
557- static void configureTestTasks (Project project ) {
558- // Default test task should run only unit tests
559- maybeConfigure(project. tasks, ' test' , Test ) { Test task ->
560- task. include ' **/*Tests.class'
561- }
562-
563- // none of this stuff is applicable to the `:buildSrc` project tests
564- if (project. path != ' :build-tools' ) {
565- File heapdumpDir = new File (project. buildDir, ' heapdump' )
566-
567- project. tasks. withType(Test ). configureEach { Test test ->
568- File testOutputDir = new File (test. reports. junitXml. getDestination(), " output" )
569-
570- ErrorReportingTestListener listener = new ErrorReportingTestListener (test. testLogging, testOutputDir)
571- test. extensions. add(ErrorReportingTestListener , ' errorReportingTestListener' , listener)
572- test. addTestOutputListener(listener)
573- test. addTestListener(listener)
574-
575- /*
576- * We use lazy-evaluated strings in order to configure system properties whose value will not be known until
577- * execution time (e.g. cluster port numbers). Adding these via the normal DSL doesn't work as these get treated
578- * as task inputs and therefore Gradle attempts to snapshot them before/after task execution. This fails due
579- * to the GStrings containing references to non-serializable objects.
580- *
581- * We bypass this by instead passing this system properties vi a CommandLineArgumentProvider. This has the added
582- * side-effect that these properties are NOT treated as inputs, therefore they don't influence things like the
583- * build cache key or up to date checking.
584- */
585- SystemPropertyCommandLineArgumentProvider nonInputProperties = new SystemPropertyCommandLineArgumentProvider ()
586-
587- test. doFirst {
588- project. mkdir(testOutputDir)
589- project. mkdir(heapdumpDir)
590- project. mkdir(test. workingDir)
591- project. mkdir(test. workingDir. toPath(). resolve(' temp' ))
592-
593- // TODO remove once jvm.options are added to test system properties
594- test. systemProperty (' java.locale.providers' ,' SPI,COMPAT' )
595- }
596- if (inFipsJvm()) {
597- project. dependencies. add(' testRuntimeOnly' , " org.bouncycastle:bc-fips:1.0.1" )
598- project. dependencies. add(' testRuntimeOnly' , " org.bouncycastle:bctls-fips:1.0.9" )
599- }
600- test. jvmArgumentProviders. add(nonInputProperties)
601- test. extensions. add(' nonInputProperties' , nonInputProperties)
602-
603- test. workingDir = project. file(" ${ project.buildDir} /testrun/${ test.name} " )
604- test. maxParallelForks = System . getProperty(' tests.jvms' , BuildParams . defaultParallel. toString()) as Integer
605-
606- test. exclude ' **/*$*.class'
607-
608- test. jvmArgs " -Xmx${ System.getProperty('tests.heap.size', '512m')} " ,
609- " -Xms${ System.getProperty('tests.heap.size', '512m')} " ,
610- ' --illegal-access=warn' ,
611- ' -XX:+HeapDumpOnOutOfMemoryError'
612-
613- test. jvmArgumentProviders. add({ [" -XX:HeapDumpPath=$heapdumpDir " ] } as CommandLineArgumentProvider )
614-
615- if (System . getProperty(' tests.jvm.argline' )) {
616- test. jvmArgs System . getProperty(' tests.jvm.argline' ). split(" " )
617- }
618-
619- if (Boolean . parseBoolean(System . getProperty(' tests.asserts' , ' true' ))) {
620- test. jvmArgs ' -ea' , ' -esa'
621- }
622-
623- test. systemProperties ' java.awt.headless' : ' true' ,
624- ' tests.gradle' : ' true' ,
625- ' tests.artifact' : project. name,
626- ' tests.task' : test. path,
627- ' tests.security.manager' : ' true' ,
628- ' jna.nosys' : ' true'
629-
630- // ignore changing test seed when build is passed -Dignore.tests.seed for cacheability experimentation
631- if (System . getProperty(' ignore.tests.seed' ) != null ) {
632- nonInputProperties. systemProperty(' tests.seed' , BuildParams . testSeed)
633- } else {
634- test. systemProperty(' tests.seed' , BuildParams . testSeed)
635- }
636-
637- // don't track these as inputs since they contain absolute paths and break cache relocatability
638- nonInputProperties. systemProperty(' gradle.dist.lib' , new File (project. class. location. toURI()). parent)
639- nonInputProperties. systemProperty(' gradle.worker.jar' , " ${ project.gradle.getGradleUserHomeDir()} /caches/${ project.gradle.gradleVersion} /workerMain/gradle-worker.jar" )
640- nonInputProperties. systemProperty(' gradle.user.home' , project. gradle. getGradleUserHomeDir())
641- // we use 'temp' relative to CWD since this is per JVM and tests are forbidden from writing to CWD
642- nonInputProperties. systemProperty(' java.io.tmpdir' , test. workingDir. toPath(). resolve(' temp' ))
643-
644- nonInputProperties. systemProperty(' compiler.java' , BuildParams . compilerJavaVersion. majorVersion)
645- nonInputProperties. systemProperty(' runtime.java' , BuildParams . runtimeJavaVersion. majorVersion)
646-
647- // TODO: remove setting logging level via system property
648- test. systemProperty ' tests.logger.level' , ' WARN'
649- System . getProperties(). each { key , value ->
650- if ((key. toString(). startsWith(' tests.' ) || key. toString(). startsWith(' es.' ))) {
651- test. systemProperty key. toString(), value
652- }
653- }
654-
655- // TODO: remove this once ctx isn't added to update script params in 7.0
656- test. systemProperty ' es.scripting.update.ctx_in_params' , ' false'
657-
658- // TODO: remove this property in 8.0
659- test. systemProperty ' es.search.rewrite_sort' , ' true'
660-
661- // TODO: remove this once cname is prepended to transport.publish_address by default in 8.0
662- test. systemProperty ' es.transport.cname_in_publish_address' , ' true'
663-
664- // Set netty system properties to the properties we configure in jvm.options
665- test. systemProperty(' io.netty.noUnsafe' , ' true' )
666- test. systemProperty(' io.netty.noKeySetOptimization' , ' true' )
667- test. systemProperty(' io.netty.recycler.maxCapacityPerThread' , ' 0' )
668-
669- test. testLogging { TestLoggingContainer logging ->
670- logging. showExceptions = true
671- logging. showCauses = true
672- logging. exceptionFormat = ' full'
673- }
674-
675- if (OS . current(). equals(OS . WINDOWS ) && System . getProperty(' tests.timeoutSuite' ) == null ) {
676- // override the suite timeout to 30 mins for windows, because it has the most inefficient filesystem known to man
677- test. systemProperty ' tests.timeoutSuite' , ' 1800000!'
678- }
679-
680- /*
681- * If this project builds a shadow JAR than any unit tests should test against that artifact instead of
682- * compiled class output and dependency jars. This better emulates the runtime environment of consumers.
683- */
684- project. pluginManager. withPlugin(' com.github.johnrengelman.shadow' ) {
685- // Remove output class files and any other dependencies from the test classpath, since the shadow JAR includes these
686- test. classpath - = project. extensions. getByType(SourceSetContainer ). getByName(SourceSet . MAIN_SOURCE_SET_NAME ). runtimeClasspath
687- // Add any "shadow" dependencies. These are dependencies that are *not* bundled into the shadow JAR
688- test. classpath + = project. configurations. getByName(ShadowBasePlugin . CONFIGURATION_NAME )
689- // Add the shadow JAR artifact itself
690- test. classpath + = project. files(project. tasks. named(' shadowJar' ))
691- }
692- }
693- }
694- }
695-
696487 private static configurePrecommit (Project project ) {
697488 TaskProvider precommit = PrecommitTasks . create(project, true )
698489 project. tasks. named(LifecycleBasePlugin . CHECK_TASK_NAME ). configure { it. dependsOn(precommit) }
0 commit comments