2015-11-10 02:34:22 -05:00
|
|
|
/*
|
|
|
|
* Licensed to Elasticsearch under one or more contributor
|
|
|
|
* license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright
|
|
|
|
* ownership. Elasticsearch licenses this file to you under
|
|
|
|
* the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
* not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing,
|
|
|
|
* software distributed under the License is distributed on an
|
|
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
* KIND, either express or implied. See the License for the
|
|
|
|
* specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*/
|
2015-10-29 14:40:19 -04:00
|
|
|
|
2016-05-07 01:22:38 -04:00
|
|
|
import java.nio.file.Files
|
|
|
|
|
2017-11-15 08:50:13 -05:00
|
|
|
import org.gradle.util.GradleVersion
|
|
|
|
|
2015-11-23 17:11:32 -05:00
|
|
|
apply plugin: 'groovy'
|
2015-10-29 14:40:19 -04:00
|
|
|
|
|
|
|
group = 'org.elasticsearch.gradle'
|
2016-05-07 01:22:38 -04:00
|
|
|
|
2017-03-21 06:20:04 -04:00
|
|
|
if (GradleVersion.current() < GradleVersion.version('3.3')) {
|
|
|
|
throw new GradleException('Gradle 3.3+ is required to build elasticsearch')
|
2016-06-18 13:27:48 -04:00
|
|
|
}
|
|
|
|
|
2017-02-03 01:58:19 -05:00
|
|
|
if (JavaVersion.current() < JavaVersion.VERSION_1_8) {
|
|
|
|
throw new GradleException('Java 1.8 is required to build elasticsearch gradle tools')
|
|
|
|
}
|
|
|
|
|
2016-05-07 01:22:38 -04:00
|
|
|
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 *
|
|
|
|
*****************************************************************************/
|
2015-10-29 14:40:19 -04:00
|
|
|
|
2015-11-10 02:34:22 -05:00
|
|
|
Properties props = new Properties()
|
|
|
|
props.load(project.file('version.properties').newDataInputStream())
|
|
|
|
version = props.getProperty('elasticsearch')
|
2016-02-20 14:53:47 -05:00
|
|
|
boolean snapshot = "true".equals(System.getProperty("build.snapshot", "true"));
|
|
|
|
if (snapshot) {
|
|
|
|
// 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.
|
2016-02-20 20:12:48 -05:00
|
|
|
version += "-SNAPSHOT"
|
2016-02-20 14:53:47 -05:00
|
|
|
props.put("elasticsearch", version);
|
|
|
|
}
|
|
|
|
|
2016-05-07 01:22:38 -04:00
|
|
|
File tempPropertiesFile = new File(project.buildDir, "version.properties")
|
|
|
|
task writeVersionProperties {
|
|
|
|
inputs.properties(props)
|
|
|
|
outputs.file(tempPropertiesFile)
|
|
|
|
doLast {
|
|
|
|
OutputStream stream = Files.newOutputStream(tempPropertiesFile.toPath());
|
|
|
|
try {
|
|
|
|
props.store(stream, "UTF-8");
|
|
|
|
} finally {
|
|
|
|
stream.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
processResources {
|
|
|
|
dependsOn writeVersionProperties
|
|
|
|
from tempPropertiesFile
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* Dependencies used by the entire build *
|
|
|
|
*****************************************************************************/
|
2015-11-10 02:34:22 -05:00
|
|
|
|
2015-10-29 14:40:19 -04:00
|
|
|
repositories {
|
2015-10-29 16:59:10 -04:00
|
|
|
jcenter()
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
compile gradleApi()
|
|
|
|
compile localGroovy()
|
2015-11-10 02:34:22 -05:00
|
|
|
compile "com.carrotsearch.randomizedtesting:junit4-ant:${props.getProperty('randomizedrunner')}"
|
|
|
|
compile("junit:junit:${props.getProperty('junit')}") {
|
2015-10-29 14:40:19 -04:00
|
|
|
transitive = false
|
|
|
|
}
|
|
|
|
compile 'com.netflix.nebula:gradle-extra-configurations-plugin:3.0.3'
|
2016-05-05 20:53:01 -04:00
|
|
|
compile 'com.netflix.nebula:nebula-publishing-plugin:4.4.4'
|
2015-10-29 16:59:10 -04:00
|
|
|
compile 'com.netflix.nebula:gradle-info-plugin:3.0.3'
|
|
|
|
compile 'org.eclipse.jgit:org.eclipse.jgit:3.2.0.201312181205-r'
|
|
|
|
compile 'com.perforce:p4java:2012.3.551082' // THIS IS SUPPOSED TO BE OPTIONAL IN THE FUTURE....
|
2017-10-04 03:20:23 -04:00
|
|
|
compile 'de.thetaphi:forbiddenapis:2.4.1'
|
2015-12-18 13:59:07 -05:00
|
|
|
compile 'org.apache.rat:apache-rat:0.11'
|
2017-08-24 18:46:49 -04:00
|
|
|
compile "org.elasticsearch:jna:4.4.0-1"
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
|
|
|
|
2017-03-22 02:32:40 -04:00
|
|
|
// Gradle 2.14+ removed ProgressLogger(-Factory) classes from the public APIs
|
|
|
|
// Use logging dependency instead
|
2017-11-15 08:50:13 -05:00
|
|
|
// Gradle 4.3.1 stopped releasing the logging jars to jcenter, just use the last available one
|
|
|
|
GradleVersion logVersion = GradleVersion.current() > GradleVersion.version('4.3') ? GradleVersion.version('4.3') : GradleVersion.current()
|
2017-01-24 05:03:07 -05:00
|
|
|
|
2017-03-22 02:32:40 -04:00
|
|
|
dependencies {
|
2017-11-15 08:50:13 -05:00
|
|
|
compileOnly "org.gradle:gradle-logging:${logVersion.getVersion()}"
|
2017-03-22 02:32:40 -04:00
|
|
|
compile 'ru.vyarus:gradle-animalsniffer-plugin:1.2.0' // Gradle 2.14 requires a version > 1.0.1
|
2017-01-19 03:56:54 -05:00
|
|
|
}
|
2016-05-07 01:22:38 -04:00
|
|
|
|
|
|
|
/*****************************************************************************
|
2016-05-09 13:17:47 -04:00
|
|
|
* Bootstrap repositories *
|
2016-05-07 01:22:38 -04:00
|
|
|
*****************************************************************************/
|
|
|
|
// this will only happen when buildSrc is built on its own during build init
|
|
|
|
if (project == rootProject) {
|
|
|
|
|
|
|
|
repositories {
|
2017-02-15 00:31:56 -05:00
|
|
|
if (System.getProperty("repos.mavenLocal") != null) {
|
|
|
|
mavenLocal()
|
|
|
|
}
|
2016-05-07 01:22:38 -04:00
|
|
|
mavenCentral()
|
2016-02-20 14:53:47 -05:00
|
|
|
}
|
2016-06-03 12:48:45 -04:00
|
|
|
test.exclude 'org/elasticsearch/test/NamingConventionsCheckBadClasses*'
|
2015-11-10 10:30:11 -05:00
|
|
|
}
|
2015-12-03 22:53:50 -05:00
|
|
|
|
2016-05-07 01:22:38 -04:00
|
|
|
/*****************************************************************************
|
|
|
|
* 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: 'nebula.maven-base-publish'
|
|
|
|
apply plugin: 'nebula.maven-scm'
|
|
|
|
|
|
|
|
// groovydoc succeeds, but has some weird internal exception...
|
|
|
|
groovydoc.enabled = false
|
|
|
|
|
|
|
|
// build-tools is not ready for primetime with these...
|
|
|
|
dependencyLicenses.enabled = false
|
|
|
|
forbiddenApisMain.enabled = false
|
2016-06-03 12:48:45 -04:00
|
|
|
forbiddenApisTest.enabled = false
|
2016-05-07 01:22:38 -04:00
|
|
|
jarHell.enabled = false
|
|
|
|
thirdPartyAudit.enabled = false
|
|
|
|
|
|
|
|
// test for elasticsearch.build tries to run with ES...
|
|
|
|
test.enabled = false
|
|
|
|
|
|
|
|
// TODO: re-enable once randomizedtesting gradle code is published and removed from here
|
|
|
|
licenseHeaders.enabled = false
|
|
|
|
|
|
|
|
forbiddenPatterns {
|
|
|
|
exclude '**/*.wav'
|
|
|
|
// the file that actually defines nocommit
|
|
|
|
exclude '**/ForbiddenPatternsTask.groovy'
|
|
|
|
}
|
2016-06-03 12:48:45 -04:00
|
|
|
|
|
|
|
namingConventions {
|
|
|
|
testClass = 'org.elasticsearch.test.NamingConventionsCheckBadClasses$UnitTestCase'
|
|
|
|
integTestClass = 'org.elasticsearch.test.NamingConventionsCheckBadClasses$IntegTestCase'
|
|
|
|
}
|
2017-04-25 21:11:47 -04:00
|
|
|
|
|
|
|
task namingConventionsMain(type: org.elasticsearch.gradle.precommit.NamingConventionsTask) {
|
|
|
|
checkForTestsInMain = true
|
|
|
|
testClass = namingConventions.testClass
|
|
|
|
integTestClass = namingConventions.integTestClass
|
|
|
|
}
|
|
|
|
precommit.dependsOn namingConventionsMain
|
2015-12-03 22:53:50 -05:00
|
|
|
}
|