فهرست منبع

Upgrade to Gradle 5.0 (#34263)

Alpar Torok 6 سال پیش
والد
کامیت
59b0900174
27فایلهای تغییر یافته به همراه65 افزوده شده و 50 حذف شده
  1. 1 1
      benchmarks/build.gradle
  2. 5 2
      build.gradle
  3. 1 1
      buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/TestProgressLogger.groovy
  4. 2 2
      buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy
  5. 1 3
      buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/PrecommitTasks.groovy
  6. 3 3
      buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy
  7. 6 6
      buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestIntegTestTask.groovy
  8. 1 1
      buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RunTask.groovy
  9. 2 2
      buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy
  10. 2 3
      buildSrc/src/main/java/org/elasticsearch/gradle/ExportElasticsearchBuildResourcesTask.java
  11. 1 1
      buildSrc/src/main/resources/minimumGradleVersion
  12. 0 0
      buildSrc/src/testKit/elasticsearch-build-resources/settings.gradle
  13. 0 0
      buildSrc/src/testKit/elasticsearch.build/settings.gradle
  14. 0 0
      buildSrc/src/testKit/jarHell/settings.gradle
  15. 0 0
      buildSrc/src/testKit/namingConventionsSelfTest/settings.gradle
  16. 0 0
      buildSrc/src/testKit/testclusters/settings.gradle
  17. 21 3
      client/rest-high-level/build.gradle
  18. 3 3
      distribution/archives/build.gradle
  19. 1 1
      distribution/bwc/build.gradle
  20. 8 8
      distribution/packages/build.gradle
  21. BIN
      gradle/wrapper/gradle-wrapper.jar
  22. 2 2
      gradle/wrapper/gradle-wrapper.properties
  23. 1 1
      gradlew
  24. 1 1
      gradlew.bat
  25. 2 2
      plugins/repository-s3/build.gradle
  26. 1 1
      qa/wildfly/build.gradle
  27. 0 3
      settings.gradle

+ 1 - 1
benchmarks/build.gradle

@@ -33,7 +33,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'

+ 5 - 2
build.gradle

@@ -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") {
@@ -527,7 +530,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."
   )

+ 1 - 1
buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/TestProgressLogger.groovy

@@ -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:

+ 2 - 2
buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy

@@ -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())) {
@@ -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)

+ 1 - 3
buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/PrecommitTasks.groovy

@@ -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')
@@ -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)

+ 3 - 3
buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy

@@ -111,8 +111,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)) {
@@ -595,7 +595,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 {

+ 6 - 6
buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestIntegTestTask.groovy

@@ -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
@@ -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)
@@ -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
@@ -130,7 +130,7 @@ public class RestIntegTestTask extends DefaultTask {
 
     /** Sets the includePackaged property */
     public void includePackaged(boolean include) {
-        includePackaged.set(include)
+        includePackaged = include
     }
 
     @Option(
@@ -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
         }
@@ -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/**'
                 }
             }

+ 1 - 1
buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RunTask.groovy

@@ -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 {

+ 2 - 2
buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy

@@ -464,9 +464,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 {

+ 2 - 3
buildSrc/src/main/java/org/elasticsearch/gradle/ExportElasticsearchBuildResourcesTask.java

@@ -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

+ 1 - 1
buildSrc/src/main/resources/minimumGradleVersion

@@ -1 +1 @@
-4.10
+5.0

+ 0 - 0
buildSrc/src/testKit/elasticsearch-build-resources/settings.gradle


+ 0 - 0
buildSrc/src/testKit/elasticsearch.build/settings.gradle


+ 0 - 0
buildSrc/src/testKit/jarHell/settings.gradle


+ 0 - 0
buildSrc/src/testKit/namingConventionsSelfTest/settings.gradle


+ 0 - 0
buildSrc/src/testKit/testclusters/settings.gradle


+ 21 - 3
client/rest-high-level/build.gradle

@@ -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 {
   /*
@@ -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 {

+ 3 - 3
distribution/archives/build.gradle

@@ -151,7 +151,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 {
@@ -179,7 +179,7 @@ subprojects {
     }
   }
 
-  final Closure toolExists
+  Closure toolExists
   if (project.name.contains('tar')) {
     toolExists = tarExists
   } else {
@@ -192,7 +192,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 {

+ 1 - 1
distribution/bwc/build.gradle

@@ -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

+ 8 - 8
distribution/packages/build.gradle

@@ -359,7 +359,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 {
@@ -406,9 +406,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"
@@ -431,7 +431,7 @@ subprojects {
     checkLicense {
       onlyIf rpmExists
       doLast {
-        final String licenseFilename
+        String licenseFilename
         if (project.name.contains('oss-')) {
           licenseFilename = "APACHE-LICENSE-2.0.txt"
         } else {
@@ -466,7 +466,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 {
@@ -502,8 +502,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 {

BIN
gradle/wrapper/gradle-wrapper.jar


+ 2 - 2
gradle/wrapper/gradle-wrapper.properties

@@ -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

+ 1 - 1
gradlew

@@ -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"

+ 1 - 1
gradlew.bat

@@ -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

+ 2 - 2
plugins/repository-s3/build.gradle

@@ -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'

+ 1 - 1
qa/wildfly/build.gradle

@@ -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]'
         }
     }

+ 0 - 3
settings.gradle

@@ -139,7 +139,4 @@ if (extraProjects.exists()) {
   }
 }
 
-// enable in preparation for Gradle 5.0
-enableFeaturePreview('STABLE_PUBLISHING')
-
 project(":libs:cli").name = 'elasticsearch-cli'