Skip to content

Commit a85772c

Browse files
authored
Use Gradle wrapper when building BWC
This commit modifies the BWC build to invoke the Gradle wrapper. The motivation for this is two-fold: - BWC versions might be dependent on a different version of Gradle than the current version of Gradle - in a follow-up we are going to need to be able to set JAVA_HOME to a different value than the current value of JAVA_HOME Relates elastic#28138
1 parent 1d1dcd4 commit a85772c

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

distribution/bwc/build.gradle

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,34 @@ if (project.hasProperty('bwcVersion')) {
115115
File bwcDeb = file("${checkoutDir}/distribution/deb/build/distributions/elasticsearch-${bwcVersion}.deb")
116116
File bwcRpm = file("${checkoutDir}/distribution/rpm/build/distributions/elasticsearch-${bwcVersion}.rpm")
117117
File bwcZip = file("${checkoutDir}/distribution/zip/build/distributions/elasticsearch-${bwcVersion}.zip")
118-
task buildBwcVersion(type: GradleBuild) {
118+
task buildBwcVersion(type: Exec) {
119119
dependsOn checkoutBwcBranch, writeBuildMetadata
120-
dir = checkoutDir
121-
tasks = [':distribution:deb:assemble', ':distribution:rpm:assemble', ':distribution:zip:assemble']
122-
startParameter.systemPropertiesArgs = ['build.snapshot': System.getProperty("build.snapshot") ?: "true"]
120+
workingDir = checkoutDir
121+
executable = new File(checkoutDir, 'gradlew').toString()
122+
final ArrayList<String> commandLineArgs = [
123+
":distribution:deb:assemble",
124+
":distribution:rpm:assemble",
125+
":distribution:zip:assemble",
126+
"-Dbuild.snapshot=${System.getProperty('build.snapshot') ?: 'true'}"]
127+
final LogLevel logLevel = gradle.startParameter.logLevel
128+
if ([LogLevel.QUIET, LogLevel.WARN, LogLevel.INFO, LogLevel.DEBUG].contains(logLevel)) {
129+
commandLineArgs << "--${logLevel.name().toLowerCase(Locale.ENGLISH)}"
130+
}
131+
final String showStacktraceName = gradle.startParameter.showStacktrace.name()
132+
assert ["INTERNAL_EXCEPTIONS", "ALWAYS", "ALWAYS_FULL"].contains(showStacktraceName)
133+
if (showStacktraceName.equals("ALWAYS")) {
134+
commandLineArgs << "--stacktrace"
135+
} else if (showStacktraceName.equals("ALWAYS_FULL")) {
136+
commandLineArgs << "--full-stacktrace"
137+
}
138+
args = commandLineArgs
123139
doLast {
124140
List missing = [bwcDeb, bwcRpm, bwcZip].grep { file ->
125-
false == file.exists() }
141+
false == file.exists()
142+
}
126143
if (false == missing.empty) {
127144
throw new InvalidUserDataException(
128-
"Building bwc version didn't generate expected files ${missing}")
145+
"Building bwc version didn't generate expected files ${missing}")
129146
}
130147
}
131148
}

0 commit comments

Comments
 (0)