elasticsearch/build-tools/build.gradle

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

215 lines
7.1 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.elasticsearch.gradle.internal.conventions.VersionPropertiesLoader
plugins {
id 'java-gradle-plugin'
id 'groovy'
id 'java-test-fixtures'
id 'elasticsearch.publish'
id 'elasticsearch.build-tools'
}
description = "The elasticsearch build tools"
// 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.
Properties props = VersionPropertiesLoader.loadBuildSrcVersion(project.file('../build-tools-internal/version.properties'))
def minRuntimeJava = JavaVersion.toVersion(file('../build-tools-internal/src/main/resources/minimumRuntimeVersion').text)
allprojects {
group = "org.elasticsearch.gradle"
version = props.getProperty("elasticsearch")
apply plugin: 'java'
apply plugin: 'elasticsearch.eclipse'
targetCompatibility = minRuntimeJava
sourceCompatibility = minRuntimeJava
}
gradlePlugin {
// We already configure publication and we don't need or want the one that comes
// with the java-gradle-plugin
automatedPublishing = false
plugins {
distributionDownload {
id = 'elasticsearch.distribution-download'
implementationClass = 'org.elasticsearch.gradle.DistributionDownloadPlugin'
}
esPlugin {
id = 'elasticsearch.esplugin'
implementationClass = 'org.elasticsearch.gradle.plugin.PluginBuildPlugin'
}
testclusters {
id = 'elasticsearch.testclusters'
implementationClass = 'org.elasticsearch.gradle.testclusters.TestClustersPlugin'
}
reaper {
id = 'elasticsearch.reaper'
implementationClass = 'org.elasticsearch.gradle.ReaperPlugin'
}
}
}
def generateVersionProperties = tasks.register("generateVersionProperties", WriteProperties) {
outputFile = "${buildDir}/version.properties"
comment = 'Generated version properties'
properties(props)
}
tasks.named("processResources").configure {
from(generateVersionProperties)
into('META-INF') {
from configurations.reaper
}
}
sourceSets {
integTest {
compileClasspath += sourceSets["main"].output + configurations["testRuntimeClasspath"]
runtimeClasspath += output + compileClasspath
}
}
// we do not publish the test fixtures of build-tools
components.java.withVariantsFromConfiguration(configurations.testFixturesApiElements) { skip() }
components.java.withVariantsFromConfiguration(configurations.testFixturesRuntimeElements) { skip() }
publishing.publications.named("elastic").configure {
suppressPomMetadataWarningsFor("testFixturesApiElements")
suppressPomMetadataWarningsFor("testFixturesRuntimeElements")
}
configurations {
integTestImplementation.extendsFrom(testFixturesApi)
integTestRuntimeOnly.extendsFrom(testRuntimeOnly)
register("reaper")
}
repositories {
mavenCentral()
gradlePluginPortal()
}
dependencies {
reaper project('reaper')
api localGroovy()
api gradleApi()
api 'org.apache.commons:commons-compress:1.19'
api 'org.apache.ant:ant:1.10.8'
api 'commons-io:commons-io:2.2'
testFixturesApi "junit:junit:${props.getProperty('junit')}"
testFixturesApi "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${props.getProperty('randomizedrunner')}"
testFixturesApi gradleApi()
testFixturesApi gradleTestKit()
testFixturesApi 'com.github.tomakehurst:wiremock-jre8-standalone:2.23.2'
testFixturesApi platform("org.spockframework:spock-bom:2.0-M5-groovy-3.0")
testFixturesApi("org.spockframework:spock-core") {
exclude module: "groovy"
}
integTestImplementation("org.spockframework:spock-junit4") {
because 'required as we rely on junit4 rules'
}
integTestImplementation(platform("org.junit:junit-bom:${props.getProperty('junit5')}"))
integTestImplementation("org.junit.jupiter:junit-jupiter") {
because 'allows to write and run Jupiter tests'
}
integTestRuntimeOnly("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'
}
}
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()
}
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("check").configure { dependsOn("integTest") }
// TODO These additional conventions will be applied once those plugins have been ported to build-conventions and
//
// apply plugin: 'elasticsearch.build'
//
// // 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")
//
//
// 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")
// }
//
//
// tasks.named("forbiddenPatterns").configure {
// exclude '**/*.wav'
// exclude '**/*.p12'
// exclude '**/*.jks'
// exclude '**/*.crt'
// // the file that actually defines nocommit
// exclude '**/ForbiddenPatternsTask.java'
// exclude '**/*.bcfks'
// }
//
// eclipse {
// classpath {
// plusConfigurations += [configurations.integTestRuntimeClasspath]
// }
// }
//
// tasks.named("testingConventions") {
// naming.clear()
// naming {
// Tests {
// baseClass 'org.elasticsearch.gradle.internal.test.GradleUnitTestCase'
// }
// TestSpec {
// baseClass 'spock.lang.Specification'
// }
// }
// }