Browse Source

Port gradle script plugins to precompiled script plugins (#72361)

Script plugins cannot apply plugins and therefore wont work with porting
buildSrc to an included build as we plan. Therefore we take advantage
of moving our script plugins into precompiled script plugins.

As a limitation of this we ran into problems applying binary plugins
from script plugins and for now moved this out of those scripts.
Rene Groeschke 4 years ago
parent
commit
17da1038fe

+ 12 - 9
build.gradle

@@ -27,18 +27,21 @@ plugins {
   id 'lifecycle-base'
   id 'elasticsearch.docker-support'
   id 'elasticsearch.global-build-info'
+  id 'elasticsearch.build-scan'
+  id 'elasticsearch.build-complete'
+  id 'elasticsearch.jdk-download'
+  id 'elasticsearch.internal-distribution-download'
+  id 'elasticsearch.runtime-jdk-provision'
+  id 'elasticsearch.ide'
+  id 'elasticsearch.forbidden-dependencies'
+  id 'elasticsearch.formatting'
+  id 'elasticsearch.local-distribution'
+  id 'elasticsearch.fips'
+  id 'elasticsearch.testclusters'
+  id 'elasticsearch.run'
   id "com.diffplug.spotless" version "5.12.0" apply false
 }
 
-apply from: 'gradle/build-scan.gradle'
-apply from: 'gradle/build-complete.gradle'
-apply from: 'gradle/runtime-jdk-provision.gradle'
-apply from: 'gradle/ide.gradle'
-apply from: 'gradle/forbidden-dependencies.gradle'
-apply from: 'gradle/formatting.gradle'
-apply from: 'gradle/local-distribution.gradle'
-apply from: 'gradle/fips.gradle'
-apply from: 'gradle/run.gradle'
 
 // common maven publishing configuration
 allprojects {

+ 4 - 0
buildSrc/build.gradle

@@ -93,6 +93,8 @@ dependencies {
   api 'org.apache.rat:apache-rat:0.11'
   api "org.elasticsearch:jna:5.7.0-1"
   api 'gradle.plugin.com.github.jengelman.gradle.plugins:shadow:7.0.0'
+  // for our ide tweaking
+  api 'gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext:0.7'
   // When upgrading forbidden apis, ensure dependency version is bumped in ThirdPartyPrecommitPlugin as well
   api 'de.thetaphi:forbiddenapis:3.1'
   api 'com.avast.gradle:gradle-docker-compose-plugin:0.14.0'
@@ -138,6 +140,8 @@ dependencies {
  *****************************************************************************/
 // this will only happen when buildSrc is built on its own during build init
 if (project == rootProject) {
+  apply plugin: 'groovy-gradle-plugin'
+
   repositories {
     if (System.getProperty("repos.mavenLocal") != null) {
       mavenLocal()

+ 8 - 0
gradle/build-complete.gradle → buildSrc/src/main/groovy/elasticsearch.build-complete.gradle

@@ -1,3 +1,11 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
 import java.nio.file.Files
 
 String buildNumber = System.getenv('BUILD_NUMBER')

+ 8 - 0
gradle/build-scan.gradle → buildSrc/src/main/groovy/elasticsearch.build-scan.gradle

@@ -1,3 +1,11 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
 import org.elasticsearch.gradle.Architecture
 import org.elasticsearch.gradle.OS
 import org.elasticsearch.gradle.internal.info.BuildParams

+ 10 - 4
gradle/bwc-test.gradle → buildSrc/src/main/groovy/elasticsearch.bwc-test.gradle

@@ -1,3 +1,11 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
 import org.elasticsearch.gradle.Version
 import org.elasticsearch.gradle.internal.info.BuildParams
 
@@ -25,8 +33,6 @@ tasks.withType(Test).configureEach {
   nonInputProperties.systemProperty 'tests.bwc', 'true'
 }
 
-tasks.named("check").configure {
-  dependsOn(bwcTestSnapshots)
-}
+tasks.matching { it.name.equals("check") }.configureEach {dependsOn(bwcTestSnapshots) }
 
-tasks.matching{ it.name.equals("test") }.configureEach {enabled = false}
+tasks.matching { it.name.equals("test") }.configureEach {enabled = false}

+ 8 - 0
gradle/fips.gradle → buildSrc/src/main/groovy/elasticsearch.fips.gradle

@@ -1,3 +1,11 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
 import org.elasticsearch.gradle.internal.ExportElasticsearchBuildResourcesTask
 import org.elasticsearch.gradle.internal.info.BuildParams
 import org.elasticsearch.gradle.testclusters.TestDistribution

+ 7 - 0
gradle/forbidden-dependencies.gradle → buildSrc/src/main/groovy/elasticsearch.forbidden-dependencies.gradle

@@ -1,3 +1,10 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
 
 // we do not want any of these dependencies on the compilation classpath
 // because they could then be used within Elasticsearch

+ 0 - 0
gradle/formatting.gradle → buildSrc/src/main/groovy/elasticsearch.formatting.gradle


+ 8 - 0
gradle/ide.gradle → buildSrc/src/main/groovy/elasticsearch.ide.gradle

@@ -1,3 +1,11 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
 import org.elasticsearch.gradle.internal.info.BuildParams
 import org.jetbrains.gradle.ext.JUnit
 

+ 3 - 1
gradle/local-distribution.gradle → buildSrc/src/main/groovy/elasticsearch.local-distribution.gradle

@@ -14,7 +14,9 @@
  * */
 import org.elasticsearch.gradle.Architecture
 
-apply plugin:'elasticsearch.internal-distribution-download'
+// gradle has an open issue of failing applying plugins in
+// precompiled script plugins (see https://github.com/gradle/gradle/issues/17004)
+// apply plugin:'elasticsearch.internal-distribution-download'
 
 elasticsearch_distributions {
   local {

+ 4 - 1
gradle/run.gradle → buildSrc/src/main/groovy/elasticsearch.run.gradle

@@ -5,9 +5,12 @@
  * in compliance with, at your election, the Elastic License 2.0 or the Server
  * Side Public License, v 1.
  */
+
 import org.elasticsearch.gradle.testclusters.RunTask
 
-apply plugin: 'elasticsearch.testclusters'
+// gradle has an open issue of failing applying plugins in
+// precompiled script plugins (see https://github.com/gradle/gradle/issues/17004)
+// apply plugin: 'elasticsearch.testclusters'
 
 testClusters {
   runTask {

+ 11 - 1
gradle/runtime-jdk-provision.gradle → buildSrc/src/main/groovy/elasticsearch.runtime-jdk-provision.gradle

@@ -1,9 +1,19 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
 import org.elasticsearch.gradle.Architecture
 import org.elasticsearch.gradle.OS
 import org.elasticsearch.gradle.internal.VersionProperties
 import org.elasticsearch.gradle.internal.info.BuildParams
 
-apply plugin: 'elasticsearch.jdk-download'
+// gradle has an open issue of failing applying plugins in
+// precompiled script plugins (see https://github.com/gradle/gradle/issues/17004)
+// apply plugin: 'elasticsearch.jdk-download'
 
 jdks {
     provisioned_runtime {

+ 1 - 1
qa/ccs-rolling-upgrade-remote-cluster/build.gradle

@@ -12,7 +12,7 @@ import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask
 
 apply plugin: 'elasticsearch.testclusters'
 apply plugin: 'elasticsearch.standalone-test'
-apply from: "$rootDir/gradle/bwc-test.gradle"
+apply plugin: 'elasticsearch.bwc-test'
 apply plugin: 'elasticsearch.rest-resources'
 
 dependencies {

+ 1 - 1
qa/full-cluster-restart/build.gradle

@@ -14,7 +14,7 @@ import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask
 apply plugin: 'elasticsearch.testclusters'
 apply plugin: 'elasticsearch.standalone-test'
 apply plugin: 'elasticsearch.internal-test-artifact'
-apply from : "$rootDir/gradle/bwc-test.gradle"
+apply plugin: 'elasticsearch.bwc-test'
 
 for (Version bwcVersion : BuildParams.bwcVersions.indexCompatible) {
   String baseName = "v${bwcVersion}"

+ 1 - 1
qa/mixed-cluster/build.gradle

@@ -13,7 +13,7 @@ import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask
 
 apply plugin: 'elasticsearch.testclusters'
 apply plugin: 'elasticsearch.standalone-test'
-apply from : "$rootDir/gradle/bwc-test.gradle"
+apply plugin: 'elasticsearch.bwc-test'
 apply plugin: 'elasticsearch.rest-resources'
 
 restResources {

+ 1 - 1
qa/repository-multi-version/build.gradle

@@ -14,7 +14,7 @@ apply plugin: 'elasticsearch.testclusters'
 apply plugin: 'elasticsearch.standalone-test'
 apply plugin: 'elasticsearch.internal-test-artifact'
 
-apply from : "$rootDir/gradle/bwc-test.gradle"
+apply plugin: 'elasticsearch.bwc-test'
 
 dependencies {
   testImplementation project(':client:rest-high-level')

+ 1 - 1
qa/rolling-upgrade/build.gradle

@@ -12,7 +12,7 @@ import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask
 
 apply plugin: 'elasticsearch.testclusters'
 apply plugin: 'elasticsearch.standalone-test'
-apply from : "$rootDir/gradle/bwc-test.gradle"
+apply plugin: 'elasticsearch.bwc-test'
 apply plugin: 'elasticsearch.rest-resources'
 
 for (Version bwcVersion : BuildParams.bwcVersions.wireCompatible) {

+ 1 - 1
qa/verify-version-constants/build.gradle

@@ -13,7 +13,7 @@ import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask
 
 apply plugin: 'elasticsearch.testclusters'
 apply plugin: 'elasticsearch.standalone-test'
-apply from : "$rootDir/gradle/bwc-test.gradle"
+apply plugin: 'elasticsearch.bwc-test'
 
 for (Version bwcVersion : BuildParams.bwcVersions.indexCompatible) {
   String baseName = "v${bwcVersion}"

+ 1 - 1
x-pack/plugin/eql/qa/mixed-node/build.gradle

@@ -1,6 +1,6 @@
 apply plugin: 'elasticsearch.testclusters'
 apply plugin: 'elasticsearch.standalone-rest-test'
-apply from : "$rootDir/gradle/bwc-test.gradle"
+apply plugin: 'elasticsearch.bwc-test'
 apply plugin: 'elasticsearch.rest-test'
 
 import org.elasticsearch.gradle.Version

+ 1 - 1
x-pack/plugin/sql/qa/jdbc/build.gradle

@@ -30,7 +30,7 @@ subprojects {
   if (subprojects.isEmpty()) {
     // leaf project
     apply plugin: 'elasticsearch.standalone-rest-test'
-    apply from: "$rootDir/gradle/bwc-test.gradle"
+    apply plugin: 'elasticsearch.bwc-test'
   } else {
     apply plugin: 'elasticsearch.java'
   }

+ 1 - 1
x-pack/plugin/sql/qa/mixed-node/build.gradle

@@ -1,6 +1,6 @@
 apply plugin: 'elasticsearch.testclusters'
 apply plugin: 'elasticsearch.standalone-rest-test'
-apply from : "$rootDir/gradle/bwc-test.gradle"
+apply plugin: 'elasticsearch.bwc-test'
 apply plugin: 'elasticsearch.rest-test'
 
 import org.elasticsearch.gradle.Version

+ 1 - 1
x-pack/qa/full-cluster-restart/build.gradle

@@ -4,7 +4,7 @@ import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask
 
 apply plugin: 'elasticsearch.testclusters'
 apply plugin: 'elasticsearch.standalone-test'
-apply from : "$rootDir/gradle/bwc-test.gradle"
+apply plugin: 'elasticsearch.bwc-test'
 
 dependencies {
   // TODO: Remove core dependency and change tests to not use builders that are part of xpack-core.

+ 1 - 1
x-pack/qa/mixed-tier-cluster/build.gradle

@@ -1,6 +1,6 @@
 apply plugin: 'elasticsearch.testclusters'
 apply plugin: 'elasticsearch.standalone-rest-test'
-apply from : "$rootDir/gradle/bwc-test.gradle"
+apply plugin: 'elasticsearch.bwc-test'
 apply plugin: 'elasticsearch.rest-test'
 
 import org.elasticsearch.gradle.Version

+ 1 - 1
x-pack/qa/rolling-upgrade-basic/build.gradle

@@ -4,7 +4,7 @@ import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask
 
 apply plugin: 'elasticsearch.testclusters'
 apply plugin: 'elasticsearch.standalone-test'
-apply from : "$rootDir/gradle/bwc-test.gradle"
+apply plugin: 'elasticsearch.bwc-test'
 
 dependencies {
   testImplementation project(':x-pack:qa')

+ 1 - 1
x-pack/qa/rolling-upgrade-multi-cluster/build.gradle

@@ -4,7 +4,7 @@ import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask
 
 apply plugin: 'elasticsearch.testclusters'
 apply plugin: 'elasticsearch.standalone-test'
-apply from : "$rootDir/gradle/bwc-test.gradle"
+apply plugin: 'elasticsearch.bwc-test'
 
 dependencies {
   testImplementation project(':x-pack:qa')

+ 1 - 1
x-pack/qa/rolling-upgrade/build.gradle

@@ -4,7 +4,7 @@ import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask
 
 apply plugin: 'elasticsearch.testclusters'
 apply plugin: 'elasticsearch.standalone-test'
-apply from : "$rootDir/gradle/bwc-test.gradle"
+apply plugin: 'elasticsearch.bwc-test'
 apply plugin: 'elasticsearch.rest-resources'
 
 dependencies {