diff --git a/build.gradle b/build.gradle index faeff873ceb..b6987700c46 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ buildscript { repositories { mavenCentral() maven { - url 'https://plugins.gradle.org/m2/' + url = 'https://plugins.gradle.org/m2/' } } } @@ -103,16 +103,16 @@ allprojects { testLogging { // set options for log level LIFECYCLE events "passed", "skipped", "failed", "standardOut" - showExceptions true - exceptionFormat "full" - showCauses true - showStackTraces true - enableAssertions false + showExceptions = true + exceptionFormat = "full" + showCauses = true + showStackTraces = true + enableAssertions = false // set options for log level DEBUG and INFO debug { events "started", "passed", "skipped", "failed", "standardOut", "standardError" - exceptionFormat "full" + exceptionFormat = "full" } info.events = debug.events info.exceptionFormat = debug.exceptionFormat @@ -133,7 +133,7 @@ subprojects { repositories { mavenCentral() maven { - url 'https://plugins.gradle.org/m2/' + url = 'https://plugins.gradle.org/m2/' } } @@ -165,8 +165,9 @@ tasks.register("configureArchitecture") { tasks.register("configureArtifactInfo") { dependsOn configureArchitecture - description "Set the url to download stack artifacts for select stack version" + description = "Set the url to download stack artifacts for select stack version" + def projectRef = project doLast { def splitVersion = version.split('\\.') int major = splitVersion[0].toInteger() @@ -189,28 +190,28 @@ tasks.register("configureArtifactInfo") { } } - project.ext.set("artifactApiVersion", qualifiedVersion) + projectRef.ext.set("artifactApiVersion", qualifiedVersion) } } tasks.register("markAliasDefinitions", SignAliasDefinitions) { - description "Create an hashes aliases file from original aliases yml definition" + description = "Create an hashes aliases file from original aliases yml definition" hashedFile = project.file("${project.buildDir}/plugin_aliases_hashed.yml") } tasks.register("markTestAliasDefinitions", SignAliasDefinitions) { - description "Create an hashes aliases file for testing aliases yml definition" + description = "Create an hashes aliases file for testing aliases yml definition" stage SignAliasDefinitions.Stage.test hashedFile = project.file("${project.buildDir}/plugin_aliases_hashed_test.yml") } tasks.register("copyPluginAlias", Copy) { - description "Copy the marked plugin_aliases.yml file to destination folders" + description = "Copy the marked plugin_aliases.yml file to destination folders" dependsOn = [copyPluginAlias_ruby, copyPluginAlias_java] } tasks.register("copyPluginAlias_ruby", Copy) { - description "Copy the marked plugin_aliases.yml file to destination folders" + description = "Copy the marked plugin_aliases.yml file to destination folders" dependsOn "markAliasDefinitions" inputs.file("${buildDir}/plugin_aliases_hashed.yml") @@ -222,7 +223,7 @@ tasks.register("copyPluginAlias_ruby", Copy) { } tasks.register("copyPluginAlias_java", Copy) { - description "Copy the marked plugin_aliases.yml file to destination folders" + description = "Copy the marked plugin_aliases.yml file to destination folders" dependsOn "markAliasDefinitions" inputs.file("${buildDir}/plugin_aliases_hashed.yml") @@ -234,12 +235,12 @@ tasks.register("copyPluginAlias_java", Copy) { } tasks.register("copyPluginTestAlias") { - description "Copy the marked test plugin_aliases.yml file to destination folders" + description = "Copy the marked test plugin_aliases.yml file to destination folders" dependsOn = [copyPluginTestAlias_ruby, copyPluginTestAlias_java] } tasks.register("copyPluginTestAlias_ruby", Copy) { - description "Copy the marked test plugin_aliases.yml file into Ruby's plugin_manager specs" + description = "Copy the marked test plugin_aliases.yml file into Ruby's plugin_manager specs" dependsOn "markTestAliasDefinitions" inputs.file(markTestAliasDefinitions.hashedFile) @@ -251,7 +252,7 @@ tasks.register("copyPluginTestAlias_ruby", Copy) { } tasks.register("copyPluginTestAlias_java", Copy) { - description "Copy the marked test plugin_aliases.yml file into logstash-core's test resources" + description = "Copy the marked test plugin_aliases.yml file into logstash-core's test resources" dependsOn "markTestAliasDefinitions" inputs.file("${buildDir}/plugin_aliases_hashed_test.yml") @@ -447,30 +448,39 @@ tasks.register("installIntegrationTestGems") { } } -tasks.register("downloadFilebeat") { - dependsOn configureArtifactInfo - description "Download Filebeat Snapshot for current branch version: ${version}" +tasks.register("prepareFilebeatDownload") { + dependsOn configureArtifactInfo + + def projectRef = project + doLast { + String beatsVersion = projectRef.ext.get("artifactApiVersion") + String downloadedFilebeatName = "filebeat-${beatsVersion}-${projectRef.ext.get("beatsArchitecture")}" + projectRef.ext.set("unpackedFilebeatName", downloadedFilebeatName) + + def res = SnapshotArtifactURLs.packageUrls("beats", beatsVersion, downloadedFilebeatName) + projectRef.ext.set("filebeatSnapshotUrl", System.getenv("FILEBEAT_SNAPSHOT_URL") ?: res.packageUrl) + projectRef.ext.set("filebeatDownloadLocation", "${projectDir}/build/${downloadedFilebeatName}.tar.gz") + } +} + +tasks.register("downloadFilebeat", Download) { + dependsOn prepareFilebeatDownload + description = "Download Filebeat Snapshot for current branch version: ${version}" project.ext.set("versionFound", true) inputs.file("${projectDir}/versions.yml") - doLast { - download { - String beatsVersion = project.ext.get("artifactApiVersion") - String downloadedFilebeatName = "filebeat-${beatsVersion}-${project.ext.get("beatsArchitecture")}" - project.ext.set("unpackedFilebeatName", downloadedFilebeatName) + def projectRef = project - def res = SnapshotArtifactURLs.packageUrls("beats", beatsVersion, downloadedFilebeatName) - project.ext.set("filebeatSnapshotUrl", System.getenv("FILEBEAT_SNAPSHOT_URL") ?: res.packageUrl) - project.ext.set("filebeatDownloadLocation", "${projectDir}/build/${downloadedFilebeatName}.tar.gz") + // Use lazy configuration to get values after prepareFilebeatDownload runs + src { projectRef.ext.filebeatSnapshotUrl } + dest { new File(projectRef.ext.filebeatDownloadLocation) } - src project.ext.filebeatSnapshotUrl - onlyIfNewer true + onlyIfNewer true + retries 3 - dest new File(project.ext.filebeatDownloadLocation) - retries 3 - } - System.out.println "Downloaded to ${project.ext.filebeatDownloadLocation}" + doLast { + System.out.println "Downloaded to ${projectRef.ext.filebeatDownloadLocation}" } } @@ -495,11 +505,12 @@ tasks.register("copyFilebeat") { tasks.register("checkEsSHA") { dependsOn configureArtifactInfo - description "Download ES version remote's fingerprint file" + description = "Download ES version remote's fingerprint file" + def projectRef = project doLast { - String esVersion = project.ext.get("artifactApiVersion") - String downloadedElasticsearchName = "elasticsearch-${esVersion}-${project.ext.get("esArchitecture")}" + String esVersion = projectRef.ext.get("artifactApiVersion") + String downloadedElasticsearchName = "elasticsearch-${esVersion}-${projectRef.ext.get("esArchitecture")}" String remoteSHA def res = SnapshotArtifactURLs.packageUrls("elasticsearch", esVersion, downloadedElasticsearchName) @@ -529,30 +540,39 @@ tasks.register("checkEsSHA") { } } -tasks.register("downloadEs") { - dependsOn = [configureArtifactInfo, checkEsSHA] - - description "Download ES Snapshot for current branch version: ${version}" - inputs.file("${projectDir}/versions.yml") +tasks.register("prepareEsDownload") { + dependsOn configureArtifactInfo + def projectRef = project doLast { - download { - String esVersion = project.ext.get("artifactApiVersion") - String downloadedElasticsearchName = "elasticsearch-${esVersion}-${project.ext.get("esArchitecture")}" + String esVersion = projectRef.ext.get("artifactApiVersion") + String downloadedElasticsearchName = "elasticsearch-${esVersion}-${projectRef.ext.get("esArchitecture")}" - project.ext.set("unpackedElasticsearchName", "elasticsearch-${esVersion}") + projectRef.ext.set("unpackedElasticsearchName", "elasticsearch-${esVersion}") - def res = SnapshotArtifactURLs.packageUrls("elasticsearch", esVersion, downloadedElasticsearchName) - project.ext.set("elasticsearchSnapshotURL", System.getenv("ELASTICSEARCH_SNAPSHOT_URL") ?: res.packageUrl) - project.ext.set("elasticsearchDownloadLocation", "${projectDir}/build/${downloadedElasticsearchName}.tar.gz") + def res = SnapshotArtifactURLs.packageUrls("elasticsearch", esVersion, downloadedElasticsearchName) + projectRef.ext.set("elasticsearchSnapshotURL", System.getenv("ELASTICSEARCH_SNAPSHOT_URL") ?: res.packageUrl) + projectRef.ext.set("elasticsearchDownloadLocation", "${projectDir}/build/${downloadedElasticsearchName}.tar.gz") + } +} - src project.ext.elasticsearchSnapshotURL - onlyIfNewer true - retries 3 - dest new File(project.ext.elasticsearchDownloadLocation) - } +tasks.register("downloadEs", Download) { + dependsOn = [prepareEsDownload, checkEsSHA] + + description = "Download ES Snapshot for current branch version: ${version}" + inputs.file("${projectDir}/versions.yml") - System.out.println "Downloaded to ${project.ext.elasticsearchDownloadLocation}" + def projectRef = project + + src { projectRef.ext.elasticsearchSnapshotURL } + dest { new File(projectRef.ext.elasticsearchDownloadLocation) } + + onlyIfNewer true + overwrite false + retries 3 + + doLast { + System.out.println "Downloaded to ${projectRef.ext.elasticsearchDownloadLocation}" } } @@ -609,7 +629,7 @@ tasks.register("generateLicenseReport", JavaExec) { String noticePath = "NOTICE.txt" classpath = project.files([jarFile]) - main = "org.logstash.dependencies.Main" + mainClass = "org.logstash.dependencies.Main" args licenseReportInputCSV, project.getBuildDir().toString() + "/licenseReportFolders.txt", licenseReportOutputCSV, noticePath @@ -828,7 +848,7 @@ tasks.register("downloadJdk", Download) { def jdkDetails = new JDKDetails(gradle.ext.versions.bundled_jdk, osName, jdkArch) - description "Download JDK ${jdkDetails.major}, OS: ${osName}" + description = "Download JDK ${jdkDetails.major}, OS: ${osName}" // find url of build artifact String artifactApiUrl = jdkDetails.createDownloadUrl() diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e6441136f3d..1b33c55baab 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 b82aa23a4f0..d4081da476b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 1aa94a42690..23d15a93670 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,7 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar +CLASSPATH="\\\"\\\"" # Determine the Java command to use to start the JVM. @@ -203,7 +205,7 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. @@ -211,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/gradlew.bat b/gradlew.bat index 7101f8e4676..5eed7ee8452 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -68,11 +70,11 @@ goto fail :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar +set CLASSPATH= @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell diff --git a/logstash-core/build.gradle b/logstash-core/build.gradle index 14dd90e8199..5c0db0f5a3f 100644 --- a/logstash-core/build.gradle +++ b/logstash-core/build.gradle @@ -103,6 +103,8 @@ configurations.archives { tasks.register("javaTests", Test) { dependsOn ':bootstrap' + testClassesDirs = sourceSets.test.output.classesDirs + classpath = sourceSets.test.runtimeClasspath exclude '/org/logstash/RSpecTests.class' exclude '/org/logstash/config/ir/ConfigCompilerTest.class' exclude '/org/logstash/config/ir/CompiledPipelineTest.class' @@ -136,6 +138,8 @@ javaTests.finalizedBy(jacocoTestReport) tasks.register("rubyTests", Test) { dependsOn compileTestJava + testClassesDirs = sourceSets.test.output.classesDirs + classpath = sourceSets.test.runtimeClasspath inputs.files fileTree("${projectDir}/lib") inputs.files fileTree("${projectDir}/spec") systemProperty 'logstash.root.dir', projectDir.parent @@ -171,10 +175,10 @@ tasks { artifacts { sources(sourcesJar) { // Weird Gradle quirk where type will be used for the extension, but only for sources - type 'jar' + type = 'jar' } javadoc(javadocJar) { - type 'javadoc' + type = 'javadoc' } } diff --git a/qa/integration/build.gradle b/qa/integration/build.gradle index f54d1abfaf4..8bd9e9a4950 100644 --- a/qa/integration/build.gradle +++ b/qa/integration/build.gradle @@ -40,7 +40,7 @@ test { } tasks.register("copyProductionLog4jConfiguration", Copy) { - description "Copy the production log4j config to be tested in QA (qa/integration/fixtures/logs_rollover)" + description = "Copy the production log4j config to be tested in QA (qa/integration/fixtures/logs_rollover)" from "${projectDir}/../../config/log4j2.properties" into "${projectDir}/fixtures/logs_rollover/" @@ -76,6 +76,8 @@ tasks.register("integrationTests", Test) { if ((JavaVersion.current().getMajorVersion() as int) >= 17) { jvmArgs = ['--add-opens', 'java.base/sun.nio.ch=ALL-UNNAMED', '--add-opens', 'java.base/java.io=ALL-UNNAMED'] } + testClassesDirs = sourceSets.test.output.classesDirs + classpath = sourceSets.test.runtimeClasspath dependsOn copyProductionLog4jConfiguration dependsOn preparePluginTestFixtures diff --git a/rubyUtils.gradle b/rubyUtils.gradle index aac0ba0e96d..4e2565f72a4 100644 --- a/rubyUtils.gradle +++ b/rubyUtils.gradle @@ -239,7 +239,7 @@ def customJRubyVersion = customJRubyDir == "" ? "" : Files.readAllLines(Paths.ge def customJRubyTar = customJRubyDir == "" ? "" : (customJRubyDir + "/maven/jruby-dist/target/jruby-dist-${customJRubyVersion}-bin.tar.gz") tasks.register("downloadJRuby", Download) { - description "Download JRuby artifact from this specific URL: ${jRubyURL}" + description = "Download JRuby artifact from this specific URL: ${jRubyURL}" src jRubyURL onlyIfNewer true inputs.file(versionsPath) @@ -251,7 +251,7 @@ downloadJRuby.onlyIf { customJRubyDir == "" } tasks.register("verifyFile", Verify) { dependsOn downloadJRuby - description "Verify the SHA256 of the download JRuby artifact" + description = "Verify the SHA256 of the download JRuby artifact" inputs.file(jrubyTarPath) outputs.file(jrubyTarPath) src new File(jrubyTarPath) @@ -263,7 +263,7 @@ verifyFile.onlyIf { customJRubyDir == "" } verifyFile.onlyIf { doChecksum } tasks.register("buildCustomJRuby", Exec) { - description "Build tar.gz and .jar artifacts from JRuby source directory" + description = "Build tar.gz and .jar artifacts from JRuby source directory" workingDir (customJRubyDir == "" ? "./" : customJRubyDir) commandLine './mvnw', 'clean', 'install', '-Pdist', '-Pcomplete' standardOutput = new ByteArrayOutputStream() @@ -277,7 +277,7 @@ buildCustomJRuby.onlyIf { customJRubyDir != "" } tasks.register("installCustomJRuby", Copy) { dependsOn buildCustomJRuby - description "Install custom built JRuby in the vendor directory" + description = "Install custom built JRuby in the vendor directory" inputs.file(customJRubyTar) outputs.dir("${projectDir}/vendor/jruby") from tarTree(customJRubyTar == "" ? jrubyTarPath : customJRubyTar) @@ -292,7 +292,7 @@ installCustomJRuby.onlyIf { customJRubyDir != "" } tasks.register("downloadAndInstallJRuby", Copy) { dependsOn=[verifyFile, installCustomJRuby] - description "Install JRuby in the vendor directory" + description = "Install JRuby in the vendor directory" inputs.file(jrubyTarPath) outputs.dir("${projectDir}/vendor/jruby") from tarTree(downloadJRuby.dest) diff --git a/x-pack/build.gradle b/x-pack/build.gradle index 68ce62f5a58..c25ea5e338c 100644 --- a/x-pack/build.gradle +++ b/x-pack/build.gradle @@ -47,6 +47,8 @@ tasks.register("unzipGeolite", Copy) { tasks.register("rubyTests", Test) { dependsOn unzipGeolite + testClassesDirs = sourceSets.test.output.classesDirs + classpath = sourceSets.test.runtimeClasspath inputs.files fileTree("${projectDir}/spec") inputs.files fileTree("${projectDir}/lib") inputs.files fileTree("${projectDir}/modules") @@ -58,6 +60,8 @@ tasks.register("rubyIntegrationTests", Test) { if ((JavaVersion.current().getMajorVersion() as int) >= 17) { jvmArgs = ['--add-opens', 'java.base/sun.nio.ch=ALL-UNNAMED', '--add-opens', 'java.base/java.io=ALL-UNNAMED'] } + testClassesDirs = sourceSets.test.output.classesDirs + classpath = sourceSets.test.runtimeClasspath dependsOn (":copyEs") dependsOn ":assemble" dependsOn "buildFipsValidationGem" @@ -78,7 +82,9 @@ tasks.register("buildFipsValidationGem") { tasks.register("observabilitySREsmokeTests", Test) { description = "Run ObservabilitySRE smoke tests using RSpec with docker-compose orchestration" - // Need to have set up the ruby environment for rspec + testClassesDirs = sourceSets.test.output.classesDirs + classpath = sourceSets.test.runtimeClasspath + // Need to have set up the ruby environment for rspec even through we are running in container dependsOn(":bootstrap", ":logstash-core:assemble", ":installDevelopmentGems") inputs.files fileTree("${projectDir}/distributions/internal/observabilitySRE/qa/smoke") doFirst { @@ -99,7 +105,9 @@ tasks.register("observabilitySREsmokeTests", Test) { tasks.register("observabilitySREacceptanceTests", Test) { description = "Run ObservabilitySRE acceptance tests using RSpec with docker-compose orchestration" - // Need to have set up the ruby environment for rspec + testClassesDirs = sourceSets.test.output.classesDirs + classpath = sourceSets.test.runtimeClasspath + // Need to have set up the ruby environment for rspec even through we are running in container dependsOn(":bootstrap", ":logstash-core:assemble", ":installDevelopmentGems") inputs.files fileTree("${projectDir}/distributions/internal/observabilitySRE/qa/acceptance") doFirst {