|
@@ -6,26 +6,19 @@
|
|
|
* Side Public License, v 1.
|
|
|
*/
|
|
|
|
|
|
-import org.gradle.internal.jvm.Jvm
|
|
|
+
|
|
|
+import org.elasticsearch.gradle.internal.conventions.VersionPropertiesLoader
|
|
|
|
|
|
plugins {
|
|
|
id 'java-gradle-plugin'
|
|
|
+ id 'groovy-gradle-plugin'
|
|
|
id 'groovy'
|
|
|
- id 'java-test-fixtures'
|
|
|
+ id 'elasticsearch.internal-licenseheaders'
|
|
|
+ id 'elasticsearch.basic-build-tool-conventions'
|
|
|
}
|
|
|
|
|
|
group = 'org.elasticsearch.gradle'
|
|
|
|
|
|
-if (project == rootProject) {
|
|
|
- // change the build dir used during build init, so that doing a clean
|
|
|
- // won't wipe out the buildscript jar
|
|
|
- buildDir = 'build-bootstrap'
|
|
|
-}
|
|
|
-
|
|
|
-/*****************************************************************************
|
|
|
- * Propagating version.properties to the rest of the build *
|
|
|
- *****************************************************************************/
|
|
|
-
|
|
|
// we update the version property to reflect if we are building a snapshot or a release build
|
|
|
// we write this back out below to load it in the Build.java which will be shown in rest main action
|
|
|
// to indicate this being a snapshot build or a release build.
|
|
@@ -41,10 +34,6 @@ gradlePlugin {
|
|
|
id = 'elasticsearch.build'
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.BuildPlugin'
|
|
|
}
|
|
|
- distributionDownload {
|
|
|
- id = 'elasticsearch.distribution-download'
|
|
|
- implementationClass = 'org.elasticsearch.gradle.DistributionDownloadPlugin'
|
|
|
- }
|
|
|
distroTest {
|
|
|
id = 'elasticsearch.distro-test'
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.test.DistroTestPlugin'
|
|
@@ -57,10 +46,6 @@ gradlePlugin {
|
|
|
id = 'elasticsearch.docs-test'
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.doc.DocsTestPlugin'
|
|
|
}
|
|
|
- esPlugin {
|
|
|
- id = 'elasticsearch.esplugin'
|
|
|
- implementationClass = 'org.elasticsearch.gradle.plugin.PluginBuildPlugin'
|
|
|
- }
|
|
|
globalBuildInfo {
|
|
|
id = 'elasticsearch.global-build-info'
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.info.GlobalBuildInfoPlugin'
|
|
@@ -89,10 +74,6 @@ gradlePlugin {
|
|
|
id = 'elasticsearch.internal-distribution-download'
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.InternalDistributionDownloadPlugin'
|
|
|
}
|
|
|
- internalLicenseheaders {
|
|
|
- id = 'elasticsearch.internal-licenseheaders'
|
|
|
- implementationClass = 'org.elasticsearch.gradle.internal.precommit.LicenseHeadersPrecommitPlugin'
|
|
|
- }
|
|
|
internalPlugin {
|
|
|
id = 'elasticsearch.internal-es-plugin'
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.InternalPluginBuildPlugin'
|
|
@@ -125,14 +106,6 @@ gradlePlugin {
|
|
|
id = 'elasticsearch.jdk-download'
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.JdkDownloadPlugin'
|
|
|
}
|
|
|
- publish {
|
|
|
- id = 'elasticsearch.publish'
|
|
|
- implementationClass = 'org.elasticsearch.gradle.internal.PublishPlugin'
|
|
|
- }
|
|
|
- reaper {
|
|
|
- id = 'elasticsearch.reaper'
|
|
|
- implementationClass = 'org.elasticsearch.gradle.ReaperPlugin'
|
|
|
- }
|
|
|
repositories {
|
|
|
id = 'elasticsearch.repositories'
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.RepositoriesSetupPlugin'
|
|
@@ -169,10 +142,6 @@ gradlePlugin {
|
|
|
id = 'elasticsearch.test-with-ssl'
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.test.TestWithSslPlugin'
|
|
|
}
|
|
|
- testclusters {
|
|
|
- id = 'elasticsearch.testclusters'
|
|
|
- implementationClass = 'org.elasticsearch.gradle.testclusters.TestClustersPlugin'
|
|
|
- }
|
|
|
validateRestSpec {
|
|
|
id = 'elasticsearch.validate-rest-spec'
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.precommit.ValidateRestSpecPlugin'
|
|
@@ -187,15 +156,6 @@ gradlePlugin {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-def generateVersionProperties = tasks.register("generateVersionProperties", WriteProperties) {
|
|
|
- outputFile = "${buildDir}/version.properties"
|
|
|
- comment = 'Generated version properties'
|
|
|
- properties(props)
|
|
|
-}
|
|
|
-
|
|
|
-tasks.named("processResources").configure {
|
|
|
- from(generateVersionProperties)
|
|
|
-}
|
|
|
|
|
|
/*****************************************************************************
|
|
|
* Java version *
|
|
@@ -205,11 +165,9 @@ if (JavaVersion.current() < JavaVersion.VERSION_11) {
|
|
|
throw new GradleException('At least Java 11 is required to build elasticsearch gradle tools')
|
|
|
}
|
|
|
|
|
|
-allprojects {
|
|
|
- apply plugin: 'java'
|
|
|
- targetCompatibility = '11'
|
|
|
- sourceCompatibility = '11'
|
|
|
-}
|
|
|
+def minRuntimeJava = JavaVersion.toVersion(file('src/main/resources/minimumRuntimeVersion').text)
|
|
|
+targetCompatibility = minRuntimeJava
|
|
|
+sourceCompatibility = minRuntimeJava
|
|
|
|
|
|
sourceSets {
|
|
|
integTest {
|
|
@@ -222,6 +180,10 @@ tasks.withType(JavaCompile).configureEach {
|
|
|
options.encoding = 'UTF-8'
|
|
|
}
|
|
|
|
|
|
+tasks.named('licenseHeaders').configure {
|
|
|
+ // ignore gradle generated binary script plugins
|
|
|
+ excludes << "Elasticsearch*Plugin.java"
|
|
|
+}
|
|
|
/*****************************************************************************
|
|
|
* Dependencies used by the entire build *
|
|
|
*****************************************************************************/
|
|
@@ -238,6 +200,9 @@ dependencies {
|
|
|
api localGroovy()
|
|
|
api gradleApi()
|
|
|
|
|
|
+ api "org.elasticsearch:build-conventions:$version"
|
|
|
+ api "org.elasticsearch:build-tools:$version"
|
|
|
+
|
|
|
api 'commons-codec:commons-codec:1.12'
|
|
|
api 'org.apache.commons:commons-compress:1.19'
|
|
|
api 'org.apache.ant:ant:1.10.8'
|
|
@@ -260,22 +225,26 @@ dependencies {
|
|
|
api "org.apache.httpcomponents:httpcore:${props.getProperty('httpcore')}"
|
|
|
compileOnly "com.puppycrawl.tools:checkstyle:${props.getProperty('checkstyle')}"
|
|
|
testImplementation "com.puppycrawl.tools:checkstyle:${props.getProperty('checkstyle')}"
|
|
|
- testFixturesApi "junit:junit:${props.getProperty('junit')}"
|
|
|
- testFixturesApi "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${props.getProperty('randomizedrunner')}"
|
|
|
- testFixturesApi gradleApi()
|
|
|
- testFixturesApi gradleTestKit()
|
|
|
+ testImplementation "junit:junit:${props.getProperty('junit')}"
|
|
|
+// testFixturesApi "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${props.getProperty('randomizedrunner')}"
|
|
|
+// testFixturesApi gradleApi()
|
|
|
+// testFixturesApi gradleTestKit()
|
|
|
testImplementation 'com.github.tomakehurst:wiremock-jre8-standalone:2.23.2'
|
|
|
testImplementation 'org.mockito:mockito-core:1.9.5'
|
|
|
testImplementation "org.hamcrest:hamcrest:${props.getProperty('hamcrest')}"
|
|
|
|
|
|
+ testImplementation testFixtures("org.elasticsearch:build-tools:$version")
|
|
|
+
|
|
|
integTestImplementation(platform("org.junit:junit-bom:${props.getProperty('junit5')}"))
|
|
|
integTestImplementation("org.junit.jupiter:junit-jupiter") {
|
|
|
because 'allows to write and run Jupiter tests'
|
|
|
}
|
|
|
+ integTestImplementation("net.bytebuddy:byte-buddy:1.11.0") {
|
|
|
+ because 'Generating dynamic mocks of internal libraries like JdkJarHell'
|
|
|
+ }
|
|
|
testRuntimeOnly("org.junit.vintage:junit-vintage-engine") {
|
|
|
because 'allows JUnit 3 and JUnit 4 tests to run'
|
|
|
}
|
|
|
-
|
|
|
integTestRuntimeOnly("org.junit.platform:junit-platform-launcher") {
|
|
|
because 'allows tests to run from IDEs that bundle older version of launcher'
|
|
|
}
|
|
@@ -293,186 +262,12 @@ dependencies {
|
|
|
integTestImplementation "org.xmlunit:xmlunit-core:2.8.2"
|
|
|
}
|
|
|
|
|
|
-/*****************************************************************************
|
|
|
- * Bootstrap repositories *
|
|
|
- *****************************************************************************/
|
|
|
-// 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()
|
|
|
- }
|
|
|
- }
|
|
|
- dependencies {
|
|
|
- // add this so the runtime classpath so Gradle will properly track it as a build runtime classpath input
|
|
|
- runtimeOnly project('reaper')
|
|
|
- }
|
|
|
- // only run tests as build-tools
|
|
|
- tasks.named("test").configure {
|
|
|
- enabled = false
|
|
|
- }
|
|
|
+tasks.register("integTest", Test) {
|
|
|
+ inputs.dir(file("src/testKit")).withPropertyName("testkit dir").withPathSensitivity(PathSensitivity.RELATIVE)
|
|
|
+ systemProperty 'test.version_under_test', version
|
|
|
+ testClassesDirs = sourceSets.integTest.output.classesDirs
|
|
|
+ classpath = sourceSets.integTest.runtimeClasspath
|
|
|
+ useJUnitPlatform()
|
|
|
}
|
|
|
|
|
|
-/*****************************************************************************
|
|
|
- * Normal project checks *
|
|
|
- *****************************************************************************/
|
|
|
-
|
|
|
-// this happens when included as a normal project in the build, which we do
|
|
|
-// to enforce precommit checks like forbidden apis, as well as setup publishing
|
|
|
-if (project != rootProject) {
|
|
|
- apply plugin: 'elasticsearch.build'
|
|
|
- apply plugin: 'elasticsearch.publish'
|
|
|
-
|
|
|
- // groovydoc succeeds, but has some weird internal exception...
|
|
|
- tasks.named("groovydoc").configure {
|
|
|
- enabled = false
|
|
|
- }
|
|
|
-
|
|
|
- // build-tools is not ready for primetime with these...
|
|
|
- tasks.named("dependencyLicenses").configure { enabled = false }
|
|
|
- tasks.named("dependenciesInfo").configure {enabled = false }
|
|
|
- tasks.named("dependenciesGraph").configure {enabled = false }
|
|
|
- disableTasks('forbiddenApisMain', 'forbiddenApisTest', 'forbiddenApisIntegTest', 'forbiddenApisTestFixtures')
|
|
|
- tasks.named("jarHell").configure {
|
|
|
- enabled = false
|
|
|
- }
|
|
|
- tasks.named("thirdPartyAudit").configure {
|
|
|
- enabled = false
|
|
|
- }
|
|
|
- configurations.register("distribution")
|
|
|
- configurations.register("reaper")
|
|
|
-
|
|
|
- dependencies {
|
|
|
- reaper project('reaper')
|
|
|
- distribution project(':distribution:archives:windows-zip')
|
|
|
- distribution project(':distribution:archives:darwin-tar')
|
|
|
- distribution project(':distribution:archives:darwin-aarch64-tar')
|
|
|
- distribution project(':distribution:archives:linux-aarch64-tar')
|
|
|
- distribution project(':distribution:archives:linux-tar')
|
|
|
- integTestRuntimeOnly(project(":libs:elasticsearch-core"))
|
|
|
- }
|
|
|
-
|
|
|
- eclipse {
|
|
|
- classpath {
|
|
|
- plusConfigurations += [configurations.integTestRuntimeClasspath]
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // for external projects we want to remove the marker file indicating we are running the Elasticsearch project
|
|
|
- tasks.named("processResources").configure {
|
|
|
- exclude 'buildSrc.marker'
|
|
|
- into('META-INF') {
|
|
|
- from configurations.reaper
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- tasks.withType(Test).configureEach {
|
|
|
- // Track reaper jar as a test input using runtime classpath normalization strategy
|
|
|
- inputs.files(configurations.reaper).withNormalizer(ClasspathNormalizer)
|
|
|
- useJUnitPlatform()
|
|
|
- }
|
|
|
-
|
|
|
- tasks.named("test").configure {
|
|
|
- include("**/*TestSpec.class")
|
|
|
- }
|
|
|
-
|
|
|
- normalization {
|
|
|
- runtimeClasspath {
|
|
|
- // We already include the reaper jar as part of our runtime classpath. Ignore the copy in META-INF.
|
|
|
- ignore('META-INF/reaper.jar')
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- tasks.named("forbiddenPatterns").configure {
|
|
|
- exclude '**/*.wav'
|
|
|
- exclude '**/*.p12'
|
|
|
- exclude '**/*.jks'
|
|
|
- exclude '**/*.crt'
|
|
|
- // the file that actually defines nocommit
|
|
|
- exclude '**/ForbiddenPatternsTask.java'
|
|
|
- exclude '**/*.bcfks'
|
|
|
- }
|
|
|
-
|
|
|
- tasks.named("testingConventions") {
|
|
|
- naming.clear()
|
|
|
- naming {
|
|
|
- Tests {
|
|
|
- baseClass 'org.elasticsearch.gradle.internal.test.GradleUnitTestCase'
|
|
|
- }
|
|
|
- TestSpec {
|
|
|
- baseClass 'spock.lang.Specification'
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- tasks.register("integTest", Test) {
|
|
|
- inputs.dir(file("src/testKit")).withPropertyName("testkit dir").withPathSensitivity(PathSensitivity.RELATIVE)
|
|
|
- systemProperty 'test.version_under_test', version
|
|
|
- testClassesDirs = sourceSets.integTest.output.classesDirs
|
|
|
- classpath = sourceSets.integTest.runtimeClasspath
|
|
|
- useJUnitPlatform()
|
|
|
- }
|
|
|
- tasks.named("check").configure { dependsOn("integTest") }
|
|
|
-
|
|
|
- // for now we hardcode the tests for our build to use the gradle jvm.
|
|
|
- tasks.withType(Test).configureEach {
|
|
|
- onlyIf { org.elasticsearch.gradle.internal.info.BuildParams.inFipsJvm == false }
|
|
|
- it.executable = Jvm.current().getJavaExecutable()
|
|
|
- maxParallelForks = providers.systemProperty('tests.jvms').forUseAtConfigurationTime().getOrElse(org.elasticsearch.gradle.internal.info.BuildParams.defaultParallel.toString()) as Integer
|
|
|
- }
|
|
|
-
|
|
|
- publishing.publications.named("elastic").configure {
|
|
|
- suppressPomMetadataWarningsFor("testFixturesApiElements")
|
|
|
- suppressPomMetadataWarningsFor("testFixturesRuntimeElements")
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-// Define this here because we need it early.
|
|
|
-class VersionPropertiesLoader {
|
|
|
- static Properties loadBuildSrcVersion(File input) throws IOException {
|
|
|
- Properties props = new Properties();
|
|
|
- InputStream is = new FileInputStream(input)
|
|
|
- try {
|
|
|
- props.load(is)
|
|
|
- } finally {
|
|
|
- is.close()
|
|
|
- }
|
|
|
- loadBuildSrcVersion(props, System.getProperties())
|
|
|
- return props
|
|
|
- }
|
|
|
-
|
|
|
- protected static void loadBuildSrcVersion(Properties loadedProps, Properties systemProperties) {
|
|
|
- String elasticsearch = loadedProps.getProperty("elasticsearch")
|
|
|
- if (elasticsearch == null) {
|
|
|
- throw new IllegalStateException("Elasticsearch version is missing from properties.")
|
|
|
- }
|
|
|
- if (elasticsearch.matches("[0-9]+\\.[0-9]+\\.[0-9]+") == false) {
|
|
|
- throw new IllegalStateException(
|
|
|
- "Expected elasticsearch version to be numbers only of the form X.Y.Z but it was: " +
|
|
|
- elasticsearch
|
|
|
- )
|
|
|
- }
|
|
|
- String qualifier = systemProperties.getProperty("build.version_qualifier", "")
|
|
|
- if (qualifier.isEmpty() == false) {
|
|
|
- if (qualifier.matches("(alpha|beta|rc)\\d+") == false) {
|
|
|
- throw new IllegalStateException("Invalid qualifier: " + qualifier)
|
|
|
- }
|
|
|
- elasticsearch += "-" + qualifier
|
|
|
- }
|
|
|
- final String buildSnapshotSystemProperty = systemProperties.getProperty("build.snapshot", "true");
|
|
|
- switch (buildSnapshotSystemProperty) {
|
|
|
- case "true":
|
|
|
- elasticsearch += "-SNAPSHOT"
|
|
|
- break;
|
|
|
- case "false":
|
|
|
- // do nothing
|
|
|
- break;
|
|
|
- default:
|
|
|
- throw new IllegalArgumentException(
|
|
|
- "build.snapshot was set to [" + buildSnapshotSystemProperty + "] but can only be unset or [true|false]");
|
|
|
- }
|
|
|
- loadedProps.put("elasticsearch", elasticsearch)
|
|
|
- }
|
|
|
-}
|
|
|
+tasks.named("check").configure { dependsOn("integTest") }
|