From 70cfedf54225753f8c0b6485d97dd2be3ef5696b Mon Sep 17 00:00:00 2001 From: Mark Vieira Date: Mon, 23 Mar 2020 15:30:10 -0700 Subject: [PATCH] Refactor global build info plugin to leverage JavaInstallationRegistry (#54026) This commit removes the configuration time vs execution time distinction with regards to certain BuildParms properties. Because of the cost of determining Java versions for configuration JDK locations we deferred this until execution time. This had two main downsides. First, we had to implement all this build logic in tasks, which required a bunch of additional plumbing and complexity. Second, because some information wasn't known during configuration time, we had to nest any build logic that depended on this in awkward callbacks. We now defer to the JavaInstallationRegistry recently added in Gradle. This utility uses a much more efficient method for probing Java installations vs our jrunscript implementation. This, combined with some optimizations to avoid probing the current JVM as well as deferring some evaluation via Providers when probing installations for BWC builds we can maintain effectively the same configuration time performance while removing a bunch of complexity and runtime cost (snapshotting inputs for the GenerateGlobalBuildInfoTask was very expensive). The end result should be a much more responsive build execution in almost all scenarios. (cherry picked from commit ecdbd37f2e0f0447ed574b306adb64c19adc3ce1) --- CONTRIBUTING.md | 3 - build.gradle | 2 +- .../elasticsearch/gradle/BuildPlugin.groovy | 84 +++-- .../gradle/precommit/PrecommitTasks.groovy | 17 +- .../gradle/DistributionDownloadPlugin.java | 6 +- .../gradle/JdkDownloadPlugin.java | 4 +- .../info/GenerateGlobalBuildInfoTask.java | 293 ------------------ .../gradle/info/GlobalBuildInfoPlugin.java | 247 +++++++++------ .../gradle/info/GlobalInfoExtension.java | 12 - .../gradle/info/PrintGlobalBuildInfoTask.java | 75 ----- .../gradle/precommit/FilePermissionsTask.java | 4 +- .../precommit/TestingConventionsTasks.java | 10 +- .../gradle/test/DistroTestPlugin.java | 4 +- .../gradle/test/rest/CopyRestApiTask.java | 4 +- .../gradle/test/rest/CopyRestTestsTask.java | 4 +- .../testclusters/RestTestRunnerTask.java | 4 +- .../testclusters/TestClustersPlugin.java | 6 +- .../testfixtures/TestFixturesPlugin.java | 4 +- .../GradleUtils.java} | 4 +- .../elasticsearch/gradle/{ => util}/Util.java | 27 +- .../gradle/vagrant/VagrantMachine.java | 2 +- .../gradle/info/BuildParams.java | 38 +-- .../elasticsearch/gradle/info/JavaHome.java | 18 +- gradle/ide.gradle | 2 +- libs/core/build.gradle | 8 +- plugins/discovery-azure-classic/build.gradle | 234 +++++++------- plugins/discovery-ec2/build.gradle | 12 +- plugins/repository-hdfs/build.gradle | 6 +- plugins/repository-s3/build.gradle | 218 +++++++------ server/build.gradle | 6 +- x-pack/plugin/security/build.gradle | 30 +- x-pack/plugin/watcher/build.gradle | 78 +++-- .../reindex-tests-with-security/build.gradle | 6 +- x-pack/snapshot-tool/build.gradle | 214 +++++++------ 34 files changed, 654 insertions(+), 1032 deletions(-) delete mode 100644 buildSrc/src/main/java/org/elasticsearch/gradle/info/GenerateGlobalBuildInfoTask.java delete mode 100644 buildSrc/src/main/java/org/elasticsearch/gradle/info/GlobalInfoExtension.java delete mode 100644 buildSrc/src/main/java/org/elasticsearch/gradle/info/PrintGlobalBuildInfoTask.java rename buildSrc/src/main/java/org/elasticsearch/gradle/{tool/Boilerplate.java => util/GradleUtils.java} (98%) rename buildSrc/src/main/java/org/elasticsearch/gradle/{ => util}/Util.java (60%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 638c56e5168..74f97dafd2c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -103,9 +103,6 @@ be used to test against other JDKs as well, this is not only limited to JDK 8. > Note: It is also required to have `JAVA8_HOME`, `JAVA9_HOME`, `JAVA10_HOME` and `JAVA11_HOME`, and `JAVA12_HOME` available so that the tests can pass. -> Warning: do not use `sdkman` for Java installations which do not have proper -`jrunscript` for jdk distributions. - Elasticsearch uses the Gradle wrapper for its build. You can execute Gradle using the wrapper via the `gradlew` script on Unix systems or `gradlew.bat` script on Windows in the root of the repository. The examples below show the diff --git a/build.gradle b/build.gradle index edc37d47b9f..2aa4d4c09f8 100644 --- a/build.gradle +++ b/build.gradle @@ -31,7 +31,7 @@ import org.gradle.plugins.ide.eclipse.model.SourceFolder import org.gradle.util.DistributionLocator import org.gradle.util.GradleVersion -import static org.elasticsearch.gradle.tool.Boilerplate.maybeConfigure +import static org.elasticsearch.gradle.util.GradleUtils.maybeConfigure plugins { id 'lifecycle-base' diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index e797fbf4bf4..5a00f2a7683 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -26,16 +26,15 @@ import groovy.transform.CompileStatic import org.apache.commons.io.IOUtils import org.elasticsearch.gradle.info.BuildParams import org.elasticsearch.gradle.info.GlobalBuildInfoPlugin -import org.elasticsearch.gradle.info.GlobalInfoExtension import org.elasticsearch.gradle.info.JavaHome import org.elasticsearch.gradle.precommit.DependencyLicensesTask import org.elasticsearch.gradle.precommit.PrecommitTasks import org.elasticsearch.gradle.test.ErrorReportingTestListener import org.elasticsearch.gradle.testclusters.ElasticsearchCluster import org.elasticsearch.gradle.testclusters.TestClustersPlugin -import org.gradle.api.Action import org.elasticsearch.gradle.testclusters.TestDistribution -import org.elasticsearch.gradle.tool.Boilerplate +import org.elasticsearch.gradle.util.GradleUtils +import org.gradle.api.Action import org.gradle.api.GradleException import org.gradle.api.InvalidUserDataException import org.gradle.api.JavaVersion @@ -84,7 +83,7 @@ import org.gradle.util.GradleVersion import java.nio.charset.StandardCharsets import java.nio.file.Files -import static org.elasticsearch.gradle.tool.Boilerplate.maybeConfigure +import static org.elasticsearch.gradle.util.GradleUtils.maybeConfigure /** * Encapsulates build configuration for elasticsearch projects. @@ -146,7 +145,7 @@ class BuildPlugin implements Plugin { // Common config when running with a FIPS-140 runtime JVM if (inFipsJvm()) { // This configuration can be removed once system modules are available - Boilerplate.maybeCreate(project.configurations, 'extraJars') { + GradleUtils.maybeCreate(project.configurations, 'extraJars') { project.dependencies.add('extraJars', "org.bouncycastle:bc-fips:1.0.1") project.dependencies.add('extraJars', "org.bouncycastle:bctls-fips:1.0.9") } @@ -156,7 +155,6 @@ class BuildPlugin implements Plugin { File securityPolicy = buildResources.copy("fips_java.policy") File security8Policy = buildResources.copy("fips_java8.policy") File bcfksKeystore = buildResources.copy("cacerts.bcfks") - GlobalInfoExtension globalInfo = project.rootProject.extensions.getByType(GlobalInfoExtension) project.pluginManager.withPlugin("elasticsearch.testclusters") { NamedDomainObjectContainer testClusters = project.extensions.findByName(TestClustersPlugin.EXTENSION_NAME) as NamedDomainObjectContainer if (testClusters != null) { @@ -165,14 +163,12 @@ class BuildPlugin implements Plugin { for (File dep : project.getConfigurations().getByName("extraJars").getFiles()) { cluster.extraJarFile(dep) } - globalInfo.ready { - if (BuildParams.runtimeJavaVersion > JavaVersion.VERSION_1_8) { - cluster.extraConfigFile("fips_java.security", securityProperties) - cluster.extraConfigFile("fips_java.policy", securityPolicy) - } else { - cluster.extraConfigFile("fips_java.security", security8Properties) - cluster.extraConfigFile("fips_java.policy", security8Policy) - } + if (BuildParams.runtimeJavaVersion > JavaVersion.VERSION_1_8) { + cluster.extraConfigFile("fips_java.security", securityProperties) + cluster.extraConfigFile("fips_java.policy", securityPolicy) + } else { + cluster.extraConfigFile("fips_java.security", security8Properties) + cluster.extraConfigFile("fips_java.policy", security8Policy) } cluster.extraConfigFile("cacerts.bcfks", bcfksKeystore) cluster.systemProperty('java.security.properties', '=${ES_PATH_CONF}/fips_java.security') @@ -188,16 +184,14 @@ class BuildPlugin implements Plugin { } project.tasks.withType(Test).configureEach { Test task -> task.dependsOn(buildResources) - globalInfo.ready { - // Using the key==value format to override default JVM security settings and policy - // see also: https://docs.oracle.com/javase/8/docs/technotes/guides/security/PolicyFiles.html - if (BuildParams.runtimeJavaVersion > JavaVersion.VERSION_1_8) { - task.systemProperty('java.security.properties', String.format(Locale.ROOT, "=%s", securityProperties.toString())) - task.systemProperty('java.security.policy', String.format(Locale.ROOT, "=%s", securityPolicy.toString())) - } else { - task.systemProperty('java.security.properties', String.format(Locale.ROOT, "=%s", security8Properties.toString())) - task.systemProperty('java.security.policy', String.format(Locale.ROOT, "=%s", security8Policy.toString())) - } + // Using the key==value format to override default JVM security settings and policy + // see also: https://docs.oracle.com/javase/8/docs/technotes/guides/security/PolicyFiles.html + if (BuildParams.runtimeJavaVersion > JavaVersion.VERSION_1_8) { + task.systemProperty('java.security.properties', String.format(Locale.ROOT, "=%s", securityProperties.toString())) + task.systemProperty('java.security.policy', String.format(Locale.ROOT, "=%s", securityPolicy.toString())) + } else { + task.systemProperty('java.security.properties', String.format(Locale.ROOT, "=%s", security8Properties.toString())) + task.systemProperty('java.security.policy', String.format(Locale.ROOT, "=%s", security8Policy.toString())) } task.systemProperty('javax.net.ssl.trustStorePassword', 'password') task.systemProperty('javax.net.ssl.keyStorePassword', 'password') @@ -258,7 +252,7 @@ class BuildPlugin implements Plugin { static String getJavaHome(final Task task, final int version) { requireJavaHome(task, version) JavaHome java = BuildParams.javaVersions.find { it.version == version } - return java == null ? null : java.javaHome.absolutePath + return java == null ? null : java.javaHome.get().absolutePath } /** @@ -407,7 +401,7 @@ class BuildPlugin implements Plugin { dependencyNode.appendNode('groupId', dependency.group) dependencyNode.appendNode('artifactId', dependency.getDependencyProject().convention.getPlugin(BasePluginConvention).archivesBaseName) dependencyNode.appendNode('version', dependency.version) - dependencyNode.appendNode('scope', 'runtime') + dependencyNode.appendNode('scope', 'compile') } } } @@ -426,13 +420,10 @@ class BuildPlugin implements Plugin { /** Adds compiler settings to the project */ static void configureCompile(Project project) { ExtraPropertiesExtension ext = project.extensions.getByType(ExtraPropertiesExtension) - GlobalInfoExtension globalBuildInfo = project.rootProject.extensions.getByType(GlobalInfoExtension) - globalBuildInfo.ready { - if (BuildParams.compilerJavaVersion < JavaVersion.VERSION_1_10) { - ext.set('compactProfile', 'compact3') - } else { - ext.set('compactProfile', 'full') - } + if (BuildParams.compilerJavaVersion < JavaVersion.VERSION_1_10) { + ext.set('compactProfile', 'compact3') + } else { + ext.set('compactProfile', 'full') } ext.set('compactProfile', 'full') @@ -450,12 +441,10 @@ class BuildPlugin implements Plugin { compileTask.options.forkOptions.javaHome = BuildParams.compilerJavaHome } if (targetCompatibilityVersion == JavaVersion.VERSION_1_8) { - globalBuildInfo.ready { - // compile with compact 3 profile by default - // NOTE: this is just a compile time check: does not replace testing with a compact3 JRE - if (ext.get('compactProfile') != 'full') { - compileTask.options.compilerArgs << '-profile' << ext.get('compactProfile').toString() - } + // compile with compact 3 profile by default + // NOTE: this is just a compile time check: does not replace testing with a compact3 JRE + if (ext.get('compactProfile') != 'full') { + compileTask.options.compilerArgs << '-profile' << ext.get('compactProfile').toString() } } /* @@ -657,16 +646,13 @@ class BuildPlugin implements Plugin { project.mkdir(heapdumpDir) project.mkdir(test.workingDir) project.mkdir(test.workingDir.toPath().resolve('temp')) - - if (BuildParams.runtimeJavaVersion >= JavaVersion.VERSION_1_9) { - test.jvmArgs '--illegal-access=warn' - } - //TODO remove once jvm.options are added to test system properties - if (BuildParams.runtimeJavaVersion == JavaVersion.VERSION_1_8) { - test.systemProperty ('java.locale.providers','SPI,JRE') - } else if (BuildParams.runtimeJavaVersion >= JavaVersion.VERSION_1_9) { - test.systemProperty ('java.locale.providers','SPI,COMPAT') - } + } + //TODO remove once jvm.options are added to test system properties + if (BuildParams.runtimeJavaVersion == JavaVersion.VERSION_1_8) { + test.systemProperty ('java.locale.providers','SPI,JRE') + } else if (BuildParams.runtimeJavaVersion >= JavaVersion.VERSION_1_9) { + test.systemProperty ('java.locale.providers','SPI,COMPAT') + test.jvmArgs '--illegal-access=warn' } if (inFipsJvm()) { project.dependencies.add('testRuntimeOnly', "org.bouncycastle:bc-fips:1.0.1") diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/PrecommitTasks.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/PrecommitTasks.groovy index 52f98330ee5..d95514f975a 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/PrecommitTasks.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/PrecommitTasks.groovy @@ -143,16 +143,13 @@ class PrecommitTasks { ExportElasticsearchBuildResourcesTask buildResources = project.tasks.getByName('buildResources') project.tasks.withType(CheckForbiddenApis).configureEach { dependsOn(buildResources) - doFirst { - // we need to defer this configuration since we don't know the runtime java version until execution time - targetCompatibility = BuildParams.runtimeJavaVersion.majorVersion - if (BuildParams.runtimeJavaVersion > JavaVersion.VERSION_13) { - project.logger.warn( - "Forbidden APIs does not support Java versions past 13. Will use the signatures from 13 for {}.", - BuildParams.runtimeJavaVersion - ) - targetCompatibility = JavaVersion.VERSION_13.majorVersion - } + targetCompatibility = BuildParams.runtimeJavaVersion.majorVersion + if (BuildParams.runtimeJavaVersion > JavaVersion.VERSION_13) { + project.logger.warn( + "Forbidden APIs does not support Java versions past 13. Will use the signatures from 13 for {}.", + BuildParams.runtimeJavaVersion + ) + targetCompatibility = JavaVersion.VERSION_13.majorVersion } bundledSignatures = [ "jdk-unsafe", "jdk-deprecated", "jdk-non-portable", "jdk-system-out" diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/DistributionDownloadPlugin.java b/buildSrc/src/main/java/org/elasticsearch/gradle/DistributionDownloadPlugin.java index 24888e683f6..9b07e5dcbb3 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/DistributionDownloadPlugin.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/DistributionDownloadPlugin.java @@ -26,7 +26,7 @@ import org.elasticsearch.gradle.docker.DockerSupportPlugin; import org.elasticsearch.gradle.docker.DockerSupportService; import org.elasticsearch.gradle.info.BuildParams; import org.elasticsearch.gradle.info.GlobalBuildInfoPlugin; -import org.elasticsearch.gradle.tool.Boilerplate; +import org.elasticsearch.gradle.util.GradleUtils; import org.gradle.api.GradleException; import org.gradle.api.NamedDomainObjectContainer; import org.gradle.api.Plugin; @@ -53,7 +53,7 @@ import java.util.Map; import java.util.concurrent.Callable; import java.util.function.Supplier; -import static org.elasticsearch.gradle.Util.capitalize; +import static org.elasticsearch.gradle.util.Util.capitalize; /** * A plugin to manage getting and extracting distributions of Elasticsearch. @@ -78,7 +78,7 @@ public class DistributionDownloadPlugin implements Plugin { project.getRootProject().getPluginManager().apply(GlobalBuildInfoPlugin.class); project.getRootProject().getPluginManager().apply(DockerSupportPlugin.class); - Provider dockerSupport = Boilerplate.getBuildService( + Provider dockerSupport = GradleUtils.getBuildService( project.getGradle().getSharedServices(), DockerSupportPlugin.DOCKER_SUPPORT_SERVICE_NAME ); diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/JdkDownloadPlugin.java b/buildSrc/src/main/java/org/elasticsearch/gradle/JdkDownloadPlugin.java index 795b99c3dfc..4d341c86fa1 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/JdkDownloadPlugin.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/JdkDownloadPlugin.java @@ -47,8 +47,8 @@ import java.util.Map; import java.util.concurrent.Callable; import java.util.stream.StreamSupport; -import static org.elasticsearch.gradle.tool.Boilerplate.findByName; -import static org.elasticsearch.gradle.tool.Boilerplate.maybeCreate; +import static org.elasticsearch.gradle.util.GradleUtils.findByName; +import static org.elasticsearch.gradle.util.GradleUtils.maybeCreate; public class JdkDownloadPlugin implements Plugin { diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/info/GenerateGlobalBuildInfoTask.java b/buildSrc/src/main/java/org/elasticsearch/gradle/info/GenerateGlobalBuildInfoTask.java deleted file mode 100644 index 75ae735e8a9..00000000000 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/info/GenerateGlobalBuildInfoTask.java +++ /dev/null @@ -1,293 +0,0 @@ -package org.elasticsearch.gradle.info; - -import org.elasticsearch.gradle.OS; -import org.gradle.api.DefaultTask; -import org.gradle.api.GradleException; -import org.gradle.api.JavaVersion; -import org.gradle.api.file.RegularFileProperty; -import org.gradle.api.model.ObjectFactory; -import org.gradle.api.tasks.CacheableTask; -import org.gradle.api.tasks.Input; -import org.gradle.api.tasks.InputDirectory; -import org.gradle.api.tasks.Nested; -import org.gradle.api.tasks.OutputFile; -import org.gradle.api.tasks.PathSensitive; -import org.gradle.api.tasks.PathSensitivity; -import org.gradle.api.tasks.TaskAction; -import org.gradle.internal.jvm.Jvm; -import org.gradle.process.ExecResult; - -import javax.inject.Inject; -import java.io.BufferedWriter; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.UncheckedIOException; -import java.io.Writer; -import java.nio.file.Files; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; - -import static java.nio.charset.StandardCharsets.UTF_8; - -@CacheableTask -public class GenerateGlobalBuildInfoTask extends DefaultTask { - private JavaVersion minimumCompilerVersion; - private JavaVersion minimumRuntimeVersion; - private File compilerJavaHome; - private File runtimeJavaHome; - private List javaVersions; - private final RegularFileProperty outputFile; - private final RegularFileProperty compilerVersionFile; - private final RegularFileProperty runtimeVersionFile; - - @Inject - public GenerateGlobalBuildInfoTask(ObjectFactory objectFactory) { - this.outputFile = objectFactory.fileProperty(); - this.compilerVersionFile = objectFactory.fileProperty(); - this.runtimeVersionFile = objectFactory.fileProperty(); - } - - @Input - public JavaVersion getMinimumCompilerVersion() { - return minimumCompilerVersion; - } - - public void setMinimumCompilerVersion(JavaVersion minimumCompilerVersion) { - this.minimumCompilerVersion = minimumCompilerVersion; - } - - @Input - public JavaVersion getMinimumRuntimeVersion() { - return minimumRuntimeVersion; - } - - public void setMinimumRuntimeVersion(JavaVersion minimumRuntimeVersion) { - this.minimumRuntimeVersion = minimumRuntimeVersion; - } - - @InputDirectory - @PathSensitive(PathSensitivity.RELATIVE) - public File getCompilerJavaHome() { - return compilerJavaHome; - } - - public void setCompilerJavaHome(File compilerJavaHome) { - this.compilerJavaHome = compilerJavaHome; - } - - @InputDirectory - @PathSensitive(PathSensitivity.RELATIVE) - public File getRuntimeJavaHome() { - return runtimeJavaHome; - } - - public void setRuntimeJavaHome(File runtimeJavaHome) { - this.runtimeJavaHome = runtimeJavaHome; - } - - @Nested - public List getJavaVersions() { - return javaVersions; - } - - public void setJavaVersions(List javaVersions) { - this.javaVersions = javaVersions; - } - - @OutputFile - public RegularFileProperty getOutputFile() { - return outputFile; - } - - @OutputFile - public RegularFileProperty getCompilerVersionFile() { - return compilerVersionFile; - } - - @OutputFile - public RegularFileProperty getRuntimeVersionFile() { - return runtimeVersionFile; - } - - @TaskAction - public void generate() { - String javaVendorVersion = System.getProperty("java.vendor.version", System.getProperty("java.vendor")); - String gradleJavaVersion = System.getProperty("java.version"); - String gradleJavaVersionDetails = javaVendorVersion - + " " - + gradleJavaVersion - + " [" - + System.getProperty("java.vm.name") - + " " - + System.getProperty("java.vm.version") - + "]"; - - String compilerJavaVersionDetails = gradleJavaVersionDetails; - JavaVersion compilerJavaVersionEnum = JavaVersion.current(); - String runtimeJavaVersionDetails = gradleJavaVersionDetails; - JavaVersion runtimeJavaVersionEnum = JavaVersion.current(); - File gradleJavaHome = Jvm.current().getJavaHome(); - - try { - if (Files.isSameFile(compilerJavaHome.toPath(), gradleJavaHome.toPath()) == false) { - if (compilerJavaHome.exists()) { - compilerJavaVersionDetails = findJavaVersionDetails(compilerJavaHome); - compilerJavaVersionEnum = JavaVersion.toVersion(findJavaSpecificationVersion(compilerJavaHome)); - } else { - throw new RuntimeException("Compiler Java home path of '" + compilerJavaHome + "' does not exist"); - } - } - - if (Files.isSameFile(runtimeJavaHome.toPath(), gradleJavaHome.toPath()) == false) { - if (runtimeJavaHome.exists()) { - runtimeJavaVersionDetails = findJavaVersionDetails(runtimeJavaHome); - runtimeJavaVersionEnum = JavaVersion.toVersion(findJavaSpecificationVersion(runtimeJavaHome)); - } else { - throw new RuntimeException("Runtime Java home path of '" + compilerJavaHome + "' does not exist"); - } - } - } catch (IOException e) { - throw new UncheckedIOException(e); - } - - try (BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile.getAsFile().get()))) { - final String osName = System.getProperty("os.name"); - final String osVersion = System.getProperty("os.version"); - final String osArch = System.getProperty("os.arch"); - final JavaVersion parsedVersion = JavaVersion.toVersion(gradleJavaVersion); - - writer.write(" Gradle Version : " + getProject().getGradle().getGradleVersion() + "\n"); - writer.write(" OS Info : " + osName + " " + osVersion + " (" + osArch + ")\n"); - - if (gradleJavaVersionDetails.equals(compilerJavaVersionDetails) == false - || gradleJavaVersionDetails.equals(runtimeJavaVersionDetails) == false) { - writer.write(" Compiler JDK Version : " + compilerJavaVersionEnum + " (" + compilerJavaVersionDetails + ")\n"); - writer.write(" Compiler java.home : " + compilerJavaHome + "\n"); - writer.write(" Runtime JDK Version : " + runtimeJavaVersionEnum + " (" + runtimeJavaVersionDetails + ")\n"); - writer.write(" Runtime java.home : " + runtimeJavaHome + "\n"); - writer.write(" Gradle JDK Version : " + parsedVersion + " (" + gradleJavaVersionDetails + ")\n"); - writer.write(" Gradle java.home : " + gradleJavaHome); - } else { - writer.write(" JDK Version : " + parsedVersion + " (" + gradleJavaVersionDetails + ")\n"); - writer.write(" JAVA_HOME : " + gradleJavaHome); - } - } catch (IOException e) { - throw new UncheckedIOException(e); - } - - // enforce Java version - if (compilerJavaVersionEnum.compareTo(minimumCompilerVersion) < 0) { - String message = String.format( - Locale.ROOT, - "The compiler java.home must be set to a JDK installation directory for Java %s but is [%s] " + "corresponding to [%s]", - minimumCompilerVersion, - compilerJavaHome, - compilerJavaVersionEnum - ); - throw new GradleException(message); - } - - if (runtimeJavaVersionEnum.compareTo(minimumRuntimeVersion) < 0) { - String message = String.format( - Locale.ROOT, - "The runtime java.home must be set to a JDK installation directory for Java %s but is [%s] " + "corresponding to [%s]", - minimumRuntimeVersion, - runtimeJavaHome, - runtimeJavaVersionEnum - ); - throw new GradleException(message); - } - - for (JavaHome javaVersion : javaVersions) { - File javaHome = javaVersion.getJavaHome(); - if (javaHome == null) { - continue; - } - JavaVersion javaVersionEnum = JavaVersion.toVersion(findJavaSpecificationVersion(javaHome)); - JavaVersion expectedJavaVersionEnum; - int version = javaVersion.getVersion(); - if (version < 9) { - expectedJavaVersionEnum = JavaVersion.toVersion("1." + version); - } else { - expectedJavaVersionEnum = JavaVersion.toVersion(Integer.toString(version)); - } - if (javaVersionEnum != expectedJavaVersionEnum) { - String message = String.format( - Locale.ROOT, - "The environment variable JAVA%d_HOME must be set to a JDK installation directory for Java" - + " %s but is [%s] corresponding to [%s]", - version, - expectedJavaVersionEnum, - javaHome, - javaVersionEnum - ); - throw new GradleException(message); - } - } - - writeToFile(compilerVersionFile.getAsFile().get(), compilerJavaVersionEnum.name()); - writeToFile(runtimeVersionFile.getAsFile().get(), runtimeJavaVersionEnum.name()); - } - - private void writeToFile(File file, String content) { - try (Writer writer = new FileWriter(file)) { - writer.write(content); - } catch (IOException e) { - throw new UncheckedIOException(e); - } - } - - /** - * Finds printable java version of the given JAVA_HOME - */ - private String findJavaVersionDetails(File javaHome) { - String versionInfoScript = "print(" - + "java.lang.System.getProperty(\"java.vendor.version\", java.lang.System.getProperty(\"java.vendor\")) + \" \" + " - + "java.lang.System.getProperty(\"java.version\") + \" [\" + " - + "java.lang.System.getProperty(\"java.vm.name\") + \" \" + " - + "java.lang.System.getProperty(\"java.vm.version\") + \"]\");"; - return runJavaAsScript(javaHome, versionInfoScript).trim(); - } - - /** - * Finds the parsable java specification version - */ - private String findJavaSpecificationVersion(File javaHome) { - String versionScript = "print(java.lang.System.getProperty(\"java.specification.version\"));"; - return runJavaAsScript(javaHome, versionScript); - } - - /** - * Runs the given javascript using jjs from the jdk, and returns the output - */ - private String runJavaAsScript(File javaHome, String script) { - ByteArrayOutputStream stdout = new ByteArrayOutputStream(); - ByteArrayOutputStream stderr = new ByteArrayOutputStream(); - if (OS.current() == OS.WINDOWS) { - // gradle/groovy does not properly escape the double quote for windows - script = script.replace("\"", "\\\""); - } - File jrunscriptPath = new File(javaHome, "bin/jrunscript"); - String finalScript = script; - ExecResult result = getProject().exec(spec -> { - spec.setExecutable(jrunscriptPath); - spec.args("-e", finalScript); - spec.setStandardOutput(stdout); - spec.setErrorOutput(stderr); - spec.setIgnoreExitValue(true); - }); - - if (result.getExitValue() != 0) { - getLogger().error("STDOUT:"); - Arrays.stream(stdout.toString(UTF_8).split(System.getProperty("line.separator"))).forEach(getLogger()::error); - getLogger().error("STDERR:"); - Arrays.stream(stderr.toString(UTF_8).split(System.getProperty("line.separator"))).forEach(getLogger()::error); - result.rethrowFailure(); - } - return stdout.toString(UTF_8).trim(); - } - -} diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/info/GlobalBuildInfoPlugin.java b/buildSrc/src/main/java/org/elasticsearch/gradle/info/GlobalBuildInfoPlugin.java index 431e66e9cde..21642b30c04 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/info/GlobalBuildInfoPlugin.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/info/GlobalBuildInfoPlugin.java @@ -1,18 +1,27 @@ package org.elasticsearch.gradle.info; import org.elasticsearch.gradle.OS; +import org.elasticsearch.gradle.util.Util; import org.gradle.api.GradleException; import org.gradle.api.JavaVersion; import org.gradle.api.Plugin; import org.gradle.api.Project; +import org.gradle.api.logging.Logger; +import org.gradle.api.logging.Logging; +import org.gradle.api.model.ObjectFactory; +import org.gradle.api.provider.Provider; +import org.gradle.api.provider.ProviderFactory; import org.gradle.internal.jvm.Jvm; +import org.gradle.jvm.toolchain.JavaInstallation; +import org.gradle.jvm.toolchain.JavaInstallationRegistry; +import org.gradle.util.GradleVersion; +import javax.inject.Inject; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileReader; import java.io.IOException; -import java.io.InputStreamReader; import java.io.UncheckedIOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -33,23 +42,146 @@ import java.util.stream.Collectors; import java.util.stream.Stream; public class GlobalBuildInfoPlugin implements Plugin { - private static final String GLOBAL_INFO_EXTENSION_NAME = "globalInfo"; + private static final Logger LOGGER = Logging.getLogger(GlobalBuildInfoPlugin.class); private static Integer _defaultParallel = null; + private final JavaInstallationRegistry javaInstallationRegistry; + private final ObjectFactory objects; + private final ProviderFactory providers; + + @Inject + public GlobalBuildInfoPlugin(JavaInstallationRegistry javaInstallationRegistry, ObjectFactory objects, ProviderFactory providers) { + this.javaInstallationRegistry = javaInstallationRegistry; + this.objects = objects; + this.providers = providers; + } + @Override public void apply(Project project) { if (project != project.getRootProject()) { throw new IllegalStateException(this.getClass().getName() + " can only be applied to the root project."); } - GlobalInfoExtension extension = project.getExtensions().create(GLOBAL_INFO_EXTENSION_NAME, GlobalInfoExtension.class); - - JavaVersion minimumCompilerVersion = JavaVersion.toVersion(getResourceContents("/minimumCompilerVersion")); - JavaVersion minimumRuntimeVersion = JavaVersion.toVersion(getResourceContents("/minimumRuntimeVersion")); + JavaVersion minimumCompilerVersion = JavaVersion.toVersion(Util.getResourceContents("/minimumCompilerVersion")); + JavaVersion minimumRuntimeVersion = JavaVersion.toVersion(Util.getResourceContents("/minimumRuntimeVersion")); File compilerJavaHome = findCompilerJavaHome(); File runtimeJavaHome = findRuntimeJavaHome(compilerJavaHome); + // Initialize global build parameters + BuildParams.init(params -> { + params.reset(); + params.setCompilerJavaHome(compilerJavaHome); + params.setRuntimeJavaHome(runtimeJavaHome); + params.setCompilerJavaVersion(determineJavaVersion("compiler java.home", compilerJavaHome, minimumCompilerVersion)); + params.setRuntimeJavaVersion(determineJavaVersion("runtime java.home", runtimeJavaHome, minimumRuntimeVersion)); + params.setIsRutimeJavaHomeSet(compilerJavaHome.equals(runtimeJavaHome) == false); + params.setJavaVersions(getAvailableJavaVersions(minimumCompilerVersion)); + params.setMinimumCompilerVersion(minimumCompilerVersion); + params.setMinimumRuntimeVersion(minimumRuntimeVersion); + params.setGradleJavaVersion(Jvm.current().getJavaVersion()); + params.setGitRevision(gitRevision(project.getRootProject().getRootDir())); + params.setBuildDate(ZonedDateTime.now(ZoneOffset.UTC)); + params.setTestSeed(getTestSeed()); + params.setIsCi(System.getenv("JENKINS_URL") != null); + params.setIsInternal(GlobalBuildInfoPlugin.class.getResource("/buildSrc.marker") != null); + params.setDefaultParallel(findDefaultParallel(project)); + params.setInFipsJvm(Util.getBooleanProperty("tests.fips.enabled", false)); + params.setIsSnapshotBuild(Util.getBooleanProperty("build.snapshot", true)); + }); + + // Print global build info header just before task execution + project.getGradle().getTaskGraph().whenReady(graph -> logGlobalBuildInfo()); + } + + private void logGlobalBuildInfo() { + final String osName = System.getProperty("os.name"); + final String osVersion = System.getProperty("os.version"); + final String osArch = System.getProperty("os.arch"); + final Jvm gradleJvm = Jvm.current(); + final String gradleJvmDetails = getJavaInstallation(gradleJvm.getJavaHome()).getImplementationName(); + + LOGGER.quiet("======================================="); + LOGGER.quiet("Elasticsearch Build Hamster says Hello!"); + LOGGER.quiet(" Gradle Version : " + GradleVersion.current().getVersion()); + LOGGER.quiet(" OS Info : " + osName + " " + osVersion + " (" + osArch + ")"); + if (Jvm.current().getJavaVersion().equals(BuildParams.getCompilerJavaVersion()) == false || BuildParams.getIsRuntimeJavaHomeSet()) { + String compilerJvmDetails = getJavaInstallation(BuildParams.getCompilerJavaHome()).getImplementationName(); + String runtimeJvmDetails = getJavaInstallation(BuildParams.getRuntimeJavaHome()).getImplementationName(); + + LOGGER.quiet(" Compiler JDK Version : " + BuildParams.getCompilerJavaVersion() + " (" + compilerJvmDetails + ")"); + LOGGER.quiet(" Compiler java.home : " + BuildParams.getCompilerJavaHome()); + LOGGER.quiet(" Runtime JDK Version : " + BuildParams.getRuntimeJavaVersion() + " (" + runtimeJvmDetails + ")"); + LOGGER.quiet(" Runtime java.home : " + BuildParams.getRuntimeJavaHome()); + LOGGER.quiet(" Gradle JDK Version : " + gradleJvm.getJavaVersion() + " (" + gradleJvmDetails + ")"); + LOGGER.quiet(" Gradle java.home : " + gradleJvm.getJavaHome()); + } else { + LOGGER.quiet(" JDK Version : " + gradleJvm.getJavaVersion() + " (" + gradleJvmDetails + ")"); + LOGGER.quiet(" JAVA_HOME : " + gradleJvm.getJavaHome()); + } + LOGGER.quiet(" Random Testing Seed : " + BuildParams.getTestSeed()); + LOGGER.quiet(" In FIPS 140 mode : " + BuildParams.isInFipsJvm()); + LOGGER.quiet("======================================="); + } + + private JavaVersion determineJavaVersion(String description, File javaHome, JavaVersion requiredVersion) { + JavaInstallation installation = getJavaInstallation(javaHome); + JavaVersion actualVersion = installation.getJavaVersion(); + if (actualVersion.isCompatibleWith(requiredVersion) == false) { + throwInvalidJavaHomeException( + description, + javaHome, + Integer.parseInt(requiredVersion.getMajorVersion()), + Integer.parseInt(actualVersion.getMajorVersion()) + ); + } + + return actualVersion; + } + + private JavaInstallation getJavaInstallation(File javaHome) { + JavaInstallation installation; + if (isCurrentJavaHome(javaHome)) { + installation = javaInstallationRegistry.getInstallationForCurrentVirtualMachine().get(); + } else { + installation = javaInstallationRegistry.installationForDirectory(objects.directoryProperty().fileValue(javaHome)).get(); + } + + return installation; + } + + private List getAvailableJavaVersions(JavaVersion minimumCompilerVersion) { + final List javaVersions = new ArrayList<>(); + for (int v = 8; v <= Integer.parseInt(minimumCompilerVersion.getMajorVersion()); v++) { + int version = v; + String javaHomeEnvVarName = getJavaHomeEnvVarName(Integer.toString(version)); + if (System.getenv(javaHomeEnvVarName) != null) { + File javaHomeDirectory = new File(findJavaHome(Integer.toString(version))); + Provider javaInstallationProvider = javaInstallationRegistry.installationForDirectory( + objects.directoryProperty().fileValue(javaHomeDirectory) + ); + JavaHome javaHome = JavaHome.of(version, providers.provider(() -> { + int actualVersion = Integer.parseInt(javaInstallationProvider.get().getJavaVersion().getMajorVersion()); + if (actualVersion != version) { + throwInvalidJavaHomeException("env variable " + javaHomeEnvVarName, javaHomeDirectory, version, actualVersion); + } + return javaHomeDirectory; + })); + javaVersions.add(javaHome); + } + } + return javaVersions; + } + + private static boolean isCurrentJavaHome(File javaHome) { + try { + return Files.isSameFile(javaHome.toPath(), Jvm.current().getJavaHome().toPath()); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + private static String getTestSeed() { String testSeedProperty = System.getProperty("tests.seed"); final String testSeed; if (testSeedProperty == null) { @@ -58,77 +190,20 @@ public class GlobalBuildInfoPlugin implements Plugin { } else { testSeed = testSeedProperty; } + return testSeed; + } - final String buildSnapshotSystemProperty = System.getProperty("build.snapshot", "true"); - final boolean isSnapshotBuild; - switch (buildSnapshotSystemProperty) { - case "true": - isSnapshotBuild = true; - break; - case "false": - isSnapshotBuild = false; - break; - default: - throw new IllegalArgumentException( - "build.snapshot was set to [" + buildSnapshotSystemProperty + "] but can only be unset or [true|false]" - ); - } - final List javaVersions = new ArrayList<>(); - for (int version = 8; version <= Integer.parseInt(minimumCompilerVersion.getMajorVersion()); version++) { - if (System.getenv(getJavaHomeEnvVarName(Integer.toString(version))) != null) { - javaVersions.add(JavaHome.of(version, new File(findJavaHome(Integer.toString(version))))); - } - } - - GenerateGlobalBuildInfoTask generateTask = project.getTasks() - .create("generateGlobalBuildInfo", GenerateGlobalBuildInfoTask.class, task -> { - task.setJavaVersions(javaVersions); - task.setMinimumCompilerVersion(minimumCompilerVersion); - task.setMinimumRuntimeVersion(minimumRuntimeVersion); - task.setCompilerJavaHome(compilerJavaHome); - task.setRuntimeJavaHome(runtimeJavaHome); - task.getOutputFile().set(new File(project.getBuildDir(), "global-build-info")); - task.getCompilerVersionFile().set(new File(project.getBuildDir(), "java-compiler-version")); - task.getRuntimeVersionFile().set(new File(project.getBuildDir(), "java-runtime-version")); - }); - - PrintGlobalBuildInfoTask printTask = project.getTasks().create("printGlobalBuildInfo", PrintGlobalBuildInfoTask.class, task -> { - task.getBuildInfoFile().set(generateTask.getOutputFile()); - task.getCompilerVersionFile().set(generateTask.getCompilerVersionFile()); - task.getRuntimeVersionFile().set(generateTask.getRuntimeVersionFile()); - task.setGlobalInfoListeners(extension.listeners); - }); - - // Initialize global build parameters - BuildParams.init(params -> { - params.reset(); - params.setCompilerJavaHome(compilerJavaHome); - params.setRuntimeJavaHome(runtimeJavaHome); - params.setIsRutimeJavaHomeSet(compilerJavaHome.equals(runtimeJavaHome) == false); - params.setJavaVersions(javaVersions); - params.setMinimumCompilerVersion(minimumCompilerVersion); - params.setMinimumRuntimeVersion(minimumRuntimeVersion); - params.setGradleJavaVersion(Jvm.current().getJavaVersion()); - params.setGitRevision(gitRevision(project.getRootProject().getRootDir())); - params.setBuildDate(ZonedDateTime.now(ZoneOffset.UTC)); - params.setTestSeed(testSeed); - params.setIsCi(System.getenv("JENKINS_URL") != null); - params.setIsInternal(GlobalBuildInfoPlugin.class.getResource("/buildSrc.marker") != null); - params.setDefaultParallel(findDefaultParallel(project)); - params.setInFipsJvm(isInFipsJvm()); - params.setIsSnapshotBuild(isSnapshotBuild); - }); - - project.allprojects( - p -> { - // Make sure than any task execution generates and prints build info - p.getTasks().configureEach(task -> { - if (task != generateTask && task != printTask) { - task.dependsOn(printTask); - } - }); - } + private static void throwInvalidJavaHomeException(String description, File javaHome, int expectedVersion, int actualVersion) { + String message = String.format( + Locale.ROOT, + "The %s must be set to a JDK installation directory for Java %d but is [%s] corresponding to [%s]", + description, + expectedVersion, + javaHome, + actualVersion ); + + throw new GradleException(message); } private static File findCompilerJavaHome() { @@ -174,28 +249,6 @@ public class GlobalBuildInfoPlugin implements Plugin { return "JAVA" + version + "_HOME"; } - private static boolean isInFipsJvm() { - return Boolean.parseBoolean(System.getProperty("tests.fips.enabled")); - } - - private static String getResourceContents(String resourcePath) { - try ( - BufferedReader reader = new BufferedReader(new InputStreamReader(GlobalBuildInfoPlugin.class.getResourceAsStream(resourcePath))) - ) { - StringBuilder b = new StringBuilder(); - for (String line = reader.readLine(); line != null; line = reader.readLine()) { - if (b.length() != 0) { - b.append('\n'); - } - b.append(line); - } - - return b.toString(); - } catch (IOException e) { - throw new UncheckedIOException("Error trying to read classpath resource: " + resourcePath, e); - } - } - private static int findDefaultParallel(Project project) { // Since it costs IO to compute this, and is done at configuration time we want to cache this if possible // It's safe to store this in a static variable since it's just a primitive so leaking memory isn't an issue diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/info/GlobalInfoExtension.java b/buildSrc/src/main/java/org/elasticsearch/gradle/info/GlobalInfoExtension.java deleted file mode 100644 index a2daa4a5767..00000000000 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/info/GlobalInfoExtension.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.elasticsearch.gradle.info; - -import java.util.ArrayList; -import java.util.List; - -public class GlobalInfoExtension { - final List listeners = new ArrayList<>(); - - public void ready(Runnable block) { - listeners.add(block); - } -} diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/info/PrintGlobalBuildInfoTask.java b/buildSrc/src/main/java/org/elasticsearch/gradle/info/PrintGlobalBuildInfoTask.java deleted file mode 100644 index fdd79e0fc9c..00000000000 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/info/PrintGlobalBuildInfoTask.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.elasticsearch.gradle.info; - -import org.gradle.api.DefaultTask; -import org.gradle.api.JavaVersion; -import org.gradle.api.file.RegularFileProperty; -import org.gradle.api.model.ObjectFactory; -import org.gradle.api.resources.TextResource; -import org.gradle.api.tasks.InputFile; -import org.gradle.api.tasks.TaskAction; - -import javax.inject.Inject; -import java.util.ArrayList; -import java.util.List; - -public class PrintGlobalBuildInfoTask extends DefaultTask { - private final RegularFileProperty buildInfoFile; - private final RegularFileProperty compilerVersionFile; - private final RegularFileProperty runtimeVersionFile; - private List globalInfoListeners = new ArrayList<>(); - - @Inject - public PrintGlobalBuildInfoTask(ObjectFactory objectFactory) { - this.buildInfoFile = objectFactory.fileProperty(); - this.compilerVersionFile = objectFactory.fileProperty(); - this.runtimeVersionFile = objectFactory.fileProperty(); - } - - @InputFile - public RegularFileProperty getBuildInfoFile() { - return buildInfoFile; - } - - @InputFile - public RegularFileProperty getCompilerVersionFile() { - return compilerVersionFile; - } - - @InputFile - public RegularFileProperty getRuntimeVersionFile() { - return runtimeVersionFile; - } - - public void setGlobalInfoListeners(List globalInfoListeners) { - this.globalInfoListeners = globalInfoListeners; - } - - @TaskAction - public void print() { - getLogger().quiet("======================================="); - getLogger().quiet("Elasticsearch Build Hamster says Hello!"); - getLogger().quiet(getFileText(getBuildInfoFile()).asString()); - getLogger().quiet(" Random Testing Seed : " + BuildParams.getTestSeed()); - getLogger().quiet(" In FIPS 140 mode : " + BuildParams.isInFipsJvm()); - getLogger().quiet("======================================="); - - setGlobalProperties(); - globalInfoListeners.forEach(Runnable::run); - - // Since all tasks depend on this task, and it always runs for every build, this makes sure that lifecycle tasks will still - // correctly report as UP-TO-DATE, since the convention is a lifecycle task (i.e. assemble, build, etc) will only be marked as - // UP-TO-DATE if all upstream tasks were also UP-TO-DATE. - setDidWork(false); - } - - private TextResource getFileText(RegularFileProperty regularFileProperty) { - return getProject().getResources().getText().fromFile(regularFileProperty.getAsFile().get()); - } - - private void setGlobalProperties() { - BuildParams.init(params -> { - params.setCompilerJavaVersion(JavaVersion.valueOf(getFileText(getCompilerVersionFile()).asString())); - params.setRuntimeJavaVersion(JavaVersion.valueOf(getFileText(getRuntimeVersionFile()).asString())); - }); - } -} diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/precommit/FilePermissionsTask.java b/buildSrc/src/main/java/org/elasticsearch/gradle/precommit/FilePermissionsTask.java index 68839f86c10..35ad889b341 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/precommit/FilePermissionsTask.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/precommit/FilePermissionsTask.java @@ -28,7 +28,7 @@ import java.util.Set; import java.util.stream.Collectors; import org.apache.tools.ant.taskdefs.condition.Os; -import org.elasticsearch.gradle.tool.Boilerplate; +import org.elasticsearch.gradle.util.GradleUtils; import org.gradle.api.DefaultTask; import org.gradle.api.GradleException; import org.gradle.api.file.FileCollection; @@ -80,7 +80,7 @@ public class FilePermissionsTask extends DefaultTask { @InputFiles @SkipWhenEmpty public FileCollection getFiles() { - return Boilerplate.getJavaSourceSets(getProject()) + return GradleUtils.getJavaSourceSets(getProject()) .stream() .map(sourceSet -> sourceSet.getAllSource().matching(filesFilter)) .reduce(FileTree::plus) diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/precommit/TestingConventionsTasks.java b/buildSrc/src/main/java/org/elasticsearch/gradle/precommit/TestingConventionsTasks.java index a662ff4dbca..3657808b919 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/precommit/TestingConventionsTasks.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/precommit/TestingConventionsTasks.java @@ -19,7 +19,7 @@ package org.elasticsearch.gradle.precommit; import groovy.lang.Closure; -import org.elasticsearch.gradle.tool.Boilerplate; +import org.elasticsearch.gradle.util.GradleUtils; import org.gradle.api.DefaultTask; import org.gradle.api.NamedDomainObjectContainer; import org.gradle.api.Task; @@ -65,7 +65,7 @@ public class TestingConventionsTasks extends DefaultTask { public TestingConventionsTasks() { setDescription("Tests various testing conventions"); // Run only after everything is compiled - Boilerplate.getJavaSourceSets(getProject()).all(sourceSet -> dependsOn(sourceSet.getOutput().getClassesDirs())); + GradleUtils.getJavaSourceSets(getProject()).all(sourceSet -> dependsOn(sourceSet.getOutput().getClassesDirs())); naming = getProject().container(TestingConventionRule.class); } @@ -81,7 +81,7 @@ public class TestingConventionsTasks extends DefaultTask { @Input public Map getTestClassNames() { if (testClassNames == null) { - testClassNames = Boilerplate.getJavaSourceSets(getProject()) + testClassNames = GradleUtils.getJavaSourceSets(getProject()) .getByName("test") .getOutput() .getClassesDirs() @@ -110,7 +110,7 @@ public class TestingConventionsTasks extends DefaultTask { @Input public Set getMainClassNamedLikeTests() { - SourceSetContainer javaSourceSets = Boilerplate.getJavaSourceSets(getProject()); + SourceSetContainer javaSourceSets = GradleUtils.getJavaSourceSets(getProject()); if (javaSourceSets.findByName(SourceSet.MAIN_SOURCE_SET_NAME) == null) { // some test projects don't have a main source set return Collections.emptySet(); @@ -351,7 +351,7 @@ public class TestingConventionsTasks extends DefaultTask { // running the tests. return getProject().files( getProject().getConfigurations().getByName("testRuntime").resolve(), - Boilerplate.getJavaSourceSets(getProject()) + GradleUtils.getJavaSourceSets(getProject()) .stream() .flatMap(sourceSet -> sourceSet.getOutput().getClassesDirs().getFiles().stream()) .collect(Collectors.toList()) diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/test/DistroTestPlugin.java b/buildSrc/src/main/java/org/elasticsearch/gradle/test/DistroTestPlugin.java index 7e425632ede..801313ccaf4 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/test/DistroTestPlugin.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/test/DistroTestPlugin.java @@ -32,7 +32,7 @@ import org.elasticsearch.gradle.VersionProperties; import org.elasticsearch.gradle.docker.DockerSupportPlugin; import org.elasticsearch.gradle.docker.DockerSupportService; import org.elasticsearch.gradle.info.BuildParams; -import org.elasticsearch.gradle.tool.Boilerplate; +import org.elasticsearch.gradle.util.GradleUtils; import org.elasticsearch.gradle.vagrant.BatsProgressLogger; import org.elasticsearch.gradle.vagrant.VagrantBasePlugin; import org.elasticsearch.gradle.vagrant.VagrantExtension; @@ -88,7 +88,7 @@ public class DistroTestPlugin implements Plugin { project.getPluginManager().apply(DistributionDownloadPlugin.class); project.getPluginManager().apply("elasticsearch.build"); - Provider dockerSupport = Boilerplate.getBuildService( + Provider dockerSupport = GradleUtils.getBuildService( project.getGradle().getSharedServices(), DockerSupportPlugin.DOCKER_SUPPORT_SERVICE_NAME ); diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/CopyRestApiTask.java b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/CopyRestApiTask.java index 1cb3034419b..a059400844c 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/CopyRestApiTask.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/CopyRestApiTask.java @@ -20,7 +20,7 @@ package org.elasticsearch.gradle.test.rest; import org.elasticsearch.gradle.VersionProperties; import org.elasticsearch.gradle.info.BuildParams; -import org.elasticsearch.gradle.tool.Boilerplate; +import org.elasticsearch.gradle.util.GradleUtils; import org.gradle.api.DefaultTask; import org.gradle.api.Project; import org.gradle.api.artifacts.Configuration; @@ -203,6 +203,6 @@ public class CopyRestApiTask extends DefaultTask { } private SourceSet getTestSourceSet() { - return Boilerplate.getJavaSourceSets(getProject()).findByName("test"); + return GradleUtils.getJavaSourceSets(getProject()).findByName("test"); } } diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/CopyRestTestsTask.java b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/CopyRestTestsTask.java index 4c86b86b56f..0d067b40edb 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/CopyRestTestsTask.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/CopyRestTestsTask.java @@ -20,7 +20,7 @@ package org.elasticsearch.gradle.test.rest; import org.elasticsearch.gradle.VersionProperties; import org.elasticsearch.gradle.info.BuildParams; -import org.elasticsearch.gradle.tool.Boilerplate; +import org.elasticsearch.gradle.util.GradleUtils; import org.gradle.api.DefaultTask; import org.gradle.api.Project; import org.gradle.api.artifacts.Configuration; @@ -146,6 +146,6 @@ public class CopyRestTestsTask extends DefaultTask { } private SourceSet getTestSourceSet() { - return Boilerplate.getJavaSourceSets(getProject()).findByName("test"); + return GradleUtils.getJavaSourceSets(getProject()).findByName("test"); } } diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/RestTestRunnerTask.java b/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/RestTestRunnerTask.java index 5cd88ea01a3..62427bc1d0a 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/RestTestRunnerTask.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/RestTestRunnerTask.java @@ -1,6 +1,6 @@ package org.elasticsearch.gradle.testclusters; -import org.elasticsearch.gradle.tool.Boilerplate; +import org.elasticsearch.gradle.util.GradleUtils; import org.gradle.api.provider.Provider; import org.gradle.api.services.internal.BuildServiceRegistryInternal; import org.gradle.api.tasks.CacheableTask; @@ -62,7 +62,7 @@ public class RestTestRunnerTask extends Test implements TestClustersAware { public List getSharedResources() { List locks = new ArrayList<>(super.getSharedResources()); BuildServiceRegistryInternal serviceRegistry = getServices().get(BuildServiceRegistryInternal.class); - Provider throttleProvider = Boilerplate.getBuildService(serviceRegistry, THROTTLE_SERVICE_NAME); + Provider throttleProvider = GradleUtils.getBuildService(serviceRegistry, THROTTLE_SERVICE_NAME); SharedResource resource = serviceRegistry.forService(throttleProvider); int nodeCount = clusters.stream().mapToInt(cluster -> cluster.getNodes().size()).sum(); diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/TestClustersPlugin.java b/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/TestClustersPlugin.java index fc41054049f..f5325636fc2 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/TestClustersPlugin.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/TestClustersPlugin.java @@ -25,7 +25,7 @@ import org.elasticsearch.gradle.JdkDownloadPlugin; import org.elasticsearch.gradle.OS; import org.elasticsearch.gradle.ReaperPlugin; import org.elasticsearch.gradle.ReaperService; -import org.elasticsearch.gradle.tool.Boilerplate; +import org.elasticsearch.gradle.util.GradleUtils; import org.gradle.api.NamedDomainObjectContainer; import org.gradle.api.Plugin; import org.gradle.api.Project; @@ -40,7 +40,7 @@ import org.gradle.api.tasks.TaskState; import java.io.File; -import static org.elasticsearch.gradle.tool.Boilerplate.noop; +import static org.elasticsearch.gradle.util.GradleUtils.noop; public class TestClustersPlugin implements Plugin { @@ -121,7 +121,7 @@ public class TestClustersPlugin implements Plugin { throw new IllegalStateException(this.getClass().getName() + " can only be applied to the root project."); } - Provider registryProvider = Boilerplate.getBuildService( + Provider registryProvider = GradleUtils.getBuildService( project.getGradle().getSharedServices(), REGISTRY_SERVICE_NAME ); diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/testfixtures/TestFixturesPlugin.java b/buildSrc/src/main/java/org/elasticsearch/gradle/testfixtures/TestFixturesPlugin.java index 64ea96e9f88..88e744043b7 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/testfixtures/TestFixturesPlugin.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/testfixtures/TestFixturesPlugin.java @@ -29,7 +29,7 @@ import org.elasticsearch.gradle.docker.DockerSupportPlugin; import org.elasticsearch.gradle.docker.DockerSupportService; import org.elasticsearch.gradle.info.BuildParams; import org.elasticsearch.gradle.precommit.TestingConventionsTasks; -import org.elasticsearch.gradle.tool.Boilerplate; +import org.elasticsearch.gradle.util.GradleUtils; import org.gradle.api.Action; import org.gradle.api.DefaultTask; import org.gradle.api.Plugin; @@ -67,7 +67,7 @@ public class TestFixturesPlugin implements Plugin { .getSharedServices() .registerIfAbsent(DOCKER_COMPOSE_THROTTLE, DockerComposeThrottle.class, spec -> spec.getMaxParallelUsages().set(1)); - Provider dockerSupport = Boilerplate.getBuildService( + Provider dockerSupport = GradleUtils.getBuildService( project.getGradle().getSharedServices(), DockerSupportPlugin.DOCKER_SUPPORT_SERVICE_NAME ); diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/tool/Boilerplate.java b/buildSrc/src/main/java/org/elasticsearch/gradle/util/GradleUtils.java similarity index 98% rename from buildSrc/src/main/java/org/elasticsearch/gradle/tool/Boilerplate.java rename to buildSrc/src/main/java/org/elasticsearch/gradle/util/GradleUtils.java index 85002b9c498..81de7ea8176 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/tool/Boilerplate.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/util/GradleUtils.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.elasticsearch.gradle.tool; +package org.elasticsearch.gradle.util; import org.gradle.api.Action; import org.gradle.api.GradleException; @@ -36,7 +36,7 @@ import org.gradle.api.tasks.TaskProvider; import java.util.Optional; -public abstract class Boilerplate { +public abstract class GradleUtils { public static Action noop() { return t -> {}; diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/Util.java b/buildSrc/src/main/java/org/elasticsearch/gradle/util/Util.java similarity index 60% rename from buildSrc/src/main/java/org/elasticsearch/gradle/Util.java rename to buildSrc/src/main/java/org/elasticsearch/gradle/util/Util.java index 9ca4efc8b9f..03ebe906625 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/Util.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/util/Util.java @@ -7,7 +7,7 @@ * not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -17,10 +17,15 @@ * under the License. */ -package org.elasticsearch.gradle; +package org.elasticsearch.gradle.util; +import org.elasticsearch.gradle.info.GlobalBuildInfoPlugin; import org.gradle.api.GradleException; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.UncheckedIOException; import java.util.Locale; public class Util { @@ -39,6 +44,24 @@ public class Util { } } + public static String getResourceContents(String resourcePath) { + try ( + BufferedReader reader = new BufferedReader(new InputStreamReader(GlobalBuildInfoPlugin.class.getResourceAsStream(resourcePath))) + ) { + StringBuilder b = new StringBuilder(); + for (String line = reader.readLine(); line != null; line = reader.readLine()) { + if (b.length() != 0) { + b.append('\n'); + } + b.append(line); + } + + return b.toString(); + } catch (IOException e) { + throw new UncheckedIOException("Error trying to read classpath resource: " + resourcePath, e); + } + } + public static String capitalize(String s) { return s.substring(0, 1).toUpperCase(Locale.ROOT) + s.substring(1); } diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/vagrant/VagrantMachine.java b/buildSrc/src/main/java/org/elasticsearch/gradle/vagrant/VagrantMachine.java index 945a5d4ed03..507b977569c 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/vagrant/VagrantMachine.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/vagrant/VagrantMachine.java @@ -23,7 +23,7 @@ import org.apache.commons.io.output.TeeOutputStream; import org.elasticsearch.gradle.LoggedExec; import org.elasticsearch.gradle.LoggingOutputStream; import org.elasticsearch.gradle.ReaperService; -import org.elasticsearch.gradle.Util; +import org.elasticsearch.gradle.util.Util; import org.gradle.api.Action; import org.gradle.api.Project; import org.gradle.internal.logging.progress.ProgressLogger; diff --git a/buildSrc/src/minimumRuntime/java/org/elasticsearch/gradle/info/BuildParams.java b/buildSrc/src/minimumRuntime/java/org/elasticsearch/gradle/info/BuildParams.java index a76413d6b47..624a3e6f5af 100644 --- a/buildSrc/src/minimumRuntime/java/org/elasticsearch/gradle/info/BuildParams.java +++ b/buildSrc/src/minimumRuntime/java/org/elasticsearch/gradle/info/BuildParams.java @@ -3,11 +3,6 @@ package org.elasticsearch.gradle.info; import org.gradle.api.JavaVersion; import java.io.File; -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; import java.lang.reflect.Modifier; import java.time.ZonedDateTime; import java.util.Arrays; @@ -75,12 +70,10 @@ public class BuildParams { return value(gradleJavaVersion); } - @ExecutionTime public static JavaVersion getCompilerJavaVersion() { return value(compilerJavaVersion); } - @ExecutionTime public static JavaVersion getRuntimeJavaVersion() { return value(runtimeJavaVersion); } @@ -120,22 +113,13 @@ public class BuildParams { private static T value(T object) { if (object == null) { String callingMethod = Thread.currentThread().getStackTrace()[2].getMethodName(); - boolean executionTime; - try { - executionTime = BuildParams.class.getMethod(callingMethod).getAnnotation(ExecutionTime.class) != null; - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } - String message = "Build parameter '" + propertyName(callingMethod) + "' has not been initialized. "; - if (executionTime) { - message += "This property is initialized at execution time, " - + "please ensure you are not attempting to access it during project configuration."; - } else { - message += "Perhaps the plugin responsible for initializing this property has not been applied."; - } - - throw new IllegalStateException(message); + throw new IllegalStateException( + "Build parameter '" + + propertyName(callingMethod) + + "' has not been initialized.\n" + + "Perhaps the plugin responsible for initializing this property has not been applied." + ); } return object; @@ -236,14 +220,4 @@ public class BuildParams { } } - - /** - * Indicates that a build parameter is initialized at task execution time and is not available at project configuration time. - * Attempts to read an uninitialized parameter wil result in an {@link IllegalStateException}. - */ - @Target({ ElementType.METHOD, ElementType.FIELD }) - @Retention(RetentionPolicy.RUNTIME) - @Documented - public @interface ExecutionTime { - } } diff --git a/buildSrc/src/minimumRuntime/java/org/elasticsearch/gradle/info/JavaHome.java b/buildSrc/src/minimumRuntime/java/org/elasticsearch/gradle/info/JavaHome.java index 29ca2bafc79..1fe376545ea 100644 --- a/buildSrc/src/minimumRuntime/java/org/elasticsearch/gradle/info/JavaHome.java +++ b/buildSrc/src/minimumRuntime/java/org/elasticsearch/gradle/info/JavaHome.java @@ -1,35 +1,27 @@ package org.elasticsearch.gradle.info; -import org.gradle.api.tasks.Input; -import org.gradle.api.tasks.InputDirectory; -import org.gradle.api.tasks.Optional; -import org.gradle.api.tasks.PathSensitive; -import org.gradle.api.tasks.PathSensitivity; +import org.gradle.api.provider.Provider; import java.io.File; public class JavaHome { private Integer version; - private File javaHome; + private Provider javaHome; - private JavaHome(int version, File javaHome) { + private JavaHome(int version, Provider javaHome) { this.version = version; this.javaHome = javaHome; } - public static JavaHome of(int version, File javaHome) { + public static JavaHome of(int version, Provider javaHome) { return new JavaHome(version, javaHome); } - @Input public Integer getVersion() { return version; } - @InputDirectory - @Optional - @PathSensitive(PathSensitivity.RELATIVE) - public File getJavaHome() { + public Provider getJavaHome() { return javaHome; } } diff --git a/gradle/ide.gradle b/gradle/ide.gradle index b3d866d8342..62c0caa37ec 100644 --- a/gradle/ide.gradle +++ b/gradle/ide.gradle @@ -108,7 +108,7 @@ idea { not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an diff --git a/libs/core/build.gradle b/libs/core/build.gradle index ab168ca6600..5515acf6fa3 100644 --- a/libs/core/build.gradle +++ b/libs/core/build.gradle @@ -49,12 +49,10 @@ if (!isEclipse) { } forbiddenApisJava9 { - rootProject.globalInfo.ready { - if (BuildParams.runtimeJavaVersion < JavaVersion.VERSION_1_9) { - targetCompatibility = JavaVersion.VERSION_1_9.getMajorVersion() - } - replaceSignatureFiles 'jdk-signatures' + if (BuildParams.runtimeJavaVersion < JavaVersion.VERSION_1_9) { + targetCompatibility = JavaVersion.VERSION_1_9.getMajorVersion() } + replaceSignatureFiles 'jdk-signatures' } jar { diff --git a/plugins/discovery-azure-classic/build.gradle b/plugins/discovery-azure-classic/build.gradle index 196a60ef83d..e6c46fe1c5a 100644 --- a/plugins/discovery-azure-classic/build.gradle +++ b/plugins/discovery-azure-classic/build.gradle @@ -53,7 +53,7 @@ dependencies { compile 'org.codehaus.jackson:jackson-xc:1.9.2' // HACK: javax.xml.bind was removed from default modules in java 9, so we pull the api in here, - // and whitelist this hack in JarHell + // and whitelist this hack in JarHell compile 'javax.xml.bind:jaxb-api:2.2.2' } @@ -142,121 +142,119 @@ thirdPartyAudit.ignoreMissingClasses( ) // jarhell with jdk (intentionally, because jaxb was removed from default modules in java 9) -rootProject.globalInfo.ready { - if (BuildParams.runtimeJavaVersion <= JavaVersion.VERSION_1_8) { - thirdPartyAudit.ignoreJarHellWithJDK( - 'javax.xml.bind.Binder', - 'javax.xml.bind.ContextFinder$1', - 'javax.xml.bind.ContextFinder', - 'javax.xml.bind.DataBindingException', - 'javax.xml.bind.DatatypeConverter', - 'javax.xml.bind.DatatypeConverterImpl$CalendarFormatter', - 'javax.xml.bind.DatatypeConverterImpl', - 'javax.xml.bind.DatatypeConverterInterface', - 'javax.xml.bind.Element', - 'javax.xml.bind.GetPropertyAction', - 'javax.xml.bind.JAXB$Cache', - 'javax.xml.bind.JAXB', - 'javax.xml.bind.JAXBContext', - 'javax.xml.bind.JAXBElement$GlobalScope', - 'javax.xml.bind.JAXBElement', - 'javax.xml.bind.JAXBException', - 'javax.xml.bind.JAXBIntrospector', - 'javax.xml.bind.JAXBPermission', - 'javax.xml.bind.MarshalException', - 'javax.xml.bind.Marshaller$Listener', - 'javax.xml.bind.Marshaller', - 'javax.xml.bind.Messages', - 'javax.xml.bind.NotIdentifiableEvent', - 'javax.xml.bind.ParseConversionEvent', - 'javax.xml.bind.PrintConversionEvent', - 'javax.xml.bind.PropertyException', - 'javax.xml.bind.SchemaOutputResolver', - 'javax.xml.bind.TypeConstraintException', - 'javax.xml.bind.UnmarshalException', - 'javax.xml.bind.Unmarshaller$Listener', - 'javax.xml.bind.Unmarshaller', - 'javax.xml.bind.UnmarshallerHandler', - 'javax.xml.bind.ValidationEvent', - 'javax.xml.bind.ValidationEventHandler', - 'javax.xml.bind.ValidationEventLocator', - 'javax.xml.bind.ValidationException', - 'javax.xml.bind.Validator', - 'javax.xml.bind.WhiteSpaceProcessor', - 'javax.xml.bind.annotation.DomHandler', - 'javax.xml.bind.annotation.W3CDomHandler', - 'javax.xml.bind.annotation.XmlAccessOrder', - 'javax.xml.bind.annotation.XmlAccessType', - 'javax.xml.bind.annotation.XmlAccessorOrder', - 'javax.xml.bind.annotation.XmlAccessorType', - 'javax.xml.bind.annotation.XmlAnyAttribute', - 'javax.xml.bind.annotation.XmlAnyElement', - 'javax.xml.bind.annotation.XmlAttachmentRef', - 'javax.xml.bind.annotation.XmlAttribute', - 'javax.xml.bind.annotation.XmlElement$DEFAULT', - 'javax.xml.bind.annotation.XmlElement', - 'javax.xml.bind.annotation.XmlElementDecl$GLOBAL', - 'javax.xml.bind.annotation.XmlElementDecl', - 'javax.xml.bind.annotation.XmlElementRef$DEFAULT', - 'javax.xml.bind.annotation.XmlElementRef', - 'javax.xml.bind.annotation.XmlElementRefs', - 'javax.xml.bind.annotation.XmlElementWrapper', - 'javax.xml.bind.annotation.XmlElements', - 'javax.xml.bind.annotation.XmlEnum', - 'javax.xml.bind.annotation.XmlEnumValue', - 'javax.xml.bind.annotation.XmlID', - 'javax.xml.bind.annotation.XmlIDREF', - 'javax.xml.bind.annotation.XmlInlineBinaryData', - 'javax.xml.bind.annotation.XmlList', - 'javax.xml.bind.annotation.XmlMimeType', - 'javax.xml.bind.annotation.XmlMixed', - 'javax.xml.bind.annotation.XmlNs', - 'javax.xml.bind.annotation.XmlNsForm', - 'javax.xml.bind.annotation.XmlRegistry', - 'javax.xml.bind.annotation.XmlRootElement', - 'javax.xml.bind.annotation.XmlSchema', - 'javax.xml.bind.annotation.XmlSchemaType$DEFAULT', - 'javax.xml.bind.annotation.XmlSchemaType', - 'javax.xml.bind.annotation.XmlSchemaTypes', - 'javax.xml.bind.annotation.XmlSeeAlso', - 'javax.xml.bind.annotation.XmlTransient', - 'javax.xml.bind.annotation.XmlType$DEFAULT', - 'javax.xml.bind.annotation.XmlType', - 'javax.xml.bind.annotation.XmlValue', - 'javax.xml.bind.annotation.adapters.CollapsedStringAdapter', - 'javax.xml.bind.annotation.adapters.HexBinaryAdapter', - 'javax.xml.bind.annotation.adapters.NormalizedStringAdapter', - 'javax.xml.bind.annotation.adapters.XmlAdapter', - 'javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter$DEFAULT', - 'javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter', - 'javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters', - 'javax.xml.bind.attachment.AttachmentMarshaller', - 'javax.xml.bind.attachment.AttachmentUnmarshaller', - 'javax.xml.bind.helpers.AbstractMarshallerImpl', - 'javax.xml.bind.helpers.AbstractUnmarshallerImpl', - 'javax.xml.bind.helpers.DefaultValidationEventHandler', - 'javax.xml.bind.helpers.Messages', - 'javax.xml.bind.helpers.NotIdentifiableEventImpl', - 'javax.xml.bind.helpers.ParseConversionEventImpl', - 'javax.xml.bind.helpers.PrintConversionEventImpl', - 'javax.xml.bind.helpers.ValidationEventImpl', - 'javax.xml.bind.helpers.ValidationEventLocatorImpl', - 'javax.xml.bind.util.JAXBResult', - 'javax.xml.bind.util.JAXBSource$1', - 'javax.xml.bind.util.JAXBSource', - 'javax.xml.bind.util.Messages', - 'javax.xml.bind.util.ValidationEventCollector' - ) - } else { - thirdPartyAudit.ignoreMissingClasses( - 'javax.activation.ActivationDataFlavor', - 'javax.activation.DataContentHandler', - 'javax.activation.DataHandler', - 'javax.activation.DataSource', - 'javax.activation.FileDataSource', - 'javax.activation.FileTypeMap', - 'javax.activation.MimeType', - 'javax.activation.MimeTypeParseException', - ) - } +if (BuildParams.runtimeJavaVersion <= JavaVersion.VERSION_1_8) { + thirdPartyAudit.ignoreJarHellWithJDK( + 'javax.xml.bind.Binder', + 'javax.xml.bind.ContextFinder$1', + 'javax.xml.bind.ContextFinder', + 'javax.xml.bind.DataBindingException', + 'javax.xml.bind.DatatypeConverter', + 'javax.xml.bind.DatatypeConverterImpl$CalendarFormatter', + 'javax.xml.bind.DatatypeConverterImpl', + 'javax.xml.bind.DatatypeConverterInterface', + 'javax.xml.bind.Element', + 'javax.xml.bind.GetPropertyAction', + 'javax.xml.bind.JAXB$Cache', + 'javax.xml.bind.JAXB', + 'javax.xml.bind.JAXBContext', + 'javax.xml.bind.JAXBElement$GlobalScope', + 'javax.xml.bind.JAXBElement', + 'javax.xml.bind.JAXBException', + 'javax.xml.bind.JAXBIntrospector', + 'javax.xml.bind.JAXBPermission', + 'javax.xml.bind.MarshalException', + 'javax.xml.bind.Marshaller$Listener', + 'javax.xml.bind.Marshaller', + 'javax.xml.bind.Messages', + 'javax.xml.bind.NotIdentifiableEvent', + 'javax.xml.bind.ParseConversionEvent', + 'javax.xml.bind.PrintConversionEvent', + 'javax.xml.bind.PropertyException', + 'javax.xml.bind.SchemaOutputResolver', + 'javax.xml.bind.TypeConstraintException', + 'javax.xml.bind.UnmarshalException', + 'javax.xml.bind.Unmarshaller$Listener', + 'javax.xml.bind.Unmarshaller', + 'javax.xml.bind.UnmarshallerHandler', + 'javax.xml.bind.ValidationEvent', + 'javax.xml.bind.ValidationEventHandler', + 'javax.xml.bind.ValidationEventLocator', + 'javax.xml.bind.ValidationException', + 'javax.xml.bind.Validator', + 'javax.xml.bind.WhiteSpaceProcessor', + 'javax.xml.bind.annotation.DomHandler', + 'javax.xml.bind.annotation.W3CDomHandler', + 'javax.xml.bind.annotation.XmlAccessOrder', + 'javax.xml.bind.annotation.XmlAccessType', + 'javax.xml.bind.annotation.XmlAccessorOrder', + 'javax.xml.bind.annotation.XmlAccessorType', + 'javax.xml.bind.annotation.XmlAnyAttribute', + 'javax.xml.bind.annotation.XmlAnyElement', + 'javax.xml.bind.annotation.XmlAttachmentRef', + 'javax.xml.bind.annotation.XmlAttribute', + 'javax.xml.bind.annotation.XmlElement$DEFAULT', + 'javax.xml.bind.annotation.XmlElement', + 'javax.xml.bind.annotation.XmlElementDecl$GLOBAL', + 'javax.xml.bind.annotation.XmlElementDecl', + 'javax.xml.bind.annotation.XmlElementRef$DEFAULT', + 'javax.xml.bind.annotation.XmlElementRef', + 'javax.xml.bind.annotation.XmlElementRefs', + 'javax.xml.bind.annotation.XmlElementWrapper', + 'javax.xml.bind.annotation.XmlElements', + 'javax.xml.bind.annotation.XmlEnum', + 'javax.xml.bind.annotation.XmlEnumValue', + 'javax.xml.bind.annotation.XmlID', + 'javax.xml.bind.annotation.XmlIDREF', + 'javax.xml.bind.annotation.XmlInlineBinaryData', + 'javax.xml.bind.annotation.XmlList', + 'javax.xml.bind.annotation.XmlMimeType', + 'javax.xml.bind.annotation.XmlMixed', + 'javax.xml.bind.annotation.XmlNs', + 'javax.xml.bind.annotation.XmlNsForm', + 'javax.xml.bind.annotation.XmlRegistry', + 'javax.xml.bind.annotation.XmlRootElement', + 'javax.xml.bind.annotation.XmlSchema', + 'javax.xml.bind.annotation.XmlSchemaType$DEFAULT', + 'javax.xml.bind.annotation.XmlSchemaType', + 'javax.xml.bind.annotation.XmlSchemaTypes', + 'javax.xml.bind.annotation.XmlSeeAlso', + 'javax.xml.bind.annotation.XmlTransient', + 'javax.xml.bind.annotation.XmlType$DEFAULT', + 'javax.xml.bind.annotation.XmlType', + 'javax.xml.bind.annotation.XmlValue', + 'javax.xml.bind.annotation.adapters.CollapsedStringAdapter', + 'javax.xml.bind.annotation.adapters.HexBinaryAdapter', + 'javax.xml.bind.annotation.adapters.NormalizedStringAdapter', + 'javax.xml.bind.annotation.adapters.XmlAdapter', + 'javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter$DEFAULT', + 'javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter', + 'javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters', + 'javax.xml.bind.attachment.AttachmentMarshaller', + 'javax.xml.bind.attachment.AttachmentUnmarshaller', + 'javax.xml.bind.helpers.AbstractMarshallerImpl', + 'javax.xml.bind.helpers.AbstractUnmarshallerImpl', + 'javax.xml.bind.helpers.DefaultValidationEventHandler', + 'javax.xml.bind.helpers.Messages', + 'javax.xml.bind.helpers.NotIdentifiableEventImpl', + 'javax.xml.bind.helpers.ParseConversionEventImpl', + 'javax.xml.bind.helpers.PrintConversionEventImpl', + 'javax.xml.bind.helpers.ValidationEventImpl', + 'javax.xml.bind.helpers.ValidationEventLocatorImpl', + 'javax.xml.bind.util.JAXBResult', + 'javax.xml.bind.util.JAXBSource$1', + 'javax.xml.bind.util.JAXBSource', + 'javax.xml.bind.util.Messages', + 'javax.xml.bind.util.ValidationEventCollector' + ) +} else { + thirdPartyAudit.ignoreMissingClasses( + 'javax.activation.ActivationDataFlavor', + 'javax.activation.DataContentHandler', + 'javax.activation.DataHandler', + 'javax.activation.DataSource', + 'javax.activation.FileDataSource', + 'javax.activation.FileTypeMap', + 'javax.activation.MimeType', + 'javax.activation.MimeTypeParseException', + ) } diff --git a/plugins/discovery-ec2/build.gradle b/plugins/discovery-ec2/build.gradle index 2c2ff4da367..7b0f412a05b 100644 --- a/plugins/discovery-ec2/build.gradle +++ b/plugins/discovery-ec2/build.gradle @@ -117,11 +117,9 @@ thirdPartyAudit.ignoreMissingClasses( 'org.apache.log.Logger' ) -rootProject.globalInfo.ready { - if (BuildParams.runtimeJavaVersion > JavaVersion.VERSION_1_8) { - thirdPartyAudit.ignoreMissingClasses( - 'javax.xml.bind.DatatypeConverter', - 'javax.xml.bind.JAXBContext' - ) - } +if (BuildParams.runtimeJavaVersion > JavaVersion.VERSION_1_8) { + thirdPartyAudit.ignoreMissingClasses( + 'javax.xml.bind.DatatypeConverter', + 'javax.xml.bind.JAXBContext' + ) } diff --git a/plugins/repository-hdfs/build.gradle b/plugins/repository-hdfs/build.gradle index 1c78f6ad059..489d969232d 100644 --- a/plugins/repository-hdfs/build.gradle +++ b/plugins/repository-hdfs/build.gradle @@ -114,10 +114,8 @@ for (String fixtureName : ['hdfsFixture', 'haHdfsFixture', 'secureHdfsFixture', // If it's a secure fixture, then depend on Kerberos Fixture and principals + add the krb5conf to the JVM options if (fixtureName.equals('secureHdfsFixture') || fixtureName.equals('secureHaHdfsFixture')) { miniHDFSArgs.add("-Djava.security.krb5.conf=${project(':test:fixtures:krb5kdc-fixture').ext.krb5Conf("hdfs")}"); - rootProject.globalInfo.ready { - if (BuildParams.runtimeJavaVersion == JavaVersion.VERSION_1_9) { - miniHDFSArgs.add('--add-opens=java.security.jgss/sun.security.krb5=ALL-UNNAMED') - } + if (BuildParams.runtimeJavaVersion == JavaVersion.VERSION_1_9) { + miniHDFSArgs.add('--add-opens=java.security.jgss/sun.security.krb5=ALL-UNNAMED') } } // If it's an HA fixture, set a nameservice to use in the JVM options diff --git a/plugins/repository-s3/build.gradle b/plugins/repository-s3/build.gradle index 05ceb079de8..df8a6905172 100644 --- a/plugins/repository-s3/build.gradle +++ b/plugins/repository-s3/build.gradle @@ -49,7 +49,7 @@ dependencies { compile "joda-time:joda-time:${versions.joda}" // HACK: javax.xml.bind was removed from default modules in java 9, so we pull the api in here, - // and whitelist this hack in JarHell + // and whitelist this hack in JarHell compile 'javax.xml.bind:jaxb-api:2.2.2' testCompile project(':test:fixtures:s3-fixture') @@ -299,7 +299,7 @@ thirdPartyAudit.ignoreMissingClasses( 'software.amazon.ion.system.IonSystemBuilder', 'software.amazon.ion.system.IonTextWriterBuilder', 'software.amazon.ion.system.IonWriterBuilder', - // We don't use the kms dependency + // We don't use the kms dependency 'com.amazonaws.services.kms.AWSKMS', 'com.amazonaws.services.kms.AWSKMSClient', 'com.amazonaws.services.kms.model.DecryptRequest', @@ -311,112 +311,110 @@ thirdPartyAudit.ignoreMissingClasses( ) // jarhell with jdk (intentionally, because jaxb was removed from default modules in java 9) -rootProject.globalInfo.ready { - if (BuildParams.runtimeJavaVersion <= JavaVersion.VERSION_1_8) { - thirdPartyAudit.ignoreJarHellWithJDK( - 'javax.xml.bind.Binder', - 'javax.xml.bind.ContextFinder$1', - 'javax.xml.bind.ContextFinder', - 'javax.xml.bind.DataBindingException', - 'javax.xml.bind.DatatypeConverter', - 'javax.xml.bind.DatatypeConverterImpl$CalendarFormatter', - 'javax.xml.bind.DatatypeConverterImpl', - 'javax.xml.bind.DatatypeConverterInterface', - 'javax.xml.bind.Element', - 'javax.xml.bind.GetPropertyAction', - 'javax.xml.bind.JAXB$Cache', - 'javax.xml.bind.JAXB', - 'javax.xml.bind.JAXBContext', - 'javax.xml.bind.JAXBElement$GlobalScope', - 'javax.xml.bind.JAXBElement', - 'javax.xml.bind.JAXBException', - 'javax.xml.bind.JAXBIntrospector', - 'javax.xml.bind.JAXBPermission', - 'javax.xml.bind.MarshalException', - 'javax.xml.bind.Marshaller$Listener', - 'javax.xml.bind.Marshaller', - 'javax.xml.bind.Messages', - 'javax.xml.bind.NotIdentifiableEvent', - 'javax.xml.bind.ParseConversionEvent', - 'javax.xml.bind.PrintConversionEvent', - 'javax.xml.bind.PropertyException', - 'javax.xml.bind.SchemaOutputResolver', - 'javax.xml.bind.TypeConstraintException', - 'javax.xml.bind.UnmarshalException', - 'javax.xml.bind.Unmarshaller$Listener', - 'javax.xml.bind.Unmarshaller', - 'javax.xml.bind.UnmarshallerHandler', - 'javax.xml.bind.ValidationEvent', - 'javax.xml.bind.ValidationEventHandler', - 'javax.xml.bind.ValidationEventLocator', - 'javax.xml.bind.ValidationException', - 'javax.xml.bind.Validator', - 'javax.xml.bind.WhiteSpaceProcessor', - 'javax.xml.bind.annotation.DomHandler', - 'javax.xml.bind.annotation.W3CDomHandler', - 'javax.xml.bind.annotation.XmlAccessOrder', - 'javax.xml.bind.annotation.XmlAccessType', - 'javax.xml.bind.annotation.XmlAccessorOrder', - 'javax.xml.bind.annotation.XmlAccessorType', - 'javax.xml.bind.annotation.XmlAnyAttribute', - 'javax.xml.bind.annotation.XmlAnyElement', - 'javax.xml.bind.annotation.XmlAttachmentRef', - 'javax.xml.bind.annotation.XmlAttribute', - 'javax.xml.bind.annotation.XmlElement$DEFAULT', - 'javax.xml.bind.annotation.XmlElement', - 'javax.xml.bind.annotation.XmlElementDecl$GLOBAL', - 'javax.xml.bind.annotation.XmlElementDecl', - 'javax.xml.bind.annotation.XmlElementRef$DEFAULT', - 'javax.xml.bind.annotation.XmlElementRef', - 'javax.xml.bind.annotation.XmlElementRefs', - 'javax.xml.bind.annotation.XmlElementWrapper', - 'javax.xml.bind.annotation.XmlElements', - 'javax.xml.bind.annotation.XmlEnum', - 'javax.xml.bind.annotation.XmlEnumValue', - 'javax.xml.bind.annotation.XmlID', - 'javax.xml.bind.annotation.XmlIDREF', - 'javax.xml.bind.annotation.XmlInlineBinaryData', - 'javax.xml.bind.annotation.XmlList', - 'javax.xml.bind.annotation.XmlMimeType', - 'javax.xml.bind.annotation.XmlMixed', - 'javax.xml.bind.annotation.XmlNs', - 'javax.xml.bind.annotation.XmlNsForm', - 'javax.xml.bind.annotation.XmlRegistry', - 'javax.xml.bind.annotation.XmlRootElement', - 'javax.xml.bind.annotation.XmlSchema', - 'javax.xml.bind.annotation.XmlSchemaType$DEFAULT', - 'javax.xml.bind.annotation.XmlSchemaType', - 'javax.xml.bind.annotation.XmlSchemaTypes', - 'javax.xml.bind.annotation.XmlSeeAlso', - 'javax.xml.bind.annotation.XmlTransient', - 'javax.xml.bind.annotation.XmlType$DEFAULT', - 'javax.xml.bind.annotation.XmlType', - 'javax.xml.bind.annotation.XmlValue', - 'javax.xml.bind.annotation.adapters.CollapsedStringAdapter', - 'javax.xml.bind.annotation.adapters.HexBinaryAdapter', - 'javax.xml.bind.annotation.adapters.NormalizedStringAdapter', - 'javax.xml.bind.annotation.adapters.XmlAdapter', - 'javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter$DEFAULT', - 'javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter', - 'javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters', - 'javax.xml.bind.attachment.AttachmentMarshaller', - 'javax.xml.bind.attachment.AttachmentUnmarshaller', - 'javax.xml.bind.helpers.AbstractMarshallerImpl', - 'javax.xml.bind.helpers.AbstractUnmarshallerImpl', - 'javax.xml.bind.helpers.DefaultValidationEventHandler', - 'javax.xml.bind.helpers.Messages', - 'javax.xml.bind.helpers.NotIdentifiableEventImpl', - 'javax.xml.bind.helpers.ParseConversionEventImpl', - 'javax.xml.bind.helpers.PrintConversionEventImpl', - 'javax.xml.bind.helpers.ValidationEventImpl', - 'javax.xml.bind.helpers.ValidationEventLocatorImpl', - 'javax.xml.bind.util.JAXBResult', - 'javax.xml.bind.util.JAXBSource$1', - 'javax.xml.bind.util.JAXBSource', - 'javax.xml.bind.util.Messages', - 'javax.xml.bind.util.ValidationEventCollector' - ) - } else { - thirdPartyAudit.ignoreMissingClasses 'javax.activation.DataHandler' - } +if (BuildParams.runtimeJavaVersion <= JavaVersion.VERSION_1_8) { + thirdPartyAudit.ignoreJarHellWithJDK( + 'javax.xml.bind.Binder', + 'javax.xml.bind.ContextFinder$1', + 'javax.xml.bind.ContextFinder', + 'javax.xml.bind.DataBindingException', + 'javax.xml.bind.DatatypeConverter', + 'javax.xml.bind.DatatypeConverterImpl$CalendarFormatter', + 'javax.xml.bind.DatatypeConverterImpl', + 'javax.xml.bind.DatatypeConverterInterface', + 'javax.xml.bind.Element', + 'javax.xml.bind.GetPropertyAction', + 'javax.xml.bind.JAXB$Cache', + 'javax.xml.bind.JAXB', + 'javax.xml.bind.JAXBContext', + 'javax.xml.bind.JAXBElement$GlobalScope', + 'javax.xml.bind.JAXBElement', + 'javax.xml.bind.JAXBException', + 'javax.xml.bind.JAXBIntrospector', + 'javax.xml.bind.JAXBPermission', + 'javax.xml.bind.MarshalException', + 'javax.xml.bind.Marshaller$Listener', + 'javax.xml.bind.Marshaller', + 'javax.xml.bind.Messages', + 'javax.xml.bind.NotIdentifiableEvent', + 'javax.xml.bind.ParseConversionEvent', + 'javax.xml.bind.PrintConversionEvent', + 'javax.xml.bind.PropertyException', + 'javax.xml.bind.SchemaOutputResolver', + 'javax.xml.bind.TypeConstraintException', + 'javax.xml.bind.UnmarshalException', + 'javax.xml.bind.Unmarshaller$Listener', + 'javax.xml.bind.Unmarshaller', + 'javax.xml.bind.UnmarshallerHandler', + 'javax.xml.bind.ValidationEvent', + 'javax.xml.bind.ValidationEventHandler', + 'javax.xml.bind.ValidationEventLocator', + 'javax.xml.bind.ValidationException', + 'javax.xml.bind.Validator', + 'javax.xml.bind.WhiteSpaceProcessor', + 'javax.xml.bind.annotation.DomHandler', + 'javax.xml.bind.annotation.W3CDomHandler', + 'javax.xml.bind.annotation.XmlAccessOrder', + 'javax.xml.bind.annotation.XmlAccessType', + 'javax.xml.bind.annotation.XmlAccessorOrder', + 'javax.xml.bind.annotation.XmlAccessorType', + 'javax.xml.bind.annotation.XmlAnyAttribute', + 'javax.xml.bind.annotation.XmlAnyElement', + 'javax.xml.bind.annotation.XmlAttachmentRef', + 'javax.xml.bind.annotation.XmlAttribute', + 'javax.xml.bind.annotation.XmlElement$DEFAULT', + 'javax.xml.bind.annotation.XmlElement', + 'javax.xml.bind.annotation.XmlElementDecl$GLOBAL', + 'javax.xml.bind.annotation.XmlElementDecl', + 'javax.xml.bind.annotation.XmlElementRef$DEFAULT', + 'javax.xml.bind.annotation.XmlElementRef', + 'javax.xml.bind.annotation.XmlElementRefs', + 'javax.xml.bind.annotation.XmlElementWrapper', + 'javax.xml.bind.annotation.XmlElements', + 'javax.xml.bind.annotation.XmlEnum', + 'javax.xml.bind.annotation.XmlEnumValue', + 'javax.xml.bind.annotation.XmlID', + 'javax.xml.bind.annotation.XmlIDREF', + 'javax.xml.bind.annotation.XmlInlineBinaryData', + 'javax.xml.bind.annotation.XmlList', + 'javax.xml.bind.annotation.XmlMimeType', + 'javax.xml.bind.annotation.XmlMixed', + 'javax.xml.bind.annotation.XmlNs', + 'javax.xml.bind.annotation.XmlNsForm', + 'javax.xml.bind.annotation.XmlRegistry', + 'javax.xml.bind.annotation.XmlRootElement', + 'javax.xml.bind.annotation.XmlSchema', + 'javax.xml.bind.annotation.XmlSchemaType$DEFAULT', + 'javax.xml.bind.annotation.XmlSchemaType', + 'javax.xml.bind.annotation.XmlSchemaTypes', + 'javax.xml.bind.annotation.XmlSeeAlso', + 'javax.xml.bind.annotation.XmlTransient', + 'javax.xml.bind.annotation.XmlType$DEFAULT', + 'javax.xml.bind.annotation.XmlType', + 'javax.xml.bind.annotation.XmlValue', + 'javax.xml.bind.annotation.adapters.CollapsedStringAdapter', + 'javax.xml.bind.annotation.adapters.HexBinaryAdapter', + 'javax.xml.bind.annotation.adapters.NormalizedStringAdapter', + 'javax.xml.bind.annotation.adapters.XmlAdapter', + 'javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter$DEFAULT', + 'javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter', + 'javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters', + 'javax.xml.bind.attachment.AttachmentMarshaller', + 'javax.xml.bind.attachment.AttachmentUnmarshaller', + 'javax.xml.bind.helpers.AbstractMarshallerImpl', + 'javax.xml.bind.helpers.AbstractUnmarshallerImpl', + 'javax.xml.bind.helpers.DefaultValidationEventHandler', + 'javax.xml.bind.helpers.Messages', + 'javax.xml.bind.helpers.NotIdentifiableEventImpl', + 'javax.xml.bind.helpers.ParseConversionEventImpl', + 'javax.xml.bind.helpers.PrintConversionEventImpl', + 'javax.xml.bind.helpers.ValidationEventImpl', + 'javax.xml.bind.helpers.ValidationEventLocatorImpl', + 'javax.xml.bind.util.JAXBResult', + 'javax.xml.bind.util.JAXBSource$1', + 'javax.xml.bind.util.JAXBSource', + 'javax.xml.bind.util.Messages', + 'javax.xml.bind.util.ValidationEventCollector' + ) +} else { + thirdPartyAudit.ignoreMissingClasses 'javax.activation.DataHandler' } diff --git a/server/build.gradle b/server/build.gradle index b7a34c79b19..6805fa77141 100644 --- a/server/build.gradle +++ b/server/build.gradle @@ -317,10 +317,8 @@ thirdPartyAudit.ignoreMissingClasses( 'com.google.common.geometry.S2LatLng' ) -rootProject.globalInfo.ready { - if (BuildParams.runtimeJavaVersion > JavaVersion.VERSION_1_8) { - thirdPartyAudit.ignoreMissingClasses 'javax.xml.bind.DatatypeConverter' - } +if (BuildParams.runtimeJavaVersion > JavaVersion.VERSION_1_8) { + thirdPartyAudit.ignoreMissingClasses 'javax.xml.bind.DatatypeConverter' } dependencyLicenses { diff --git a/x-pack/plugin/security/build.gradle b/x-pack/plugin/security/build.gradle index b7f8d660a06..29e4be4f52e 100644 --- a/x-pack/plugin/security/build.gradle +++ b/x-pack/plugin/security/build.gradle @@ -455,22 +455,20 @@ thirdPartyAudit { ) } -rootProject.globalInfo.ready { - if (BuildParams.runtimeJavaVersion > JavaVersion.VERSION_1_8) { - thirdPartyAudit.ignoreMissingClasses( - 'javax.xml.bind.JAXBContext', - 'javax.xml.bind.JAXBElement', - 'javax.xml.bind.JAXBException', - 'javax.xml.bind.Unmarshaller', - 'javax.xml.bind.UnmarshallerHandler', - 'javax.activation.ActivationDataFlavor', - 'javax.activation.DataContentHandler', - 'javax.activation.DataHandler', - 'javax.activation.DataSource', - 'javax.activation.FileDataSource', - 'javax.activation.FileTypeMap' - ) - } +if (BuildParams.runtimeJavaVersion > JavaVersion.VERSION_1_8) { + thirdPartyAudit.ignoreMissingClasses( + 'javax.xml.bind.JAXBContext', + 'javax.xml.bind.JAXBElement', + 'javax.xml.bind.JAXBException', + 'javax.xml.bind.Unmarshaller', + 'javax.xml.bind.UnmarshallerHandler', + 'javax.activation.ActivationDataFlavor', + 'javax.activation.DataContentHandler', + 'javax.activation.DataHandler', + 'javax.activation.DataSource', + 'javax.activation.FileDataSource', + 'javax.activation.FileTypeMap' + ) } test { diff --git a/x-pack/plugin/watcher/build.gradle b/x-pack/plugin/watcher/build.gradle index 10b020c1ab9..0c67c7d9dc7 100644 --- a/x-pack/plugin/watcher/build.gradle +++ b/x-pack/plugin/watcher/build.gradle @@ -84,47 +84,45 @@ forbiddenPatterns { } // pulled in as external dependency to work on java 9 -rootProject.globalInfo.ready { - if (BuildParams.runtimeJavaVersion <= JavaVersion.VERSION_1_8) { - thirdPartyAudit.ignoreJarHellWithJDK( - // pulled in as external dependency to work on java 9 - 'com.sun.activation.registries.LineTokenizer', - 'com.sun.activation.registries.LogSupport', - 'com.sun.activation.registries.MailcapFile', - 'com.sun.activation.registries.MailcapTokenizer', - 'com.sun.activation.registries.MimeTypeEntry', - 'com.sun.activation.registries.MimeTypeFile', - 'javax.activation.MailcapCommandMap', - 'javax.activation.MimetypesFileTypeMap', +if (BuildParams.runtimeJavaVersion <= JavaVersion.VERSION_1_8) { + thirdPartyAudit.ignoreJarHellWithJDK( + // pulled in as external dependency to work on java 9 + 'com.sun.activation.registries.LineTokenizer', + 'com.sun.activation.registries.LogSupport', + 'com.sun.activation.registries.MailcapFile', + 'com.sun.activation.registries.MailcapTokenizer', + 'com.sun.activation.registries.MimeTypeEntry', + 'com.sun.activation.registries.MimeTypeFile', + 'javax.activation.MailcapCommandMap', + 'javax.activation.MimetypesFileTypeMap', - 'com.sun.activation.registries.MailcapParseException', - 'javax.activation.ActivationDataFlavor', - 'javax.activation.CommandInfo', - 'javax.activation.CommandMap', - 'javax.activation.CommandObject', - 'javax.activation.DataContentHandler', - 'javax.activation.DataContentHandlerFactory', - 'javax.activation.DataHandler$1', - 'javax.activation.DataHandler', - 'javax.activation.DataHandlerDataSource', - 'javax.activation.DataSource', - 'javax.activation.DataSourceDataContentHandler', - 'javax.activation.FileDataSource', - 'javax.activation.FileTypeMap', - 'javax.activation.MimeType', - 'javax.activation.MimeTypeParameterList', - 'javax.activation.MimeTypeParseException', - 'javax.activation.ObjectDataContentHandler', - 'javax.activation.SecuritySupport$1', - 'javax.activation.SecuritySupport$2', - 'javax.activation.SecuritySupport$3', - 'javax.activation.SecuritySupport$4', - 'javax.activation.SecuritySupport$5', - 'javax.activation.SecuritySupport', - 'javax.activation.URLDataSource', - 'javax.activation.UnsupportedDataTypeException' - ) - } + 'com.sun.activation.registries.MailcapParseException', + 'javax.activation.ActivationDataFlavor', + 'javax.activation.CommandInfo', + 'javax.activation.CommandMap', + 'javax.activation.CommandObject', + 'javax.activation.DataContentHandler', + 'javax.activation.DataContentHandlerFactory', + 'javax.activation.DataHandler$1', + 'javax.activation.DataHandler', + 'javax.activation.DataHandlerDataSource', + 'javax.activation.DataSource', + 'javax.activation.DataSourceDataContentHandler', + 'javax.activation.FileDataSource', + 'javax.activation.FileTypeMap', + 'javax.activation.MimeType', + 'javax.activation.MimeTypeParameterList', + 'javax.activation.MimeTypeParseException', + 'javax.activation.ObjectDataContentHandler', + 'javax.activation.SecuritySupport$1', + 'javax.activation.SecuritySupport$2', + 'javax.activation.SecuritySupport$3', + 'javax.activation.SecuritySupport$4', + 'javax.activation.SecuritySupport$5', + 'javax.activation.SecuritySupport', + 'javax.activation.URLDataSource', + 'javax.activation.UnsupportedDataTypeException' + ) } test { diff --git a/x-pack/qa/reindex-tests-with-security/build.gradle b/x-pack/qa/reindex-tests-with-security/build.gradle index 58ab5515b14..969fdba727e 100644 --- a/x-pack/qa/reindex-tests-with-security/build.gradle +++ b/x-pack/qa/reindex-tests-with-security/build.gradle @@ -39,10 +39,8 @@ testClusters.integTest { setting 'reindex.ssl.truststore.password', 'password' // Workaround for JDK-8212885 - rootProject.globalInfo.ready { - if (BuildParams.runtimeJavaVersion.isJava12Compatible() == false) { - setting 'reindex.ssl.supported_protocols', 'TLSv1.2' - } + if (BuildParams.runtimeJavaVersion.isJava12Compatible() == false) { + setting 'reindex.ssl.supported_protocols', 'TLSv1.2' } extraConfigFile 'roles.yml', file('roles.yml') diff --git a/x-pack/snapshot-tool/build.gradle b/x-pack/snapshot-tool/build.gradle index 31c17ba4c35..71dbeb0a073 100644 --- a/x-pack/snapshot-tool/build.gradle +++ b/x-pack/snapshot-tool/build.gradle @@ -181,114 +181,112 @@ thirdPartyAudit.ignoreMissingClasses( 'javax.servlet.ServletContextListener' ) -rootProject.globalInfo.ready { - if (BuildParams.runtimeJavaVersion <= JavaVersion.VERSION_1_8) { - thirdPartyAudit.ignoreJarHellWithJDK( - 'javax.xml.bind.Binder', - 'javax.xml.bind.ContextFinder$1', - 'javax.xml.bind.ContextFinder', - 'javax.xml.bind.DataBindingException', - 'javax.xml.bind.DatatypeConverter', - 'javax.xml.bind.DatatypeConverterImpl$CalendarFormatter', - 'javax.xml.bind.DatatypeConverterImpl', - 'javax.xml.bind.DatatypeConverterInterface', - 'javax.xml.bind.Element', - 'javax.xml.bind.GetPropertyAction', - 'javax.xml.bind.JAXB$Cache', - 'javax.xml.bind.JAXB', - 'javax.xml.bind.JAXBContext', - 'javax.xml.bind.JAXBElement$GlobalScope', - 'javax.xml.bind.JAXBElement', - 'javax.xml.bind.JAXBException', - 'javax.xml.bind.JAXBIntrospector', - 'javax.xml.bind.JAXBPermission', - 'javax.xml.bind.MarshalException', - 'javax.xml.bind.Marshaller$Listener', - 'javax.xml.bind.Marshaller', - 'javax.xml.bind.Messages', - 'javax.xml.bind.NotIdentifiableEvent', - 'javax.xml.bind.ParseConversionEvent', - 'javax.xml.bind.PrintConversionEvent', - 'javax.xml.bind.PropertyException', - 'javax.xml.bind.SchemaOutputResolver', - 'javax.xml.bind.TypeConstraintException', - 'javax.xml.bind.UnmarshalException', - 'javax.xml.bind.Unmarshaller$Listener', - 'javax.xml.bind.Unmarshaller', - 'javax.xml.bind.UnmarshallerHandler', - 'javax.xml.bind.ValidationEvent', - 'javax.xml.bind.ValidationEventHandler', - 'javax.xml.bind.ValidationEventLocator', - 'javax.xml.bind.ValidationException', - 'javax.xml.bind.Validator', - 'javax.xml.bind.WhiteSpaceProcessor', - 'javax.xml.bind.annotation.DomHandler', - 'javax.xml.bind.annotation.W3CDomHandler', - 'javax.xml.bind.annotation.XmlAccessOrder', - 'javax.xml.bind.annotation.XmlAccessType', - 'javax.xml.bind.annotation.XmlAccessorOrder', - 'javax.xml.bind.annotation.XmlAccessorType', - 'javax.xml.bind.annotation.XmlAnyAttribute', - 'javax.xml.bind.annotation.XmlAnyElement', - 'javax.xml.bind.annotation.XmlAttachmentRef', - 'javax.xml.bind.annotation.XmlAttribute', - 'javax.xml.bind.annotation.XmlElement$DEFAULT', - 'javax.xml.bind.annotation.XmlElement', - 'javax.xml.bind.annotation.XmlElementDecl$GLOBAL', - 'javax.xml.bind.annotation.XmlElementDecl', - 'javax.xml.bind.annotation.XmlElementRef$DEFAULT', - 'javax.xml.bind.annotation.XmlElementRef', - 'javax.xml.bind.annotation.XmlElementRefs', - 'javax.xml.bind.annotation.XmlElementWrapper', - 'javax.xml.bind.annotation.XmlElements', - 'javax.xml.bind.annotation.XmlEnum', - 'javax.xml.bind.annotation.XmlEnumValue', - 'javax.xml.bind.annotation.XmlID', - 'javax.xml.bind.annotation.XmlIDREF', - 'javax.xml.bind.annotation.XmlInlineBinaryData', - 'javax.xml.bind.annotation.XmlList', - 'javax.xml.bind.annotation.XmlMimeType', - 'javax.xml.bind.annotation.XmlMixed', - 'javax.xml.bind.annotation.XmlNs', - 'javax.xml.bind.annotation.XmlNsForm', - 'javax.xml.bind.annotation.XmlRegistry', - 'javax.xml.bind.annotation.XmlRootElement', - 'javax.xml.bind.annotation.XmlSchema', - 'javax.xml.bind.annotation.XmlSchemaType$DEFAULT', - 'javax.xml.bind.annotation.XmlSchemaType', - 'javax.xml.bind.annotation.XmlSchemaTypes', - 'javax.xml.bind.annotation.XmlSeeAlso', - 'javax.xml.bind.annotation.XmlTransient', - 'javax.xml.bind.annotation.XmlType$DEFAULT', - 'javax.xml.bind.annotation.XmlType', - 'javax.xml.bind.annotation.XmlValue', - 'javax.xml.bind.annotation.adapters.CollapsedStringAdapter', - 'javax.xml.bind.annotation.adapters.HexBinaryAdapter', - 'javax.xml.bind.annotation.adapters.NormalizedStringAdapter', - 'javax.xml.bind.annotation.adapters.XmlAdapter', - 'javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter$DEFAULT', - 'javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter', - 'javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters', - 'javax.xml.bind.attachment.AttachmentMarshaller', - 'javax.xml.bind.attachment.AttachmentUnmarshaller', - 'javax.xml.bind.helpers.AbstractMarshallerImpl', - 'javax.xml.bind.helpers.AbstractUnmarshallerImpl', - 'javax.xml.bind.helpers.DefaultValidationEventHandler', - 'javax.xml.bind.helpers.Messages', - 'javax.xml.bind.helpers.NotIdentifiableEventImpl', - 'javax.xml.bind.helpers.ParseConversionEventImpl', - 'javax.xml.bind.helpers.PrintConversionEventImpl', - 'javax.xml.bind.helpers.ValidationEventImpl', - 'javax.xml.bind.helpers.ValidationEventLocatorImpl', - 'javax.xml.bind.util.JAXBResult', - 'javax.xml.bind.util.JAXBSource$1', - 'javax.xml.bind.util.JAXBSource', - 'javax.xml.bind.util.Messages', - 'javax.xml.bind.util.ValidationEventCollector' - ) - } else { - thirdPartyAudit.ignoreMissingClasses 'javax.activation.DataHandler' - } +if (BuildParams.runtimeJavaVersion <= JavaVersion.VERSION_1_8) { + thirdPartyAudit.ignoreJarHellWithJDK( + 'javax.xml.bind.Binder', + 'javax.xml.bind.ContextFinder$1', + 'javax.xml.bind.ContextFinder', + 'javax.xml.bind.DataBindingException', + 'javax.xml.bind.DatatypeConverter', + 'javax.xml.bind.DatatypeConverterImpl$CalendarFormatter', + 'javax.xml.bind.DatatypeConverterImpl', + 'javax.xml.bind.DatatypeConverterInterface', + 'javax.xml.bind.Element', + 'javax.xml.bind.GetPropertyAction', + 'javax.xml.bind.JAXB$Cache', + 'javax.xml.bind.JAXB', + 'javax.xml.bind.JAXBContext', + 'javax.xml.bind.JAXBElement$GlobalScope', + 'javax.xml.bind.JAXBElement', + 'javax.xml.bind.JAXBException', + 'javax.xml.bind.JAXBIntrospector', + 'javax.xml.bind.JAXBPermission', + 'javax.xml.bind.MarshalException', + 'javax.xml.bind.Marshaller$Listener', + 'javax.xml.bind.Marshaller', + 'javax.xml.bind.Messages', + 'javax.xml.bind.NotIdentifiableEvent', + 'javax.xml.bind.ParseConversionEvent', + 'javax.xml.bind.PrintConversionEvent', + 'javax.xml.bind.PropertyException', + 'javax.xml.bind.SchemaOutputResolver', + 'javax.xml.bind.TypeConstraintException', + 'javax.xml.bind.UnmarshalException', + 'javax.xml.bind.Unmarshaller$Listener', + 'javax.xml.bind.Unmarshaller', + 'javax.xml.bind.UnmarshallerHandler', + 'javax.xml.bind.ValidationEvent', + 'javax.xml.bind.ValidationEventHandler', + 'javax.xml.bind.ValidationEventLocator', + 'javax.xml.bind.ValidationException', + 'javax.xml.bind.Validator', + 'javax.xml.bind.WhiteSpaceProcessor', + 'javax.xml.bind.annotation.DomHandler', + 'javax.xml.bind.annotation.W3CDomHandler', + 'javax.xml.bind.annotation.XmlAccessOrder', + 'javax.xml.bind.annotation.XmlAccessType', + 'javax.xml.bind.annotation.XmlAccessorOrder', + 'javax.xml.bind.annotation.XmlAccessorType', + 'javax.xml.bind.annotation.XmlAnyAttribute', + 'javax.xml.bind.annotation.XmlAnyElement', + 'javax.xml.bind.annotation.XmlAttachmentRef', + 'javax.xml.bind.annotation.XmlAttribute', + 'javax.xml.bind.annotation.XmlElement$DEFAULT', + 'javax.xml.bind.annotation.XmlElement', + 'javax.xml.bind.annotation.XmlElementDecl$GLOBAL', + 'javax.xml.bind.annotation.XmlElementDecl', + 'javax.xml.bind.annotation.XmlElementRef$DEFAULT', + 'javax.xml.bind.annotation.XmlElementRef', + 'javax.xml.bind.annotation.XmlElementRefs', + 'javax.xml.bind.annotation.XmlElementWrapper', + 'javax.xml.bind.annotation.XmlElements', + 'javax.xml.bind.annotation.XmlEnum', + 'javax.xml.bind.annotation.XmlEnumValue', + 'javax.xml.bind.annotation.XmlID', + 'javax.xml.bind.annotation.XmlIDREF', + 'javax.xml.bind.annotation.XmlInlineBinaryData', + 'javax.xml.bind.annotation.XmlList', + 'javax.xml.bind.annotation.XmlMimeType', + 'javax.xml.bind.annotation.XmlMixed', + 'javax.xml.bind.annotation.XmlNs', + 'javax.xml.bind.annotation.XmlNsForm', + 'javax.xml.bind.annotation.XmlRegistry', + 'javax.xml.bind.annotation.XmlRootElement', + 'javax.xml.bind.annotation.XmlSchema', + 'javax.xml.bind.annotation.XmlSchemaType$DEFAULT', + 'javax.xml.bind.annotation.XmlSchemaType', + 'javax.xml.bind.annotation.XmlSchemaTypes', + 'javax.xml.bind.annotation.XmlSeeAlso', + 'javax.xml.bind.annotation.XmlTransient', + 'javax.xml.bind.annotation.XmlType$DEFAULT', + 'javax.xml.bind.annotation.XmlType', + 'javax.xml.bind.annotation.XmlValue', + 'javax.xml.bind.annotation.adapters.CollapsedStringAdapter', + 'javax.xml.bind.annotation.adapters.HexBinaryAdapter', + 'javax.xml.bind.annotation.adapters.NormalizedStringAdapter', + 'javax.xml.bind.annotation.adapters.XmlAdapter', + 'javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter$DEFAULT', + 'javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter', + 'javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters', + 'javax.xml.bind.attachment.AttachmentMarshaller', + 'javax.xml.bind.attachment.AttachmentUnmarshaller', + 'javax.xml.bind.helpers.AbstractMarshallerImpl', + 'javax.xml.bind.helpers.AbstractUnmarshallerImpl', + 'javax.xml.bind.helpers.DefaultValidationEventHandler', + 'javax.xml.bind.helpers.Messages', + 'javax.xml.bind.helpers.NotIdentifiableEventImpl', + 'javax.xml.bind.helpers.ParseConversionEventImpl', + 'javax.xml.bind.helpers.PrintConversionEventImpl', + 'javax.xml.bind.helpers.ValidationEventImpl', + 'javax.xml.bind.helpers.ValidationEventLocatorImpl', + 'javax.xml.bind.util.JAXBResult', + 'javax.xml.bind.util.JAXBSource$1', + 'javax.xml.bind.util.JAXBSource', + 'javax.xml.bind.util.Messages', + 'javax.xml.bind.util.ValidationEventCollector' + ) +} else { + thirdPartyAudit.ignoreMissingClasses 'javax.activation.DataHandler' } thirdPartyAudit.ignoreViolations(