elasticsearch/build-tools-internal/build.gradle

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

301 lines
12 KiB
Groovy
Raw Normal View History

/*
* 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.apache.tools.ant.filters.ReplaceTokens
import org.elasticsearch.gradle.internal.conventions.info.GitInfo
Remove deprecation warnings to prepare for Gradle 5 (sourceSets.main.output.classesDirs) (#30389) * Remove deprecation warnings to prepare for Gradle 5 Gradle replaced `project.sourceSets.main.output.classesDir` of type `File` with `project.sourceSets.main.output.classesDirs` of type `FileCollection` (see [SourceSetOutput](https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/java/org/gradle/api/tasks/SourceSetOutput.java)) Build output is now stored on a per language folder. There are a few places where we use that, here's these and how it's fixed: - Randomized Test execution - look in all test folders ( pass the multi dir configuration to the ant runner ) - DRY the task configuration by introducing `basedOn` for `RandomizedTestingTask` DSL - Extend the naming convention test to support passing in multiple directories - Fix the standalon test plugin, the dires were not passed trough, checked with a debuger and the statement had no affect due to a missing `=`. Closes #30354 * Only check Java tests, PR feedback - Name checker was ran for Groovy tests that don't adhere to the same convections causing the check to fail - implement PR feedback * Replace `add` with `addAll` This worked because the list is passed to `project.files` that does the right thing. * Revert "Only check Java tests, PR feedback" This reverts commit 9bd9389875d8b88aadb50df57a45cd0d2b073241. * Remove `basedOn` helper * Bring some changes back Previus revert accidentally reverted too much * Fix negation * add back public * revert name check changes * Revert "revert name check changes" This reverts commit a2800c0b363168339ea65e2a79ec8256e5883e6d. * Pass all dirs to name check Only run on Java for build-tools, this is safe because it's a self test. It needs more work before we could pass in the Groovy classes as well as these inherit from `GroovyTestCase` * remove self tests from name check The self complicates the task setup and disable real checks on build-tools. With this change there are no more self tests, and the build-tools tests adhere to the conventions. The self test will be replaced by gradle test kit, thus the addition of the Gradle plugin builder plugin. * First test to run a Gradle build * Add tests that replace the name check self test * Clean up integ test base class * Always run tests * Align with test naming conventions * Make integ. test case inherit from unit test case The check requires this * Remove `import static org.junit.Assert.*`
2018-06-28 20:14:34 +08:00
plugins {
id 'java-gradle-plugin'
id 'groovy-gradle-plugin'
Remove deprecation warnings to prepare for Gradle 5 (sourceSets.main.output.classesDirs) (#30389) * Remove deprecation warnings to prepare for Gradle 5 Gradle replaced `project.sourceSets.main.output.classesDir` of type `File` with `project.sourceSets.main.output.classesDirs` of type `FileCollection` (see [SourceSetOutput](https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/java/org/gradle/api/tasks/SourceSetOutput.java)) Build output is now stored on a per language folder. There are a few places where we use that, here's these and how it's fixed: - Randomized Test execution - look in all test folders ( pass the multi dir configuration to the ant runner ) - DRY the task configuration by introducing `basedOn` for `RandomizedTestingTask` DSL - Extend the naming convention test to support passing in multiple directories - Fix the standalon test plugin, the dires were not passed trough, checked with a debuger and the statement had no affect due to a missing `=`. Closes #30354 * Only check Java tests, PR feedback - Name checker was ran for Groovy tests that don't adhere to the same convections causing the check to fail - implement PR feedback * Replace `add` with `addAll` This worked because the list is passed to `project.files` that does the right thing. * Revert "Only check Java tests, PR feedback" This reverts commit 9bd9389875d8b88aadb50df57a45cd0d2b073241. * Remove `basedOn` helper * Bring some changes back Previus revert accidentally reverted too much * Fix negation * add back public * revert name check changes * Revert "revert name check changes" This reverts commit a2800c0b363168339ea65e2a79ec8256e5883e6d. * Pass all dirs to name check Only run on Java for build-tools, this is safe because it's a self test. It needs more work before we could pass in the Groovy classes as well as these inherit from `GroovyTestCase` * remove self tests from name check The self complicates the task setup and disable real checks on build-tools. With this change there are no more self tests, and the build-tools tests adhere to the conventions. The self test will be replaced by gradle test kit, thus the addition of the Gradle plugin builder plugin. * First test to run a Gradle build * Add tests that replace the name check self test * Clean up integ test base class * Always run tests * Align with test naming conventions * Make integ. test case inherit from unit test case The check requires this * Remove `import static org.junit.Assert.*`
2018-06-28 20:14:34 +08:00
id 'groovy'
id 'elasticsearch.build-tools'
id 'elasticsearch.eclipse'
id 'elasticsearch.versions'
id 'elasticsearch.formatting'
Remove deprecation warnings to prepare for Gradle 5 (sourceSets.main.output.classesDirs) (#30389) * Remove deprecation warnings to prepare for Gradle 5 Gradle replaced `project.sourceSets.main.output.classesDir` of type `File` with `project.sourceSets.main.output.classesDirs` of type `FileCollection` (see [SourceSetOutput](https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/java/org/gradle/api/tasks/SourceSetOutput.java)) Build output is now stored on a per language folder. There are a few places where we use that, here's these and how it's fixed: - Randomized Test execution - look in all test folders ( pass the multi dir configuration to the ant runner ) - DRY the task configuration by introducing `basedOn` for `RandomizedTestingTask` DSL - Extend the naming convention test to support passing in multiple directories - Fix the standalon test plugin, the dires were not passed trough, checked with a debuger and the statement had no affect due to a missing `=`. Closes #30354 * Only check Java tests, PR feedback - Name checker was ran for Groovy tests that don't adhere to the same convections causing the check to fail - implement PR feedback * Replace `add` with `addAll` This worked because the list is passed to `project.files` that does the right thing. * Revert "Only check Java tests, PR feedback" This reverts commit 9bd9389875d8b88aadb50df57a45cd0d2b073241. * Remove `basedOn` helper * Bring some changes back Previus revert accidentally reverted too much * Fix negation * add back public * revert name check changes * Revert "revert name check changes" This reverts commit a2800c0b363168339ea65e2a79ec8256e5883e6d. * Pass all dirs to name check Only run on Java for build-tools, this is safe because it's a self test. It needs more work before we could pass in the Groovy classes as well as these inherit from `GroovyTestCase` * remove self tests from name check The self complicates the task setup and disable real checks on build-tools. With this change there are no more self tests, and the build-tools tests adhere to the conventions. The self test will be replaced by gradle test kit, thus the addition of the Gradle plugin builder plugin. * First test to run a Gradle build * Add tests that replace the name check self test * Clean up integ test base class * Always run tests * Align with test naming conventions * Make integ. test case inherit from unit test case The check requires this * Remove `import static org.junit.Assert.*`
2018-06-28 20:14:34 +08:00
}
group = 'org.elasticsearch.gradle'
// 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.
version = versions.getProperty("elasticsearch")
gradlePlugin {
// We already configure publication and we don't need or want the one that comes
// with the java-gradle-plugin
automatedPublishing = false
plugins {
build {
id = 'elasticsearch.build'
implementationClass = 'org.elasticsearch.gradle.internal.BuildPlugin'
}
distroTest {
id = 'elasticsearch.distro-test'
implementationClass = 'org.elasticsearch.gradle.internal.test.DistroTestPlugin'
}
dockerSupport {
id = 'elasticsearch.docker-support'
implementationClass = 'org.elasticsearch.gradle.internal.docker.DockerSupportPlugin'
}
docsTest {
id = 'elasticsearch.docs-test'
implementationClass = 'org.elasticsearch.gradle.internal.doc.DocsTestPlugin'
}
globalBuildInfo {
id = 'elasticsearch.global-build-info'
implementationClass = 'org.elasticsearch.gradle.internal.info.GlobalBuildInfoPlugin'
}
internalAvailablePorts {
id = 'elasticsearch.internal-available-ports'
implementationClass = 'org.elasticsearch.gradle.internal.InternalAvailableTcpPortProviderPlugin'
}
internalClusterTest {
id = 'elasticsearch.internal-cluster-test'
implementationClass = 'org.elasticsearch.gradle.internal.test.InternalClusterTestPlugin'
}
internalDistributionArchiveCheck {
id = 'elasticsearch.internal-distribution-archive-check'
implementationClass = 'org.elasticsearch.gradle.internal.InternalDistributionArchiveCheckPlugin'
}
internalDistributionArchiveSetup {
id = 'elasticsearch.internal-distribution-archive-setup'
implementationClass = 'org.elasticsearch.gradle.internal.InternalDistributionArchiveSetupPlugin'
}
internalDistributionBwcSetup {
id = 'elasticsearch.internal-distribution-bwc-setup'
implementationClass = 'org.elasticsearch.gradle.internal.InternalDistributionBwcSetupPlugin'
}
internalDistributionDownload {
id = 'elasticsearch.internal-distribution-download'
implementationClass = 'org.elasticsearch.gradle.internal.InternalDistributionDownloadPlugin'
}
internalPlugin {
id = 'elasticsearch.internal-es-plugin'
implementationClass = 'org.elasticsearch.gradle.internal.InternalPluginBuildPlugin'
}
internalTestArtifact {
id = 'elasticsearch.internal-test-artifact'
implementationClass = 'org.elasticsearch.gradle.internal.InternalTestArtifactPlugin'
}
internalTestArtifactBase {
id = 'elasticsearch.internal-test-artifact-base'
implementationClass = 'org.elasticsearch.gradle.internal.InternalTestArtifactBasePlugin'
}
internalTestClusters {
id = 'elasticsearch.internal-testclusters'
implementationClass = 'org.elasticsearch.gradle.internal.InternalTestClustersPlugin'
}
internalTestRerun {
id = 'elasticsearch.internal-test-rerun'
implementationClass = 'org.elasticsearch.gradle.internal.test.rerun.TestRerunPlugin'
}
java {
id = 'elasticsearch.java'
implementationClass = 'org.elasticsearch.gradle.internal.ElasticsearchJavaPlugin'
}
internalJavaRestTest {
id = 'elasticsearch.internal-java-rest-test'
implementationClass = 'org.elasticsearch.gradle.internal.test.rest.InternalJavaRestTestPlugin'
}
jdkDownload {
id = 'elasticsearch.jdk-download'
implementationClass = 'org.elasticsearch.gradle.internal.JdkDownloadPlugin'
}
releaseTools {
id = 'elasticsearch.release-tools'
implementationClass = 'org.elasticsearch.gradle.internal.release.ReleaseToolsPlugin'
}
repositories {
id = 'elasticsearch.repositories'
implementationClass = 'org.elasticsearch.gradle.internal.RepositoriesSetupPlugin'
}
restResources {
id = 'elasticsearch.rest-resources'
implementationClass = 'org.elasticsearch.gradle.internal.test.rest.RestResourcesPlugin'
}
restTest {
id = 'elasticsearch.rest-test'
implementationClass = 'org.elasticsearch.gradle.internal.test.RestTestPlugin'
}
standaloneRestTest {
id = 'elasticsearch.standalone-rest-test'
implementationClass = 'org.elasticsearch.gradle.internal.test.StandaloneRestTestPlugin'
}
standaloneTest {
id = 'elasticsearch.standalone-test'
implementationClass = 'org.elasticsearch.gradle.internal.test.StandaloneTestPlugin'
}
testFixtures {
id = 'elasticsearch.test.fixtures'
implementationClass = 'org.elasticsearch.gradle.internal.testfixtures.TestFixturesPlugin'
}
testBase {
id = 'elasticsearch.test-base'
implementationClass = 'org.elasticsearch.gradle.internal.ElasticsearchTestBasePlugin'
}
testWithDependencies {
id = 'elasticsearch.test-with-dependencies'
implementationClass = 'org.elasticsearch.gradle.internal.test.TestWithDependenciesPlugin'
}
testWithSsl {
id = 'elasticsearch.test-with-ssl'
implementationClass = 'org.elasticsearch.gradle.internal.test.TestWithSslPlugin'
}
validateRestSpec {
id = 'elasticsearch.validate-rest-spec'
implementationClass = 'org.elasticsearch.gradle.internal.precommit.ValidateRestSpecPlugin'
}
yamlRestCompatTest {
id = 'elasticsearch.yaml-rest-compat-test'
implementationClass = 'org.elasticsearch.gradle.internal.rest.compat.YamlRestCompatTestPlugin'
}
yamlRestTest {
id = 'elasticsearch.internal-yaml-rest-test'
implementationClass = 'org.elasticsearch.gradle.internal.test.rest.InternalYamlRestTestPlugin'
}
}
}
/*****************************************************************************
* Java version *
*****************************************************************************/
def minCompilerJava = versions.get("minimumCompilerJava")
targetCompatibility = minCompilerJava
sourceCompatibility = minCompilerJava
if (JavaVersion.current() < JavaVersion.toVersion(minCompilerJava)) {
throw new GradleException("Java ${minCompilerJava} is required to build Elasticsearch but current Java is version ${JavaVersion.current()}.")
}
sourceSets {
integTest {
compileClasspath += sourceSets["main"].output + configurations["testRuntimeClasspath"]
runtimeClasspath += output + compileClasspath
}
}
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 *
*****************************************************************************/
repositories {
mavenCentral()
gradlePluginPortal()
}
configurations {
integTestRuntimeOnly.extendsFrom(testRuntimeOnly)
}
dependencies {
constraints {
api("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${versions.getProperty('jackson')}") {
version {
strictly "${versions.getProperty('jackson')}"
}
because 'We want to use the exact same jackson version we use in production'
}
}
api localGroovy()
api gradleApi()
api "org.elasticsearch:build-conventions:$version"
api "org.elasticsearch.gradle:build-tools:$version"
// same version as http client transitive dep
api 'commons-codec:commons-codec:1.11'
api 'org.apache.commons:commons-compress:1.19'
api 'org.apache.ant:ant:1.10.8'
api 'com.netflix.nebula:gradle-extra-configurations-plugin:7.0.0'
api 'com.netflix.nebula:gradle-info-plugin:11.1.0'
api 'org.apache.rat:apache-rat:0.11'
api "net.java.dev.jna:jna:${versions.getProperty('jna')}"
api 'gradle.plugin.com.github.johnrengelman:shadow:7.1.2'
// for our ide tweaking
api 'gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext:1.1.1'
// When upgrading forbidden apis, ensure dependency version is bumped in ThirdPartyPrecommitPlugin as well
api 'de.thetaphi:forbiddenapis:3.2'
api 'com.avast.gradle:gradle-docker-compose-plugin:0.14.13'
api 'org.apache.maven:maven-model:3.6.2'
api 'com.networknt:json-schema-validator:1.0.65'
api "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${versions.getProperty('jackson')}"
api 'org.ow2.asm:asm:9.2'
api 'org.ow2.asm:asm-tree:9.2'
api "org.apache.httpcomponents:httpclient:${versions.getProperty('httpclient')}"
api "org.apache.httpcomponents:httpcore:${versions.getProperty('httpcore')}"
compileOnly "com.puppycrawl.tools:checkstyle:${versions.getProperty('checkstyle')}"
runtimeOnly "org.elasticsearch.gradle:reaper:$version"
testImplementation "com.puppycrawl.tools:checkstyle:${versions.getProperty('checkstyle')}"
testImplementation 'com.github.tomakehurst:wiremock-jre8-standalone:2.23.2'
testImplementation 'org.mockito:mockito-core:1.9.5'
testImplementation "org.hamcrest:hamcrest:${versions.getProperty('hamcrest')}"
testImplementation testFixtures("org.elasticsearch.gradle:build-tools:$version")
testImplementation(platform("org.junit:junit-bom:${versions.getProperty('junit5')}"))
testImplementation("org.junit.jupiter:junit-jupiter") {
because 'allows to write and run Jupiter tests'
}
integTestImplementation(platform("org.junit:junit-bom:${versions.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'
}
testRuntimeOnly("org.junit.platform:junit-platform-launcher") {
because 'allows tests to run from IDEs that bundle older version of launcher'
}
testImplementation platform("org.spockframework:spock-bom:2.0-groovy-3.0")
testImplementation("org.spockframework:spock-core") {
exclude module: "groovy"
}
integTestImplementation platform("org.spockframework:spock-bom:2.0-groovy-3.0")
integTestImplementation("org.spockframework:spock-core") {
exclude module: "groovy"
}
// required as we rely on junit4 rules
integTestImplementation("org.spockframework:spock-junit4") {
exclude module: "groovy"
}
testImplementation "org.spockframework:spock-junit4"
integTestImplementation "org.xmlunit:xmlunit-core:2.8.2"
}
tasks.named('test').configure {
useJUnitPlatform()
}
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") }
tasks.register("bootstrapPerformanceTests", Copy) {
from('performance')
into('build/performanceTests')
def root = file('..')
filter(ReplaceTokens, tokens: [testGitCommit:GitInfo.gitInfo(root).revision])
}