Skip to content

Commit

Permalink
Upgrade to Gradle 5.0 (#34263)
Browse files Browse the repository at this point in the history
  • Loading branch information
alpar-t committed Dec 5, 2018
1 parent 8b9b2cb commit ddaf65d
Show file tree
Hide file tree
Showing 27 changed files with 65 additions and 50 deletions.
2 changes: 1 addition & 1 deletion benchmarks/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dependencies {
exclude group: 'net.sf.jopt-simple', module: 'jopt-simple'
}
compile "org.openjdk.jmh:jmh-core:$versions.jmh"
compile "org.openjdk.jmh:jmh-generator-annprocess:$versions.jmh"
annotationProcessor "org.openjdk.jmh:jmh-generator-annprocess:$versions.jmh"
// Dependencies of JMH
runtime 'net.sf.jopt-simple:jopt-simple:4.6'
runtime 'org.apache.commons:commons-math3:3.2'
Expand Down
7 changes: 5 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ import org.elasticsearch.gradle.Version
import org.elasticsearch.gradle.VersionCollection
import org.elasticsearch.gradle.VersionProperties
import org.elasticsearch.gradle.plugin.PluginBuildPlugin
import org.gradle.api.tasks.options.Option
import org.gradle.util.GradleVersion
import org.gradle.util.DistributionLocator
import org.gradle.plugins.ide.eclipse.model.SourceFolder
import com.carrotsearch.gradle.junit4.RandomizedTestingTask

import java.util.function.Predicate

plugins {
id 'com.gradle.build-scan' version '1.13.2'
id 'com.gradle.build-scan' version '2.0.2'
id 'base'
}
if (properties.get("org.elasticsearch.acceptScanTOS", "false") == "true") {
Expand Down Expand Up @@ -531,7 +534,7 @@ allprojects {
class Run extends DefaultTask {
boolean debug = false

@org.gradle.api.internal.tasks.options.Option(
@Option(
option = "debug-jvm",
description = "Enable debugging configuration, to allow attaching a debugger to elasticsearch."
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class TestProgressLogger implements AggregatedEventListener {

@Subscribe
void onTestResult(AggregatedTestResultEvent e) throws IOException {
final String statusMessage
String statusMessage
testsCompleted++
switch (e.status) {
case ERROR:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class BuildPlugin implements Plugin<Project> {
+ 'elasticsearch.standalone-rest-test, and elasticsearch.build '
+ 'are mutually exclusive')
}
final String minimumGradleVersion
String minimumGradleVersion = null
InputStream is = getClass().getResourceAsStream("/minimumGradleVersion")
try { minimumGradleVersion = IOUtils.toString(is, StandardCharsets.UTF_8.toString()) } finally { is.close() }
if (GradleVersion.current() < GradleVersion.version(minimumGradleVersion.trim())) {
Expand Down Expand Up @@ -233,7 +233,7 @@ class BuildPlugin implements Plugin<Project> {
}

private static String findCompilerJavaHome() {
final String compilerJavaHome = System.getenv('JAVA_HOME')
String compilerJavaHome = System.getenv('JAVA_HOME')
final String compilerJavaProperty = System.getProperty('compiler.java')
if (compilerJavaProperty != null) {
compilerJavaHome = findJavaHome(compilerJavaProperty)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,7 @@ class PrecommitTasks {
Task checkstyleTask = project.tasks.create('checkstyle')
// Apply the checkstyle plugin to create `checkstyleMain` and `checkstyleTest`. It only
// creates them if there is main or test code to check and it makes `check` depend
// on them. But we want `precommit` to depend on `checkstyle` which depends on them so
// we have to swap them.
// on them. We also want `precommit` to depend on `checkstyle`.
project.pluginManager.apply('checkstyle')
project.checkstyle {
config = project.resources.text.fromFile(checkstyleConf, 'UTF-8')
Expand All @@ -202,7 +201,6 @@ class PrecommitTasks {
}

project.tasks.withType(Checkstyle) { task ->
project.tasks[JavaBasePlugin.CHECK_TASK_NAME].dependsOn.remove(task)
checkstyleTask.dependsOn(task)
task.dependsOn(copyCheckstyleConf)
task.inputs.file(checkstyleSuppressions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ class ClusterFormationTasks {
for (int i = 0; i < config.numNodes; i++) {
// we start N nodes and out of these N nodes there might be M bwc nodes.
// for each of those nodes we might have a different configuration
final Configuration distro
final String elasticsearchVersion
Configuration distro
String elasticsearchVersion
if (i < config.numBwcNodes) {
elasticsearchVersion = config.bwcVersion.toString()
if (project.bwcVersions.unreleased.contains(config.bwcVersion)) {
Expand Down Expand Up @@ -589,7 +589,7 @@ class ClusterFormationTasks {
}

static Task configureInstallPluginTask(String name, Project project, Task setup, NodeInfo node, String pluginName, String prefix) {
final FileCollection pluginZip;
FileCollection pluginZip;
if (node.nodeVersion != Version.fromString(VersionProperties.elasticsearch)) {
pluginZip = project.configurations.getByName(pluginBwcConfigurationName(prefix, pluginName))
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ import org.gradle.api.DefaultTask
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.execution.TaskExecutionAdapter
import org.gradle.api.internal.tasks.options.Option
import org.gradle.api.provider.Property
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.Copy
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.TaskState
import org.gradle.api.tasks.options.Option
import org.gradle.plugins.ide.idea.IdeaPlugin

import java.nio.charset.StandardCharsets
Expand All @@ -53,7 +53,7 @@ public class RestIntegTestTask extends DefaultTask {

/** Flag indicating whether the rest tests in the rest spec should be run. */
@Input
Property<Boolean> includePackaged = project.objects.property(Boolean)
Boolean includePackaged = false

public RestIntegTestTask() {
runner = project.tasks.create("${name}Runner", RandomizedTestingTask.class)
Expand Down Expand Up @@ -109,7 +109,7 @@ public class RestIntegTestTask extends DefaultTask {
}

// copy the rest spec/tests into the test resources
Task copyRestSpec = createCopyRestSpecTask(project, includePackaged)
Task copyRestSpec = createCopyRestSpecTask()
runner.dependsOn(copyRestSpec)

// this must run after all projects have been configured, so we know any project
Expand All @@ -130,7 +130,7 @@ public class RestIntegTestTask extends DefaultTask {

/** Sets the includePackaged property */
public void includePackaged(boolean include) {
includePackaged.set(include)
includePackaged = include
}

@Option(
Expand Down Expand Up @@ -215,7 +215,7 @@ public class RestIntegTestTask extends DefaultTask {
* @param project The project to add the copy task to
* @param includePackagedTests true if the packaged tests should be copied, false otherwise
*/
static Task createCopyRestSpecTask(Project project, Provider<Boolean> includePackagedTests) {
Task createCopyRestSpecTask() {
project.configurations {
restSpec
}
Expand All @@ -237,7 +237,7 @@ public class RestIntegTestTask extends DefaultTask {
project.afterEvaluate {
copyRestSpec.from({ project.zipTree(project.configurations.restSpec.singleFile) }) {
include 'rest-api-spec/api/**'
if (includePackagedTests.get()) {
if (includePackaged) {
include 'rest-api-spec/test/**'
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.elasticsearch.gradle.test

import org.gradle.api.DefaultTask
import org.gradle.api.Task
import org.gradle.api.internal.tasks.options.Option
import org.gradle.api.tasks.options.Option
import org.gradle.util.ConfigureUtil

public class RunTask extends DefaultTask {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,9 @@ class VagrantTestPlugin implements Plugin<Project> {
* execution.
*/
final String vagrantDestroyProperty = project.getProperties().get('vagrant.destroy', 'true')
final boolean vagrantDestroy
boolean vagrantDestroy
if ("true".equals(vagrantDestroyProperty)) {
vagrantDestroy = true;
vagrantDestroy = true
} else if ("false".equals(vagrantDestroyProperty)) {
vagrantDestroy = false
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ public class ExportElasticsearchBuildResourcesTask extends DefaultTask {
private DirectoryProperty outputDir;

public ExportElasticsearchBuildResourcesTask() {
outputDir = getProject().getLayout().directoryProperty(
getProject().getLayout().getBuildDirectory().dir("build-tools-exported")
);
outputDir = getProject().getObjects().directoryProperty();
outputDir.set(new File(getProject().getBuildDir(), "build-tools-exported"));
}

@OutputDirectory
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/resources/minimumGradleVersion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.10
5.0
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
24 changes: 21 additions & 3 deletions client/rest-high-level/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,17 @@ publishing {
}
}

//we need to copy the yaml spec so we can check naming (see RestHighlevelClientTests#testApiNamingConventions)
Task copyRestSpec = RestIntegTestTask.createCopyRestSpecTask(project, Providers.FALSE)
test.dependsOn(copyRestSpec)
configurations {
restSpec
}

idea {
module {
if (scopes.TEST != null) {
scopes.TEST.plus.add(project.configurations.restSpec)
}
}
}

dependencies {
/*
Expand All @@ -59,6 +67,16 @@ dependencies {
testCompile "org.hamcrest:hamcrest-all:${versions.hamcrest}"
//this is needed to make RestHighLevelClientTests#testApiNamingConventions work from IDEs
testCompile "org.elasticsearch:rest-api-spec:${version}"

restSpec "org.elasticsearch:rest-api-spec:${version}"
}

//we need to copy the yaml spec so we can check naming (see RestHighlevelClientTests#testApiNamingConventions)
processTestResources {
dependsOn jar // so that configurations resolve
from({ zipTree(configurations.restSpec.singleFile) }) {
include 'rest-api-spec/api/**'
}
}

dependencyLicenses {
Expand Down
6 changes: 3 additions & 3 deletions distribution/archives/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ subprojects {
}

// sanity checks if archives can be extracted
final File archiveExtractionDir
File archiveExtractionDir
if (project.name.contains('tar')) {
archiveExtractionDir = new File(buildDir, 'tar-extracted')
} else {
Expand Down Expand Up @@ -190,7 +190,7 @@ subprojects {
}
}

final Closure toolExists
Closure toolExists
if (project.name.contains('tar')) {
toolExists = tarExists
} else {
Expand All @@ -203,7 +203,7 @@ subprojects {
dependsOn buildDist, checkExtraction
onlyIf toolExists
doLast {
final String licenseFilename
String licenseFilename = null
if (project.name.contains('oss-') || project.name == 'integ-test-zip') {
licenseFilename = "APACHE-LICENSE-2.0.txt"
} else {
Expand Down
2 changes: 1 addition & 1 deletion distribution/bwc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bwcVersions.forPreviousUnreleased { VersionCollection.UnreleasedVersionInfo unre

final String remote = System.getProperty("tests.bwc.remote", "elastic")

final boolean gitFetchLatest
boolean gitFetchLatest
final String gitFetchLatestProperty = System.getProperty("tests.bwc.git_fetch_latest", "true")
if ("true".equals(gitFetchLatestProperty)) {
gitFetchLatest = true
Expand Down
16 changes: 8 additions & 8 deletions distribution/packages/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ subprojects {

// sanity checks if packages can be extracted
final File extractionDir = new File(buildDir, 'extracted')
final File packageExtractionDir
File packageExtractionDir
if (project.name.contains('deb')) {
packageExtractionDir = new File(extractionDir, 'deb-extracted')
} else {
Expand Down Expand Up @@ -407,9 +407,9 @@ subprojects {
checkLicense {
onlyIf dpkgExists
doLast {
final Path copyrightPath
final String expectedLicense
final String licenseFilename
Path copyrightPath
String expectedLicense
String licenseFilename
if (project.name.contains('oss-')) {
copyrightPath = packageExtractionDir.toPath().resolve("usr/share/doc/elasticsearch-oss/copyright")
expectedLicense = "ASL-2.0"
Expand All @@ -432,7 +432,7 @@ subprojects {
checkLicense {
onlyIf rpmExists
doLast {
final String licenseFilename
String licenseFilename
if (project.name.contains('oss-')) {
licenseFilename = "APACHE-LICENSE-2.0.txt"
} else {
Expand Down Expand Up @@ -467,7 +467,7 @@ subprojects {
exec.commandLine 'dpkg-deb', '--info', "${ -> buildDist.outputs.files.filter(debFilter).singleFile}"
exec.standardOutput = output
doLast {
final String expectedLicense
String expectedLicense
if (project.name.contains('oss-')) {
expectedLicense = "ASL-2.0"
} else {
Expand Down Expand Up @@ -503,8 +503,8 @@ subprojects {
exec.commandLine 'rpm', '-qp', '--queryformat', '%{License}', "${-> buildDist.outputs.files.singleFile}"
exec.standardOutput = output
doLast {
final String license = output.toString('UTF-8')
final String expectedLicense
String license = output.toString('UTF-8')
String expectedLicense
if (project.name.contains('oss-')) {
expectedLicense = "ASL 2.0"
} else {
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionSha256Sum=fc049dcbcb245d5892bebae143bd515a78f6a5a93cec99d489b312dc0ce4aad9
distributionSha256Sum=17847c8e12b2bcfce26a79f425f082c31d4ded822f99a66127eee2d96bf18216
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
DEFAULT_JVM_OPTS='"-Xmx64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
Expand Down
2 changes: 1 addition & 1 deletion gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DEFAULT_JVM_OPTS="-Xmx64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
Expand Down
4 changes: 2 additions & 2 deletions plugins/repository-s3/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ final String minioBinDir = "${buildDir}/minio/bin"
final String minioDataDir = "${buildDir}/minio/data"
final String minioAddress = "127.0.0.1"

final String minioDistribution
final String minioCheckSum
String minioDistribution
String minioCheckSum
if (Os.isFamily(Os.FAMILY_MAC)) {
minioDistribution = 'darwin-amd64'
minioCheckSum = '96b0bcb2f590e8e65fb83d5c3e221f9bd1106b49fa6f22c6b726b80b845d7c60'
Expand Down
2 changes: 1 addition & 1 deletion qa/wildfly/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ repositories {
// the Wildfly distribution is not available via a repository, so we fake an Ivy repository on top of the download site
ivy {
url "http://download.jboss.org"
layout 'pattern', {
patternLayout {
artifact 'wildfly/[revision]/[module]-[revision].[ext]'
}
}
Expand Down
3 changes: 0 additions & 3 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,3 @@ if (extraProjects.exists()) {
addSubProjects('', extraProjectDir)
}
}

// enable in preparation for Gradle 5.0
enableFeaturePreview('STABLE_PUBLISHING')

0 comments on commit ddaf65d

Please sign in to comment.