Skip to content

Commit d3cf89b

Browse files
authored
Upgrade to Gradle 6.0 (#49211) (#49994)
This upgrade required a few significant changes. Firstly, the build scan plugin has been renamed, and changed to be a Settings plugin rather than a project plugin so the declaration of this has moved to our settings.gradle file. Second, we were using a rather old version of the Nebula ospackage plugin for building deb and rpm packages, the migration to the latest version required some updates to get things working as expected as we had some workarounds in place that are no longer applicable with the latest bug fixes. (cherry picked from commit 87f9c16)
1 parent 3359438 commit d3cf89b

File tree

11 files changed

+37
-35
lines changed

11 files changed

+37
-35
lines changed

.ci/java-versions.properties

+3
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ ES_BUILD_JAVA=openjdk12
88
ES_RUNTIME_JAVA=java8
99
GRADLE_TASK=build
1010
GRADLE_EXTRA_ARGS=
11+
12+
# Workaround for https://github.com/gradle/gradle/issues/11426
13+
OPENSHIFT_IP=0.0.0.0

build.gradle

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import org.gradle.util.GradleVersion
3232
import static org.elasticsearch.gradle.tool.Boilerplate.maybeConfigure
3333

3434
plugins {
35-
id 'com.gradle.build-scan' version '2.4.2'
3635
id 'lifecycle-base'
3736
id 'elasticsearch.global-build-info'
3837
id "com.diffplug.gradle.spotless" version "3.24.2" apply false

buildSrc/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ group = 'org.elasticsearch.gradle'
2929

3030
String minimumGradleVersion = file('src/main/resources/minimumGradleVersion').text.trim()
3131
if (GradleVersion.current() < GradleVersion.version(minimumGradleVersion)) {
32-
throw new GradleException("Gradle ${minimumGradleVersion}+ is required to build elasticsearch")
32+
throw new GradleException("Gradle ${minimumGradleVersion}+ is required to build elasticsearch")
3333
}
3434

3535
if (project == rootProject) {
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.6.4
1+
6.0.1

buildSrc/src/testKit/thirdPartyAudit/build.gradle

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ repositories {
1616
maven {
1717
name = "local-test"
1818
url = file("sample_jars/build/testrepo")
19+
metadataSources {
20+
artifact()
21+
}
1922
}
2023
jcenter()
2124
}

distribution/packages/build.gradle

+9-13
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,8 @@ import java.util.regex.Pattern
5151
* dpkg -c path/to/elasticsearch.deb
5252
*/
5353

54-
buildscript {
55-
repositories {
56-
maven {
57-
name "gradle-plugins"
58-
url "https://plugins.gradle.org/m2/"
59-
}
60-
}
61-
dependencies {
62-
classpath 'com.netflix.nebula:gradle-ospackage-plugin:4.7.1'
63-
}
54+
plugins {
55+
id "nebula.ospackage-base" version "8.0.3"
6456
}
6557

6658
void addProcessFilesTask(String type, boolean oss, boolean jdk) {
@@ -115,10 +107,12 @@ Closure commonPackageConfig(String type, boolean oss, boolean jdk) {
115107
arch(type == 'deb' ? 'amd64' : 'X86_64')
116108
// Follow elasticsearch's file naming convention
117109
String jdkString = jdk ? "" : "no-jdk-"
118-
archiveName "${packageName}-${project.version}-${jdkString}${archString}.${type}"
119-
120110
String prefix = "${oss ? 'oss-' : ''}${jdk ? '' : 'no-jdk-'}${type}"
121111
destinationDir = file("${prefix}/build/distributions")
112+
113+
// SystemPackagingTask overrides default archive task convention mappings, but doesn't provide a setter so we have to override the convention mapping itself
114+
conventionMapping.archiveFile = { objects.fileProperty().fileValue(file("${destinationDir}/${packageName}-${project.version}-${jdkString}${archString}.${type}")) }
115+
122116
String packagingFiles = "build/packaging/${oss ? 'oss-' : ''}${jdk ? '' : 'no-jdk-'}${type}"
123117

124118
String scripts = "${packagingFiles}/scripts"
@@ -157,7 +151,9 @@ Closure commonPackageConfig(String type, boolean oss, boolean jdk) {
157151
eachFile { FileCopyDetails fcp ->
158152
String[] segments = fcp.relativePath.segments
159153
for (int i = segments.length - 2; i > 2; --i) {
160-
directory('/' + segments[0..i].join('/'), 0755)
154+
if (type == 'rpm') {
155+
directory('/' + segments[0..i].join('/'), 0755)
156+
}
161157
if (segments[-2] == 'bin' || segments[-1] == 'jspawnhelper') {
162158
fcp.mode = 0755
163159
} else {

gradle/build-complete.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ if (buildNumber) {
3838
fileset(dir: "${gradle.gradleUserHomeDir}/daemon/${gradle.gradleVersion}", followsymlinks: false) {
3939
include(name: "**/daemon-${ProcessHandle.current().pid()}*.log")
4040
}
41+
42+
fileset(dir: "${gradle.gradleUserHomeDir}/workers", followsymlinks: false)
4143
}
4244
} catch (Exception e) {
4345
logger.lifecycle("Failed to archive additional logs", e)

gradle/wrapper/gradle-wrapper.jar

3.01 KB
Binary file not shown.
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionSha256Sum=abc10bcedb58806e8654210f96031db541bcd2d6fc3161e81cb0572d6a15e821
6+
distributionSha256Sum=6f6cfdbb12a577c3845522a1c7fbfe1295ea05d87edabedd4e23fd2bf02b88b1

gradlew

+12-17
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,19 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
154154
else
155155
eval `echo args$i`="\"$arg\""
156156
fi
157-
i=$((i+1))
157+
i=`expr $i + 1`
158158
done
159159
case $i in
160-
(0) set -- ;;
161-
(1) set -- "$args0" ;;
162-
(2) set -- "$args0" "$args1" ;;
163-
(3) set -- "$args0" "$args1" "$args2" ;;
164-
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
165-
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
166-
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
167-
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
168-
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
169-
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
160+
0) set -- ;;
161+
1) set -- "$args0" ;;
162+
2) set -- "$args0" "$args1" ;;
163+
3) set -- "$args0" "$args1" "$args2" ;;
164+
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
165+
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
166+
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
167+
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
168+
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
169+
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
170170
esac
171171
fi
172172

@@ -175,14 +175,9 @@ save () {
175175
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
176176
echo " "
177177
}
178-
APP_ARGS=$(save "$@")
178+
APP_ARGS=`save "$@"`
179179

180180
# Collect all arguments for the java command, following the shell quoting and substitution rules
181181
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
182182

183-
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
184-
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
185-
cd "$(dirname "$0")"
186-
fi
187-
188183
exec "$JAVACMD" "$@"

settings.gradle

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
plugins {
2+
id "com.gradle.enterprise" version "3.0"
3+
}
4+
15
String dirName = rootProject.projectDir.name
26
rootProject.name = dirName
37

0 commit comments

Comments
 (0)