diff --git a/build.gradle b/build.gradle index ffd2e8e1382f8..8104f6e383d31 100644 --- a/build.gradle +++ b/build.gradle @@ -312,7 +312,7 @@ allprojects { } } boolean hasShadow = project.plugins.hasPlugin(ShadowPlugin) - project.configurations.compile.dependencies + project.configurations.implementation.dependencies .findAll() .toSorted(sortClosure) .each({ c -> depJavadocClosure(hasShadow, c) }) @@ -422,6 +422,12 @@ allprojects { tasks.named('cleanEclipse') { dependsOn 'wipeEclipseSettings' } // otherwise the eclipse merging is *super confusing* tasks.named('eclipse') { dependsOn 'cleanEclipse', 'copyEclipseSettings' } + + afterEvaluate { + tasks.findByName("eclipseJdt")?.configure { + dependsOn 'copyEclipseSettings' + } + } } wrapper { diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 87195a4ac3d41..dd3284cc32168 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -94,7 +94,8 @@ tasks.withType(JavaCompile).configureEach { *****************************************************************************/ repositories { - jcenter() + mavenCentral() + gradlePluginPortal() } dependencies { @@ -123,7 +124,7 @@ dependencies { testFixturesApi gradleTestKit() testImplementation 'com.github.tomakehurst:wiremock-jre8-standalone:2.23.2' testImplementation "org.mockito:mockito-core:${props.getProperty('mockito')}" - integTestImplementation('org.spockframework:spock-core:1.3-groovy-2.5') { + integTestImplementation('org.spockframework:spock-core:2.0-groovy-3.0') { exclude module: "groovy" } } @@ -259,6 +260,9 @@ if (project != rootProject) { */ afterEvaluate { generatePomFileForPluginMavenPublication.enabled = false + tasks.matching { it.name.contains("PluginMaven") }*.configure { + dependsOn("generatePomFileForNebulaPublication") + } } publishing.publications.named("nebula").configure { diff --git a/buildSrc/src/main/java/org/opensearch/gradle/LoggedExec.java b/buildSrc/src/main/java/org/opensearch/gradle/LoggedExec.java index 03873cc003e11..2831108b94452 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/LoggedExec.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/LoggedExec.java @@ -82,7 +82,7 @@ public LoggedExec(FileSystemOperations fileSystemOperations) { doLast(new Action() { @Override public void execute(Task task) { - if (LoggedExec.this.getExecResult().getExitValue() != 0) { + if (LoggedExec.this.getExecutionResult().get().getExitValue() != 0) { try { LoggedExec.this.getLogger().error("Output for " + LoggedExec.this.getExecutable() + ":"); outputLogger.accept(LoggedExec.this.getLogger()); @@ -94,7 +94,7 @@ public void execute(Task task) { "Process '%s %s' finished with non-zero exit value %d", LoggedExec.this.getExecutable(), LoggedExec.this.getArgs(), - LoggedExec.this.getExecResult().getExitValue() + LoggedExec.this.getExecutionResult().get().getExitValue() ) ); } diff --git a/buildSrc/src/main/java/org/opensearch/gradle/OpenSearchTestBasePlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/OpenSearchTestBasePlugin.java index b6dba360ddb27..556060d8afe4a 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/OpenSearchTestBasePlugin.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/OpenSearchTestBasePlugin.java @@ -74,7 +74,7 @@ public void apply(Project project) { File heapdumpDir = new File(project.getBuildDir(), "heapdump"); project.getTasks().withType(Test.class).configureEach(test -> { - File testOutputDir = new File(test.getReports().getJunitXml().getDestination(), "output"); + File testOutputDir = new File(test.getReports().getJunitXml().getOutputLocation().getAsFile().get(), "output"); ErrorReportingTestListener listener = new ErrorReportingTestListener(test.getTestLogging(), test.getLogger(), testOutputDir); test.getExtensions().add("errorReportingTestListener", listener); diff --git a/buildSrc/src/main/java/org/opensearch/gradle/RepositoriesSetupPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/RepositoriesSetupPlugin.java index 9396d03e4f5c6..30847f0648c5c 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/RepositoriesSetupPlugin.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/RepositoriesSetupPlugin.java @@ -82,7 +82,7 @@ public static void configureRepositories(Project project) { // such that we don't have to pass hardcoded files to gradle repos.mavenLocal(); } - repos.jcenter(); + repos.mavenCentral(); String luceneVersion = VersionProperties.getLucene(); if (luceneVersion.contains("-snapshot")) { diff --git a/buildSrc/src/main/java/org/opensearch/gradle/info/GlobalBuildInfoPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/info/GlobalBuildInfoPlugin.java index c1e96a3d9401e..60afe8334f05d 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/info/GlobalBuildInfoPlugin.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/info/GlobalBuildInfoPlugin.java @@ -41,11 +41,10 @@ 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.internal.jvm.inspection.JvmInstallationMetadata; +import org.gradle.internal.jvm.inspection.JvmMetadataDetector; import org.gradle.util.GradleVersion; import javax.inject.Inject; @@ -77,13 +76,13 @@ public class GlobalBuildInfoPlugin implements Plugin { private static final String DEFAULT_VERSION_JAVA_FILE_PATH = "server/src/main/java/org/opensearch/Version.java"; private static Integer _defaultParallel = null; - private final JavaInstallationRegistry javaInstallationRegistry; + private final JvmMetadataDetector jvmMetadataDetector; private final ObjectFactory objects; private final ProviderFactory providers; @Inject - public GlobalBuildInfoPlugin(JavaInstallationRegistry javaInstallationRegistry, ObjectFactory objects, ProviderFactory providers) { - this.javaInstallationRegistry = javaInstallationRegistry; + public GlobalBuildInfoPlugin(JvmMetadataDetector jvmMetadataDetector, ObjectFactory objects, ProviderFactory providers) { + this.jvmMetadataDetector = jvmMetadataDetector; this.objects = objects; this.providers = providers; } @@ -115,7 +114,7 @@ public void apply(Project project) { params.setRuntimeJavaHome(runtimeJavaHome); params.setRuntimeJavaVersion(determineJavaVersion("runtime java.home", runtimeJavaHome, minimumRuntimeVersion)); params.setIsRutimeJavaHomeSet(runtimeJavaHomeOpt.isPresent()); - params.setRuntimeJavaDetails(getJavaInstallation(runtimeJavaHome).getImplementationName()); + params.setRuntimeJavaDetails(getJavaInstallation(runtimeJavaHome).getDisplayName()); params.setJavaVersions(getAvailableJavaVersions(minimumCompilerVersion)); params.setMinimumCompilerVersion(minimumCompilerVersion); params.setMinimumRuntimeVersion(minimumRuntimeVersion); @@ -160,14 +159,14 @@ private void logGlobalBuildInfo() { 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(); + final String gradleJvmDetails = getJavaInstallation(gradleJvm.getJavaHome()).getDisplayName(); LOGGER.quiet("======================================="); LOGGER.quiet("OpenSearch Build Hamster says Hello!"); LOGGER.quiet(" Gradle Version : " + GradleVersion.current().getVersion()); LOGGER.quiet(" OS Info : " + osName + " " + osVersion + " (" + osArch + ")"); if (BuildParams.getIsRuntimeJavaHomeSet()) { - String runtimeJvmDetails = getJavaInstallation(BuildParams.getRuntimeJavaHome()).getImplementationName(); + String runtimeJvmDetails = getJavaInstallation(BuildParams.getRuntimeJavaHome()).getDisplayName(); LOGGER.quiet(" Runtime JDK Version : " + BuildParams.getRuntimeJavaVersion() + " (" + runtimeJvmDetails + ")"); LOGGER.quiet(" Runtime java.home : " + BuildParams.getRuntimeJavaHome()); LOGGER.quiet(" Gradle JDK Version : " + gradleJvm.getJavaVersion() + " (" + gradleJvmDetails + ")"); @@ -182,8 +181,8 @@ private void logGlobalBuildInfo() { } private JavaVersion determineJavaVersion(String description, File javaHome, JavaVersion requiredVersion) { - JavaInstallation installation = getJavaInstallation(javaHome); - JavaVersion actualVersion = installation.getJavaVersion(); + JvmInstallationMetadata installation = getJavaInstallation(javaHome); + JavaVersion actualVersion = installation.getLanguageVersion(); if (actualVersion.isCompatibleWith(requiredVersion) == false) { throwInvalidJavaHomeException( description, @@ -196,15 +195,8 @@ private JavaVersion determineJavaVersion(String description, File javaHome, Java 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 JvmInstallationMetadata getJavaInstallation(File javaHome) { + return jvmMetadataDetector.getMetadata(javaHome); } private List getAvailableJavaVersions(JavaVersion minimumCompilerVersion) { @@ -214,11 +206,9 @@ private List getAvailableJavaVersions(JavaVersion minimumCompilerVersi 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) - ); + JvmInstallationMetadata javaInstallation = jvmMetadataDetector.getMetadata(javaHomeDirectory); JavaHome javaHome = JavaHome.of(version, providers.provider(() -> { - int actualVersion = Integer.parseInt(javaInstallationProvider.get().getJavaVersion().getMajorVersion()); + int actualVersion = Integer.parseInt(javaInstallation.getLanguageVersion().getMajorVersion()); if (actualVersion != version) { throwInvalidJavaHomeException("env variable " + javaHomeEnvVarName, javaHomeDirectory, version, actualVersion); } diff --git a/buildSrc/src/main/java/org/opensearch/gradle/internal/BwcSetupExtension.java b/buildSrc/src/main/java/org/opensearch/gradle/internal/BwcSetupExtension.java index 53b89a5d783e8..402ac6947b53a 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/internal/BwcSetupExtension.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/internal/BwcSetupExtension.java @@ -39,6 +39,7 @@ import org.gradle.api.Action; import org.gradle.api.GradleException; import org.gradle.api.Project; +import org.gradle.api.Task; import org.gradle.api.logging.LogLevel; import org.gradle.api.provider.Provider; import org.gradle.api.tasks.TaskProvider; @@ -80,77 +81,83 @@ TaskProvider bwcTask(String name, Action configuration) } private TaskProvider createRunBwcGradleTask(Project project, String name, Action configAction) { - return project.getTasks().register(name, LoggedExec.class, loggedExec -> { - // TODO revisit - loggedExec.dependsOn("checkoutBwcBranch"); - loggedExec.setSpoolOutput(true); - loggedExec.setWorkingDir(checkoutDir.get()); - loggedExec.doFirst(t -> { - // Execution time so that the checkouts are available - String javaVersionsString = readFromFile(new File(checkoutDir.get(), ".ci/java-versions.properties")); - loggedExec.environment( - "JAVA_HOME", - getJavaHome( - Integer.parseInt( - Arrays.asList(javaVersionsString.split("\n")) - .stream() - .filter(l -> l.trim().startsWith("OPENSEARCH_BUILD_JAVA=")) - .map(l -> l.replace("OPENSEARCH_BUILD_JAVA=java", "").trim()) - .map(l -> l.replace("OPENSEARCH_BUILD_JAVA=openjdk", "").trim()) - .collect(Collectors.joining("!!")) - ) - ) - ); - loggedExec.environment( - "RUNTIME_JAVA_HOME", - getJavaHome( - Integer.parseInt( - Arrays.asList(javaVersionsString.split("\n")) - .stream() - .filter(l -> l.trim().startsWith("OPENSEARCH_RUNTIME_JAVA=")) - .map(l -> l.replace("OPENSEARCH_RUNTIME_JAVA=java", "").trim()) - .map(l -> l.replace("OPENSEARCH_RUNTIME_JAVA=openjdk", "").trim()) - .collect(Collectors.joining("!!")) - ) - ) - ); - }); - - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - loggedExec.executable("cmd"); - loggedExec.args("/C", "call", new File(checkoutDir.get(), "gradlew").toString()); - } else { - loggedExec.executable(new File(checkoutDir.get(), "gradlew").toString()); - } - if (project.getGradle().getStartParameter().isOffline()) { - loggedExec.args("--offline"); - } - // TODO resolve - String buildCacheUrl = System.getProperty("org.opensearch.build.cache.url"); - if (buildCacheUrl != null) { - loggedExec.args("-Dorg.opensearch.build.cache.url=" + buildCacheUrl); - } + return project.getTasks().register(name, LoggedExec.class, new Action() { + @Override + public void execute(LoggedExec loggedExec) { + // TODO revisit + loggedExec.dependsOn("checkoutBwcBranch"); + loggedExec.setSpoolOutput(true); + loggedExec.setWorkingDir(checkoutDir.get()); + loggedExec.doFirst(new Action() { + @Override + public void execute(Task t) { + // Execution time so that the checkouts are available + String javaVersionsString = readFromFile(new File(checkoutDir.get(), ".ci/java-versions.properties")); + loggedExec.environment( + "JAVA_HOME", + getJavaHome( + Integer.parseInt( + Arrays.asList(javaVersionsString.split("\n")) + .stream() + .filter(l -> l.trim().startsWith("OPENSEARCH_BUILD_JAVA=")) + .map(l -> l.replace("OPENSEARCH_BUILD_JAVA=java", "").trim()) + .map(l -> l.replace("OPENSEARCH_BUILD_JAVA=openjdk", "").trim()) + .collect(Collectors.joining("!!")) + ) + ) + ); + loggedExec.environment( + "RUNTIME_JAVA_HOME", + getJavaHome( + Integer.parseInt( + Arrays.asList(javaVersionsString.split("\n")) + .stream() + .filter(l -> l.trim().startsWith("OPENSEARCH_RUNTIME_JAVA=")) + .map(l -> l.replace("OPENSEARCH_RUNTIME_JAVA=java", "").trim()) + .map(l -> l.replace("OPENSEARCH_RUNTIME_JAVA=openjdk", "").trim()) + .collect(Collectors.joining("!!")) + ) + ) + ); + } + }); + + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + loggedExec.executable("cmd"); + loggedExec.args("/C", "call", new File(checkoutDir.get(), "gradlew").toString()); + } else { + loggedExec.executable(new File(checkoutDir.get(), "gradlew").toString()); + } + if (project.getGradle().getStartParameter().isOffline()) { + loggedExec.args("--offline"); + } + // TODO resolve + String buildCacheUrl = System.getProperty("org.opensearch.build.cache.url"); + if (buildCacheUrl != null) { + loggedExec.args("-Dorg.opensearch.build.cache.url=" + buildCacheUrl); + } - loggedExec.args("-Dbuild.snapshot=true"); - loggedExec.args("-Dscan.tag.NESTED"); - final LogLevel logLevel = project.getGradle().getStartParameter().getLogLevel(); - List nonDefaultLogLevels = Arrays.asList(LogLevel.QUIET, LogLevel.WARN, LogLevel.INFO, LogLevel.DEBUG); - if (nonDefaultLogLevels.contains(logLevel)) { - loggedExec.args("--" + logLevel.name().toLowerCase(Locale.ENGLISH)); - } - final String showStacktraceName = project.getGradle().getStartParameter().getShowStacktrace().name(); - assert Arrays.asList("INTERNAL_EXCEPTIONS", "ALWAYS", "ALWAYS_FULL").contains(showStacktraceName); - if (showStacktraceName.equals("ALWAYS")) { - loggedExec.args("--stacktrace"); - } else if (showStacktraceName.equals("ALWAYS_FULL")) { - loggedExec.args("--full-stacktrace"); - } - if (project.getGradle().getStartParameter().isParallelProjectExecutionEnabled()) { - loggedExec.args("--parallel"); + loggedExec.args("-Dbuild.snapshot=true"); + loggedExec.args("-Dscan.tag.NESTED"); + final LogLevel logLevel = project.getGradle().getStartParameter().getLogLevel(); + List nonDefaultLogLevels = Arrays.asList(LogLevel.QUIET, LogLevel.WARN, LogLevel.INFO, LogLevel.DEBUG); + if (nonDefaultLogLevels.contains(logLevel)) { + loggedExec.args("--" + logLevel.name().toLowerCase(Locale.ENGLISH)); + } + final String showStacktraceName = project.getGradle().getStartParameter().getShowStacktrace().name(); + assert Arrays.asList("INTERNAL_EXCEPTIONS", "ALWAYS", "ALWAYS_FULL").contains(showStacktraceName); + if (showStacktraceName.equals("ALWAYS")) { + loggedExec.args("--stacktrace"); + } else if (showStacktraceName.equals("ALWAYS_FULL")) { + loggedExec.args("--full-stacktrace"); + } + if (project.getGradle().getStartParameter().isParallelProjectExecutionEnabled()) { + loggedExec.args("--parallel"); + } + loggedExec.setStandardOutput(new IndentingOutputStream(System.out, unreleasedVersionInfo.get().version)); + loggedExec.setErrorOutput(new IndentingOutputStream(System.err, unreleasedVersionInfo.get().version)); + configAction.execute(loggedExec); } - loggedExec.setStandardOutput(new IndentingOutputStream(System.out, unreleasedVersionInfo.get().version)); - loggedExec.setErrorOutput(new IndentingOutputStream(System.err, unreleasedVersionInfo.get().version)); - configAction.execute(loggedExec); }); } diff --git a/buildSrc/src/main/java/org/opensearch/gradle/internal/InternalDistributionBwcSetupPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/internal/InternalDistributionBwcSetupPlugin.java index e05c68e258ad6..dd2393702fe2b 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/internal/InternalDistributionBwcSetupPlugin.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/internal/InternalDistributionBwcSetupPlugin.java @@ -33,9 +33,11 @@ package org.opensearch.gradle.internal; import org.opensearch.gradle.BwcVersions; +import org.opensearch.gradle.LoggedExec; import org.opensearch.gradle.Version; import org.opensearch.gradle.info.BuildParams; import org.opensearch.gradle.info.GlobalBuildInfoPlugin; +import org.gradle.api.Action; import org.gradle.api.InvalidUserDataException; import org.gradle.api.Plugin; import org.gradle.api.Project; @@ -204,24 +206,30 @@ static void createBuildBwcTask( TaskProvider bwcTaskProvider ) { String bwcTaskName = buildBwcTaskName(projectName); - bwcSetupExtension.bwcTask(bwcTaskName, c -> { - c.getInputs().file(new File(project.getBuildDir(), "refspec")); - c.getOutputs().files(projectArtifact); - c.getOutputs().cacheIf("BWC distribution caching is disabled on 'master' branch", task -> { - String gitBranch = System.getenv("GIT_BRANCH"); - return BuildParams.isCi() && (gitBranch == null || gitBranch.endsWith("master") == false); - }); - c.args(projectPath.replace('/', ':') + ":assemble"); - if (project.getGradle().getStartParameter().isBuildCacheEnabled()) { - c.args("--build-cache"); - } - c.doLast(task -> { - if (projectArtifact.exists() == false) { - throw new InvalidUserDataException( - "Building " + bwcVersion.get() + " didn't generate expected file " + projectArtifact - ); + bwcSetupExtension.bwcTask(bwcTaskName, new Action() { + @Override + public void execute(LoggedExec c) { + c.getInputs().file(new File(project.getBuildDir(), "refspec")); + c.getOutputs().files(projectArtifact); + c.getOutputs().cacheIf("BWC distribution caching is disabled on 'master' branch", task -> { + String gitBranch = System.getenv("GIT_BRANCH"); + return BuildParams.isCi() && (gitBranch == null || gitBranch.endsWith("master") == false); + }); + c.args(projectPath.replace('/', ':') + ":assemble"); + if (project.getGradle().getStartParameter().isBuildCacheEnabled()) { + c.args("--build-cache"); } - }); + c.doLast(new Action() { + @Override + public void execute(Task task) { + if (projectArtifact.exists() == false) { + throw new InvalidUserDataException( + "Building " + bwcVersion.get() + " didn't generate expected file " + projectArtifact + ); + } + } + }); + } }); bwcTaskProvider.configure(t -> t.dependsOn(bwcTaskName)); } diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/JarHellPrecommitPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/JarHellPrecommitPlugin.java index 04ae37f92bcc9..87bf03cec3587 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/JarHellPrecommitPlugin.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/precommit/JarHellPrecommitPlugin.java @@ -53,9 +53,16 @@ public TaskProvider createTask(Project project) { TaskProvider jarHell = project.getTasks().register("jarHell", JarHellTask.class); jarHell.configure(t -> { - SourceSet testSourceSet = Util.getJavaTestSourceSet(project).get(); + final Task testClassesTask = project.getTasks().getByName("testClasses"); + final SourceSet testSourceSet = Util.getJavaTestSourceSet(project).get(); t.setClasspath(testSourceSet.getRuntimeClasspath().plus(jarHellConfig)); - t.dependsOn(jarHellConfig); + t.dependsOn(jarHellConfig, testClassesTask); + + // if this a plugin, we need to add dependency on pluginProperties task + project.getPluginManager().withPlugin("opensearch.opensearchplugin", plugin -> { + Task propertiesTask = project.getTasks().getByName("pluginProperties"); + t.dependsOn(jarHellConfig, testClassesTask, propertiesTask); + }); }); return jarHell; diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/JarHellTask.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/JarHellTask.java index e642aaee754e7..c6a0d7abf7da1 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/JarHellTask.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/precommit/JarHellTask.java @@ -33,6 +33,7 @@ package org.opensearch.gradle.precommit; import org.opensearch.gradle.LoggedExec; + import org.gradle.api.file.FileCollection; import org.gradle.api.tasks.CacheableTask; import org.gradle.api.tasks.CompileClasspath; @@ -56,7 +57,7 @@ public JarHellTask() { public void runJarHellCheck() { LoggedExec.javaexec(getProject(), spec -> { spec.environment("CLASSPATH", getClasspath().getAsPath()); - spec.setMain("org.opensearch.bootstrap.JarHell"); + spec.getMainClass().set("org.opensearch.bootstrap.JarHell"); }); } diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/LoggerUsageTask.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/LoggerUsageTask.java index 7ce0c0cecff81..1fd092b7f268f 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/LoggerUsageTask.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/precommit/LoggerUsageTask.java @@ -61,7 +61,7 @@ public LoggerUsageTask() { @TaskAction public void runLoggerUsageTask() { LoggedExec.javaexec(getProject(), spec -> { - spec.setMain("org.opensearch.test.loggerusage.OpenSearchLoggerUsageChecker"); + spec.getMainClass().set("org.opensearch.test.loggerusage.OpenSearchLoggerUsageChecker"); spec.classpath(getClasspath()); getClassDirectories().forEach(spec::args); }); diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/ThirdPartyAuditTask.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/ThirdPartyAuditTask.java index 8be3f3b8e9b95..ee68d2740e279 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/ThirdPartyAuditTask.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/precommit/ThirdPartyAuditTask.java @@ -281,10 +281,6 @@ private void logForbiddenAPIsOutput(String forbiddenApisOutput) { getLogger().error("Forbidden APIs output:\n{}==end of forbidden APIs==", forbiddenApisOutput); } - private void throwNotConfiguredCorrectlyException() { - throw new IllegalArgumentException("Audit of third party dependencies is not configured correctly"); - } - private void extractJars(Set jars) { File jarExpandDir = getJarExpandDir(); // We need to clean up to make sure old dependencies don't linger @@ -360,7 +356,7 @@ private String runForbiddenAPIsCli() throws IOException { ); spec.jvmArgs("-Xmx1g"); spec.jvmArgs(LoggedExec.shortLivedArgs()); - spec.setMain("de.thetaphi.forbiddenapis.cli.CliMain"); + spec.getMainClass().set("de.thetaphi.forbiddenapis.cli.CliMain"); spec.args("-f", getSignatureFile().getAbsolutePath(), "-d", getJarExpandDir(), "--allowmissingclasses"); spec.setErrorOutput(errorOut); if (getLogger().isInfoEnabled() == false) { @@ -390,7 +386,7 @@ private Set runJdkJarHellCheck() throws IOException { getProject().getConfigurations().getByName(CompileOnlyResolvePlugin.RESOLVEABLE_COMPILE_ONLY_CONFIGURATION_NAME) ); - spec.setMain(JDK_JAR_HELL_MAIN_CLASS); + spec.getMainClass().set(JDK_JAR_HELL_MAIN_CLASS); spec.args(getJarExpandDir()); spec.setIgnoreExitValue(true); if (javaHome != null) { diff --git a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java index 17f8d455f6a27..ab480cef56772 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java @@ -1385,25 +1385,27 @@ private Path getExtractedDistributionDir() { return distributions.get(currentDistro).getExtracted().getSingleFile().toPath(); } - private List getInstalledFileSet(Action filter) { - return Stream.concat(plugins.stream().map(Provider::get), modules.stream().map(Provider::get)) - .filter(File::exists) - // TODO: We may be able to simplify this with Gradle 5.6 - // https://docs.gradle.org/nightly/release-notes.html#improved-handling-of-zip-archives-on-classpaths - .map(zipFile -> archiveOperations.zipTree(zipFile).matching(filter)) - .flatMap(tree -> tree.getFiles().stream()) - .sorted(Comparator.comparing(File::getName)) + private List>> getInstalledFileSet(Action filter) { + return Stream.concat(plugins.stream(), modules.stream()).map(p -> p.map(f -> { + if (f.exists()) { + final FileTree tree = archiveOperations.zipTree(f).matching(filter); + return tree.getFiles(); + } else { + return new HashSet(); + } + })) + .map(p -> p.map(f -> f.stream().sorted(Comparator.comparing(File::getName)).collect(Collectors.toList()))) .collect(Collectors.toList()); } @Classpath - public List getInstalledClasspath() { + public List>> getInstalledClasspath() { return getInstalledFileSet(filter -> filter.include("**/*.jar")); } @InputFiles @PathSensitive(PathSensitivity.RELATIVE) - public List getInstalledFiles() { + public List>> getInstalledFiles() { return getInstalledFileSet(filter -> filter.exclude("**/*.jar")); } diff --git a/buildSrc/src/main/java/org/opensearch/gradle/testfixtures/TestFixturesPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/testfixtures/TestFixturesPlugin.java index d6a13f550dffb..2872f9d984c19 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/testfixtures/TestFixturesPlugin.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/testfixtures/TestFixturesPlugin.java @@ -112,27 +112,42 @@ public void apply(Project project) { project.getPluginManager().apply(BasePlugin.class); project.getPluginManager().apply(DockerComposePlugin.class); - TaskProvider preProcessFixture = project.getTasks().register("preProcessFixture", t -> { - t.getOutputs().dir(testfixturesDir); - t.doFirst(t2 -> { - try { - Files.createDirectories(testfixturesDir.toPath()); - } catch (IOException e) { - throw new UncheckedIOException(e); - } - }); + TaskProvider preProcessFixture = project.getTasks().register("preProcessFixture", new Action() { + @Override + public void execute(Task t) { + t.getOutputs().dir(testfixturesDir); + t.doFirst(new Action() { + @Override + public void execute(Task t2) { + { + try { + Files.createDirectories(testfixturesDir.toPath()); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + } + }); + } + }); + TaskProvider buildFixture = project.getTasks().register("buildFixture", new Action() { + @Override + public void execute(Task t) { + t.dependsOn(preProcessFixture, tasks.named("composeUp")); + } }); - TaskProvider buildFixture = project.getTasks() - .register("buildFixture", t -> t.dependsOn(preProcessFixture, tasks.named("composeUp"))); - - TaskProvider postProcessFixture = project.getTasks().register("postProcessFixture", task -> { - task.dependsOn(buildFixture); - configureServiceInfoForTask( - task, - project, - false, - (name, port) -> task.getExtensions().getByType(ExtraPropertiesExtension.class).set(name, port) - ); + + TaskProvider postProcessFixture = project.getTasks().register("postProcessFixture", new Action() { + @Override + public void execute(Task task) { + task.dependsOn(buildFixture); + configureServiceInfoForTask( + task, + project, + false, + (name, port) -> task.getExtensions().getByType(ExtraPropertiesExtension.class).set(name, port) + ); + } }); maybeSkipTask(dockerSupport, preProcessFixture); diff --git a/buildSrc/src/main/java/org/opensearch/gradle/util/GradleUtils.java b/buildSrc/src/main/java/org/opensearch/gradle/util/GradleUtils.java index 772e52a48a6f2..01622e6df3ee1 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/util/GradleUtils.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/util/GradleUtils.java @@ -187,9 +187,9 @@ public static void setupIdeForTestSourceSet(Project project, SourceSet testSourc */ public static void extendSourceSet(Project project, String parentSourceSetName, String childSourceSetName) { final List> configNameFunctions = Arrays.asList( - SourceSet::getCompileConfigurationName, + SourceSet::getCompileClasspathConfigurationName, SourceSet::getImplementationConfigurationName, - SourceSet::getRuntimeConfigurationName, + SourceSet::getRuntimeClasspathConfigurationName, SourceSet::getRuntimeOnlyConfigurationName ); SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); diff --git a/buildSrc/src/test/java/org/opensearch/gradle/precommit/DependencyLicensesTaskTests.java b/buildSrc/src/test/java/org/opensearch/gradle/precommit/DependencyLicensesTaskTests.java index 59f7a807476a0..6bb6b90116394 100644 --- a/buildSrc/src/test/java/org/opensearch/gradle/precommit/DependencyLicensesTaskTests.java +++ b/buildSrc/src/test/java/org/opensearch/gradle/precommit/DependencyLicensesTaskTests.java @@ -95,7 +95,7 @@ public void givenProjectWithoutLicensesDirButWithDependenciesThenShouldThrowExce expectedException.expect(GradleException.class); expectedException.expectMessage(containsString("does not exist, but there are dependencies")); - project.getDependencies().add("compile", dependency); + project.getDependencies().add("compileClasspath", dependency); task.get().checkDependencies(); } @@ -110,10 +110,10 @@ public void givenProjectWithDependencyButNoShaFileThenShouldReturnException() th expectedException.expectMessage(containsString("Missing SHA for ")); File licensesDir = getLicensesDir(project); - createFileIn(licensesDir, "groovy-all-LICENSE.txt", PERMISSIVE_LICENSE_TEXT); - createFileIn(licensesDir, "groovy-all-NOTICE.txt", ""); + createFileIn(licensesDir, "groovy-LICENSE.txt", PERMISSIVE_LICENSE_TEXT); + createFileIn(licensesDir, "groovy-NOTICE.txt", ""); - project.getDependencies().add("compile", project.getDependencies().localGroovy()); + project.getDependencies().add("compileClasspath", project.getDependencies().localGroovy()); task.get().checkDependencies(); } @@ -122,7 +122,7 @@ public void givenProjectWithDependencyButNoLicenseFileThenShouldReturnException( expectedException.expect(GradleException.class); expectedException.expectMessage(containsString("Missing LICENSE for ")); - project.getDependencies().add("compile", project.getDependencies().localGroovy()); + project.getDependencies().add("compileClasspath", project.getDependencies().localGroovy()); getLicensesDir(project).mkdir(); updateShas.updateShas(); @@ -134,9 +134,9 @@ public void givenProjectWithDependencyButNoNoticeFileThenShouldReturnException() expectedException.expect(GradleException.class); expectedException.expectMessage(containsString("Missing NOTICE for ")); - project.getDependencies().add("compile", dependency); + project.getDependencies().add("compileClasspath", dependency); - createFileIn(getLicensesDir(project), "groovy-all-LICENSE.txt", PERMISSIVE_LICENSE_TEXT); + createFileIn(getLicensesDir(project), "groovy-LICENSE.txt", PERMISSIVE_LICENSE_TEXT); updateShas.updateShas(); task.get().checkDependencies(); @@ -147,10 +147,10 @@ public void givenProjectWithStrictDependencyButNoSourcesFileThenShouldReturnExce expectedException.expect(GradleException.class); expectedException.expectMessage(containsString("Missing SOURCES for ")); - project.getDependencies().add("compile", dependency); + project.getDependencies().add("compileClasspath", dependency); - createFileIn(getLicensesDir(project), "groovy-all-LICENSE.txt", STRICT_LICENSE_TEXT); - createFileIn(getLicensesDir(project), "groovy-all-NOTICE.txt", ""); + createFileIn(getLicensesDir(project), "groovy-LICENSE.txt", STRICT_LICENSE_TEXT); + createFileIn(getLicensesDir(project), "groovy-NOTICE.txt", ""); updateShas.updateShas(); task.get().checkDependencies(); @@ -158,11 +158,15 @@ public void givenProjectWithStrictDependencyButNoSourcesFileThenShouldReturnExce @Test public void givenProjectWithStrictDependencyAndEverythingInOrderThenShouldReturnSilently() throws Exception { - project.getDependencies().add("compile", dependency); + project.getDependencies().add("compileClasspath", dependency); - createFileIn(getLicensesDir(project), "groovy-all-LICENSE.txt", STRICT_LICENSE_TEXT); - createFileIn(getLicensesDir(project), "groovy-all-NOTICE.txt", ""); - createFileIn(getLicensesDir(project), "groovy-all-SOURCES.txt", ""); + createFileIn(getLicensesDir(project), "groovy-LICENSE.txt", STRICT_LICENSE_TEXT); + createFileIn(getLicensesDir(project), "groovy-NOTICE.txt", ""); + createFileIn(getLicensesDir(project), "groovy-SOURCES.txt", ""); + + createFileIn(getLicensesDir(project), "javaparser-core-LICENSE.txt", STRICT_LICENSE_TEXT); + createFileIn(getLicensesDir(project), "javaparser-core-NOTICE.txt", ""); + createFileIn(getLicensesDir(project), "javaparser-core-SOURCES.txt", ""); updateShas.updateShas(); task.get().checkDependencies(); @@ -170,11 +174,11 @@ public void givenProjectWithStrictDependencyAndEverythingInOrderThenShouldReturn @Test public void givenProjectWithDependencyAndEverythingInOrderThenShouldReturnSilently() throws Exception { - project.getDependencies().add("compile", dependency); + project.getDependencies().add("compileClasspath", dependency); File licensesDir = getLicensesDir(project); - createAllDefaultDependencyFiles(licensesDir, "groovy-all"); + createAllDefaultDependencyFiles(licensesDir, "groovy", "javaparser-core"); task.get().checkDependencies(); } @@ -183,10 +187,10 @@ public void givenProjectWithALicenseButWithoutTheDependencyThenShouldThrowExcept expectedException.expect(GradleException.class); expectedException.expectMessage(containsString("Unused license ")); - project.getDependencies().add("compile", dependency); + project.getDependencies().add("compileClasspath", dependency); File licensesDir = getLicensesDir(project); - createAllDefaultDependencyFiles(licensesDir, "groovy-all"); + createAllDefaultDependencyFiles(licensesDir, "groovy", "javaparser-core"); createFileIn(licensesDir, "non-declared-LICENSE.txt", ""); task.get().checkDependencies(); @@ -197,10 +201,10 @@ public void givenProjectWithANoticeButWithoutTheDependencyThenShouldThrowExcepti expectedException.expect(GradleException.class); expectedException.expectMessage(containsString("Unused notice ")); - project.getDependencies().add("compile", dependency); + project.getDependencies().add("compileClasspath", dependency); File licensesDir = getLicensesDir(project); - createAllDefaultDependencyFiles(licensesDir, "groovy-all"); + createAllDefaultDependencyFiles(licensesDir, "groovy", "javaparser-core"); createFileIn(licensesDir, "non-declared-NOTICE.txt", ""); task.get().checkDependencies(); @@ -211,10 +215,10 @@ public void givenProjectWithAShaButWithoutTheDependencyThenShouldThrowException( expectedException.expect(GradleException.class); expectedException.expectMessage(containsString("Unused sha files found: \n")); - project.getDependencies().add("compile", dependency); + project.getDependencies().add("compileClasspath", dependency); File licensesDir = getLicensesDir(project); - createAllDefaultDependencyFiles(licensesDir, "groovy-all"); + createAllDefaultDependencyFiles(licensesDir, "groovy", "javaparser-core"); createFileIn(licensesDir, "non-declared.sha1", ""); task.get().checkDependencies(); @@ -225,10 +229,10 @@ public void givenProjectWithADependencyWithWrongShaThenShouldThrowException() th expectedException.expect(GradleException.class); expectedException.expectMessage(containsString("SHA has changed! Expected ")); - project.getDependencies().add("compile", dependency); + project.getDependencies().add("compileClasspath", dependency); File licensesDir = getLicensesDir(project); - createAllDefaultDependencyFiles(licensesDir, "groovy-all"); + createAllDefaultDependencyFiles(licensesDir, "groovy"); Path groovySha = Files.list(licensesDir.toPath()).filter(file -> file.toFile().getName().contains("sha")).findFirst().get(); @@ -239,14 +243,14 @@ public void givenProjectWithADependencyWithWrongShaThenShouldThrowException() th @Test public void givenProjectWithADependencyMappingThenShouldReturnSilently() throws Exception { - project.getDependencies().add("compile", dependency); + project.getDependencies().add("compileClasspath", dependency); File licensesDir = getLicensesDir(project); - createAllDefaultDependencyFiles(licensesDir, "groovy"); + createAllDefaultDependencyFiles(licensesDir, "groovy", "javaparser"); Map mappings = new HashMap<>(); - mappings.put("from", "groovy-all"); - mappings.put("to", "groovy"); + mappings.put("from", "javaparser-core"); + mappings.put("to", "javaparser"); task.get().mapping(mappings); task.get().checkDependencies(); @@ -254,13 +258,30 @@ public void givenProjectWithADependencyMappingThenShouldReturnSilently() throws @Test public void givenProjectWithAIgnoreShaConfigurationAndNoShaFileThenShouldReturnSilently() throws Exception { - project.getDependencies().add("compile", dependency); + project.getDependencies().add("compileClasspath", dependency); File licensesDir = getLicensesDir(project); - createFileIn(licensesDir, "groovy-all-LICENSE.txt", PERMISSIVE_LICENSE_TEXT); - createFileIn(licensesDir, "groovy-all-NOTICE.txt", ""); + createFileIn(licensesDir, "groovy-LICENSE.txt", PERMISSIVE_LICENSE_TEXT); + createFileIn(licensesDir, "groovy-NOTICE.txt", ""); + + createFileIn(licensesDir, "javaparser-core-LICENSE.txt", PERMISSIVE_LICENSE_TEXT); + createFileIn(licensesDir, "javaparser-core-NOTICE.txt", ""); + + task.get().ignoreSha("groovy"); + task.get().ignoreSha("groovy-ant"); + task.get().ignoreSha("groovy-astbuilder"); + task.get().ignoreSha("groovy-console"); + task.get().ignoreSha("groovy-datetime"); + task.get().ignoreSha("groovy-dateutil"); + task.get().ignoreSha("groovy-groovydoc"); + task.get().ignoreSha("groovy-json"); + task.get().ignoreSha("groovy-nio"); + task.get().ignoreSha("groovy-sql"); + task.get().ignoreSha("groovy-templates"); + task.get().ignoreSha("groovy-test"); + task.get().ignoreSha("groovy-xml"); + task.get().ignoreSha("javaparser-core"); - task.get().ignoreSha("groovy-all"); task.get().checkDependencies(); } @@ -279,9 +300,11 @@ private Project createProject() { return project; } - private void createAllDefaultDependencyFiles(File licensesDir, String dependencyName) throws IOException, NoSuchAlgorithmException { - createFileIn(licensesDir, dependencyName + "-LICENSE.txt", PERMISSIVE_LICENSE_TEXT); - createFileIn(licensesDir, dependencyName + "-NOTICE.txt", ""); + private void createAllDefaultDependencyFiles(File licensesDir, String... dependencyNames) throws IOException, NoSuchAlgorithmException { + for (final String dependencyName : dependencyNames) { + createFileIn(licensesDir, dependencyName + "-LICENSE.txt", PERMISSIVE_LICENSE_TEXT); + createFileIn(licensesDir, dependencyName + "-NOTICE.txt", ""); + } updateShas.updateShas(); } @@ -316,6 +339,12 @@ private TaskProvider createDependencyLicensesTask(Projec @Override public void execute(DependencyLicensesTask dependencyLicensesTask) { dependencyLicensesTask.setDependencies(getDependencies(project)); + + final Map mappings = new HashMap<>(); + mappings.put("from", "groovy-.*"); + mappings.put("to", "groovy"); + + dependencyLicensesTask.mapping(mappings); } }); @@ -323,6 +352,6 @@ public void execute(DependencyLicensesTask dependencyLicensesTask) { } private FileCollection getDependencies(Project project) { - return project.getConfigurations().getByName("compile"); + return project.getConfigurations().getByName("compileClasspath"); } } diff --git a/buildSrc/src/test/java/org/opensearch/gradle/precommit/UpdateShasTaskTests.java b/buildSrc/src/test/java/org/opensearch/gradle/precommit/UpdateShasTaskTests.java index 084b3b9149e33..ded9c2e3bcddf 100644 --- a/buildSrc/src/test/java/org/opensearch/gradle/precommit/UpdateShasTaskTests.java +++ b/buildSrc/src/test/java/org/opensearch/gradle/precommit/UpdateShasTaskTests.java @@ -86,19 +86,19 @@ public void whenDependencyDoesntExistThenShouldDeleteDependencySha() throws IOEx @Test public void whenDependencyExistsButShaNotThenShouldCreateNewShaFile() throws IOException, NoSuchAlgorithmException { - project.getDependencies().add("compile", dependency); + project.getDependencies().add("compileClasspath", dependency); getLicensesDir(project).mkdir(); task.updateShas(); Path groovySha = Files.list(getLicensesDir(project).toPath()).findFirst().get(); - assertTrue(groovySha.toFile().getName().startsWith("groovy-all")); + assertTrue(groovySha.toFile().getName().startsWith("groovy-")); } @Test public void whenDependencyAndWrongShaExistsThenShouldNotOverwriteShaFile() throws IOException, NoSuchAlgorithmException { - project.getDependencies().add("compile", dependency); + project.getDependencies().add("compileClasspath", dependency); File groovyJar = task.getParentTask().getDependencies().getFiles().iterator().next(); String groovyShaName = groovyJar.getName() + ".sha1"; @@ -163,6 +163,6 @@ public void execute(DependencyLicensesTask dependencyLicensesTask) { } private FileCollection getDependencies(Project project) { - return project.getConfigurations().getByName("compile"); + return project.getConfigurations().getByName("compileClasspath"); } } diff --git a/buildSrc/src/testFixtures/java/org/opensearch/gradle/test/GradleThreadsFilter.java b/buildSrc/src/testFixtures/java/org/opensearch/gradle/test/GradleThreadsFilter.java index 8f930bacdfa08..b64c719440733 100644 --- a/buildSrc/src/testFixtures/java/org/opensearch/gradle/test/GradleThreadsFilter.java +++ b/buildSrc/src/testFixtures/java/org/opensearch/gradle/test/GradleThreadsFilter.java @@ -43,6 +43,8 @@ public class GradleThreadsFilter implements ThreadFilter { @Override public boolean reject(Thread t) { - return t.getName().startsWith("Exec process") || t.getName().startsWith("File watcher consumer"); + return t.getName().startsWith("Exec process") + || t.getName().startsWith("Memory manager") + || t.getName().startsWith("File watcher consumer"); } } diff --git a/buildSrc/src/testKit/opensearch.build/build.gradle b/buildSrc/src/testKit/opensearch.build/build.gradle index be1d34db7d286..a0093eb1d2cd1 100644 --- a/buildSrc/src/testKit/opensearch.build/build.gradle +++ b/buildSrc/src/testKit/opensearch.build/build.gradle @@ -39,7 +39,7 @@ repositories { artifact() } } - jcenter() + mavenCentral() } repositories { @@ -53,7 +53,7 @@ repositories { artifact() } } - jcenter() + mavenCentral() } // todo remove offending rules diff --git a/buildSrc/src/testKit/testingConventions/build.gradle b/buildSrc/src/testKit/testingConventions/build.gradle index 57179bf8407a3..309a9d64d4170 100644 --- a/buildSrc/src/testKit/testingConventions/build.gradle +++ b/buildSrc/src/testKit/testingConventions/build.gradle @@ -18,7 +18,7 @@ allprojects { apply plugin: 'opensearch.build' repositories { - jcenter() + mavenCentral() } dependencies { testImplementation "junit:junit:4.13.1" diff --git a/buildSrc/src/testKit/thirdPartyAudit/build.gradle b/buildSrc/src/testKit/thirdPartyAudit/build.gradle index f323e538a0b87..21b0fc3e74f57 100644 --- a/buildSrc/src/testKit/thirdPartyAudit/build.gradle +++ b/buildSrc/src/testKit/thirdPartyAudit/build.gradle @@ -36,7 +36,7 @@ repositories { artifact() } } - jcenter() + mavenCentral() } dependencies { diff --git a/distribution/packages/build.gradle b/distribution/packages/build.gradle index 921439f750205..e5c75af5188e5 100644 --- a/distribution/packages/build.gradle +++ b/distribution/packages/build.gradle @@ -63,7 +63,7 @@ import java.util.regex.Pattern */ plugins { - id "nebula.ospackage-base" version "8.3.0" + id "nebula.ospackage-base" version "9.0.0" } void addProcessFilesTask(String type, boolean jdk) { @@ -136,9 +136,9 @@ Closure commonPackageConfig(String type, boolean jdk, String architecture) { // SystemPackagingTask overrides default archive task convention mappings, but doesn't provide a setter so we have to override the convention mapping itself // Deb convention uses a '_' for final separator before architecture, rpm uses a '.' if (type == 'deb') { - conventionMapping.archiveFile = { objects.fileProperty().fileValue(file("${destinationDirectory.get()}/${packageName}-min_${project.version}${jdkString}_${archString}.${type}")) } + archiveFileName.value(project.provider({ "${destinationDirectory.get()}/${packageName}-min_${project.version}${jdkString}_${archString}.${type}" })) } else { - conventionMapping.archiveFile = { objects.fileProperty().fileValue(file("${destinationDirectory.get()}/${packageName}-min-${project.version}${jdkString}.${archString}.${type}")) } + archiveFileName.value(project.provider({ "${destinationDirectory.get()}/${packageName}-min-${project.version}${jdkString}.${archString}.${type}" })) } String packagingFiles = "build/packaging/${jdk ? '' : 'no-jdk-'}${type}" diff --git a/gradle/code-coverage.gradle b/gradle/code-coverage.gradle index 34fdf5d99ed84..de041eae7b72d 100644 --- a/gradle/code-coverage.gradle +++ b/gradle/code-coverage.gradle @@ -22,6 +22,7 @@ allprojects { def codeCoverageReportTask = tasks.register("codeCoverageReport", JacocoReport) { description = 'Generates aggregate report from all subprojects.' executionData.setFrom fileTree(dir: '.', include: '**/build/jacoco/*.exec') + dependsOn subprojects.findAll(s -> s.tasks.findByName('check') != null).check } tasks.register("codeCoverageReportForUnitTest", JacocoReport) { @@ -46,10 +47,12 @@ tasks.withType(JacocoReport).configureEach { def projectsWithJavaPlugin = subprojects.findAll { it.pluginManager.hasPlugin('java') } def projectsWithUnitTest = projectsWithJavaPlugin.findAll { it.tasks.findByName('test').enabled } def projectsWithIntegTest = projectsWithJavaPlugin.findAll {it.tasks.findByName('integTest')} + def projectsWithAsyncIntegTest = projectsWithJavaPlugin.findAll {it.tasks.findByName('asyncIntegTest')} def projectsWithInternalClusterTest = projectsWithJavaPlugin.findAll {it.tasks.findByName('internalClusterTest')} + def projectsWithPooledInternalClusterTest = projectsWithJavaPlugin.findAll {it.tasks.findByName('pooledInternalClusterTest')} def projectsWithJavaRestTest = projectsWithJavaPlugin.findAll {it.tasks.findByName('javaRestTest')} def projectsWithYamlRestTest = projectsWithJavaPlugin.findAll {it.tasks.findByName('yamlRestTest')} - def projectsWithIntegrationTest = projectsWithIntegTest + projectsWithInternalClusterTest + projectsWithJavaRestTest + projectsWithYamlRestTest + def projectsWithIntegrationTest = projectsWithIntegTest + projectsWithAsyncIntegTest + projectsWithInternalClusterTest + projectsWithPooledInternalClusterTest + projectsWithJavaRestTest + projectsWithYamlRestTest def projectsWithTest = projectsWithUnitTest + projectsWithIntegrationTest def selectedProjects @@ -60,7 +63,9 @@ tasks.withType(JacocoReport).configureEach { break case "codeCoverageReportForIntegrationTest": dependsOn projectsWithIntegTest.integTest + dependsOn projectsWithAsyncIntegTest.asyncIntegTest dependsOn projectsWithInternalClusterTest.internalClusterTest + dependsOn projectsWithPooledInternalClusterTest.pooledInternalClusterTest dependsOn projectsWithJavaRestTest.javaRestTest dependsOn projectsWithYamlRestTest.yamlRestTest selectedProjects = projectsWithIntegrationTest @@ -68,20 +73,23 @@ tasks.withType(JacocoReport).configureEach { default: dependsOn projectsWithUnitTest.test dependsOn projectsWithIntegTest.integTest + dependsOn projectsWithAsyncIntegTest.asyncIntegTest dependsOn projectsWithInternalClusterTest.internalClusterTest + dependsOn projectsWithPooledInternalClusterTest.pooledInternalClusterTest dependsOn projectsWithJavaRestTest.javaRestTest dependsOn projectsWithYamlRestTest.yamlRestTest - selectedProjects = projectsWithTest + selectedProjects = projectsWithJavaPlugin break } + sourceDirectories.setFrom files(selectedProjects.sourceSets.main.allSource.srcDirs) classDirectories.setFrom files(selectedProjects.sourceSets.main.output) reports { // Code coverage report in HTML and CSV formats are on demand, in case they take extra disk space. - xml.enabled System.getProperty('tests.coverage.report.xml', 'true').toBoolean() - html.enabled System.getProperty('tests.coverage.report.html', 'false').toBoolean() - csv.enabled System.getProperty('tests.coverage.report.csv', 'false').toBoolean() + xml.getRequired().set(System.getProperty('tests.coverage.report.xml', 'true').toBoolean()) + html.getRequired().set(System.getProperty('tests.coverage.report.html', 'false').toBoolean()) + csv.getRequired().set(System.getProperty('tests.coverage.report.csv', 'false').toBoolean()) } } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e708b1c023ec8..7454180f2ae88 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f24ec6254c6bb..e7095967a87b7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -11,7 +11,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionSha256Sum=11657af6356b7587bfb37287b5992e94a9686d5c8a0a1b60b87b9928a2decde5 +distributionSha256Sum=00b273629df4ce46e68df232161d5a7c4e495b9a029ce6e0420f071e21316867 diff --git a/modules/reindex/build.gradle b/modules/reindex/build.gradle index c77c51727df5a..6639e799cdd5d 100644 --- a/modules/reindex/build.gradle +++ b/modules/reindex/build.gradle @@ -92,3 +92,7 @@ forbiddenPatterns { exclude '**/*.p12' } +tasks.named("bundlePlugin").configure { + dependsOn("copyParentJoinMetadata") + dependsOn("copyTransportNetty4Metadata") +} diff --git a/plugins/repository-hdfs/build.gradle b/plugins/repository-hdfs/build.gradle index f5f619cc075fb..15ba93e4d7584 100644 --- a/plugins/repository-hdfs/build.gradle +++ b/plugins/repository-hdfs/build.gradle @@ -124,6 +124,13 @@ testClusters.integTest { String realm = "BUILD.OPENSEARCH.ORG" String krb5conf = project(':test:fixtures:krb5kdc-fixture').ext.krb5Conf("hdfs") + +project(':test:fixtures:krb5kdc-fixture').tasks.preProcessFixture { + dependsOn tasks.named("jarHell") + dependsOn tasks.named("testingConventions") +} + + // Create HDFS File System Testing Fixtures for HA/Secure combinations for (String fixtureName : ['hdfsFixture', 'haHdfsFixture', 'secureHdfsFixture', 'secureHaHdfsFixture']) { def tsk = project.tasks.register(fixtureName, org.opensearch.gradle.test.AntFixture) { diff --git a/qa/full-cluster-restart/build.gradle b/qa/full-cluster-restart/build.gradle index 4a36a6a937bb6..e50ca63c3da69 100644 --- a/qa/full-cluster-restart/build.gradle +++ b/qa/full-cluster-restart/build.gradle @@ -92,7 +92,7 @@ configurations { } TaskProvider testJar = tasks.register("testJar", Jar) { - appendix 'test' + archiveAppendix = 'test' from sourceSets.test.output } diff --git a/qa/repository-multi-version/build.gradle b/qa/repository-multi-version/build.gradle index 53a72c4d95c89..fdde0997df371 100644 --- a/qa/repository-multi-version/build.gradle +++ b/qa/repository-multi-version/build.gradle @@ -115,7 +115,7 @@ configurations { } def testJar = tasks.register("testJar", Jar) { - appendix 'test' + archiveAppendix = 'test' from sourceSets.test.output } diff --git a/qa/translog-policy/build.gradle b/qa/translog-policy/build.gradle index 8e161ba3fe1a3..5ef7774045e16 100644 --- a/qa/translog-policy/build.gradle +++ b/qa/translog-policy/build.gradle @@ -108,7 +108,7 @@ configurations { } task testJar(type: Jar) { - appendix 'test' + archiveAppendix = 'test' from sourceSets.test.output }